The whole “make it is compact and efficient” as possible seems to go back to the day of the 4 K Hertz microprocessor. Back then it made sense. Now, even if you’re running it down a raspberry pi it takes about 1 billionth of a second for it to deal with you in efficiency. But it takes me four hours to unravel whatever the hell it was you wrote when looking at the code.
I started writing software for $ on an 8 bit TRS-80 Model 1 with 48K RAM and four 95K floppy drives with a 2 khz Z-80, so I know how to do compact code. I believe I think more about how things probably are in memory and how many allocations are happening, whether I’m on a (potentially) hot path or not, etc., than your average noob, because I have a much more complete mental model of the machine in my head vs., often close to none at all in young jedis.
All that said, I agree with what you said here. What I avoid is disorganized or slovenly code, and I probably make better decisions overall, but I do not obsess about being terse at the expense of clarity, and I don’t (prematurely) over-optimize for performance as it often doesn’t matter enough to bother.
Compactness usually has nothing to do with how fast the code is executed, but may have to do with how much memory is used.
Back in the day, you had to shove a program into blocks of memory that sometimes did not exceed 4K (yes K , not M, not G)
Later grew to a 16K, and 2 FDD
Hey I saw what you did there, lol. 48K, not 4, and four floppies. But yeah that environment is unimaginable to most modern devs. Heck it’s barely imaginable to me anymore … I recently played with a TRS-80 emulator (Model 4, 1.5M RAM which the OS supported but the hardware never did – via bank switching) with the last release of various compilers and it was even cruder than I recall – things like no local variables, lots of weird bugs outside of happy paths, etc. I’m not sure how I ever got anything done.
a few years ago I wrote a full TRS-80 Level II emulator in Xojo… it worked quite well…
Long variable names for method names dont take any more runtime space than short ones
The compiler turns them all into addresses anyways so those long name are JUST for you and me & other readers
This is going back a LOT of years but a BASIC module for an Allen-Bradley processor had some screwy rules for variable names. Variables could be a max of 8 characters, and if two variables were the same length and the first and last characters were the same they were considered the same variable.
apple1 and abbie1 were considered the same variable! It was such a stupid system!
Huh. Sounds like some weird performance optimization where they were trying to avoid comparing all the characters in the string when matching variable names. Makes more sense for an interpreter (which I assume this was) than a compiler.
There were a lot of not-so-clever hacks and quirks and limitations like this in the old BASIC interpreters.
Impressive!
The original Microsoft Basic interpreter on 8 bit systems stored variable names as literals in memory (most keywords were tokenized in memory to save space but not variable names) which encouraged the use of single-letter variables names. I think disk basic allowed maybe 8 letters max, level II might have been 2 characters, level 1 provided for just 2 strings, A$ and B$.
Those were the days
I believe Level I, only had A-Z for numeric and A$ and B$ as you said
Level II had A-Z, A1-Z9 and maybe even AA-ZZ (not sure) and if I recall it used a suffix to denote datatype !=single %=Integer #=Double and $=String
That sounds right.
Was that an interpreter or a compiler ?
Do you recall ?
Yeah interpreters generally have entirely different runtime behaviour than a compiled app
So it doesnt surprise me that an interpreted version might have those limits
Trs80 Level I, II and III were all interpeted…
No. I mean it’s only been 30 years and I only used it on the one project.
I think you were asking this RE: Allen Bradley and BASIC. I found the below hardware manual from 2005 that describes adding hardware modules for running “Intel BASIC” and it sure looks like an 8-bit interpreter, even at that late date. I suppose they were still using Intel 8080 chips to run stuff. Might still be.
IIRC I used the Allen Bradley basic module circa 1992. Back in the Stone Age of PLC’s. The AB SLC500 was brand new and I had to drag our company kicking and screaming to use them since they had standardized on the PLC 2.