3 ms·
It's because the historical perspective in this article is really lacking, despite that being the premise of the article. Not only does the author seem to beli
by tdeck 1y ago
It's because the historical perspective in this article is really lacking, despite that being the premise of the article.
Not only does the author seem to believe that C was the first popular high-level language, but the claim that hardware provided stack based CALL and RETURN instructions was not universally true. Many systems had no call/return stack, or supported only a single level of subroutine calls (essentially useless for a high level language but maybe useful for some hand written machine code).
FORTRAN compilers often worked by dedicating certain statically allocated RAM locations near a function's machine code for the arguments, return value, and return address for that function. So a function call involved writing to those locations and then performing a branch instruction (not a CALL). This worked absolutely fine if you didn't need recursion. The real benefit of a stack is to support recursion.
- cyberax 1y agoC can work just fine in systems without a stack. A very modern example: eBPF.
- deleted 1y ago[deleted]
- MichaelRo 1y agoI recall starting to program in BASIC on CP/M and ZX-Spectrum machines and they didn't have procedures, only GOTO. Just like assembler, you can use all the JMP you want and not use structured programming and procedures but ... it will all become an unmaintainable mess in short time. Very likely in a number of alternate futures (if not all of them), given the original set of CPU instructions, people would gravitate naturally to C and not some GOTO spaghetti or message passing or object oriented whatever.
- heisenbit 1y agoI remember jumping out of gosub on the Apple ][ and eventually running into an out of memory error as the stack on the 255 byte page $01 overflowed. As math was also done on the stack math functions broke. Simplifying expressions only delayed the inevitable doom. I had to abandon the project and only later understood my first encounter with a memory leak.
- weinzierl 1y agoThe BASICs of the time often had GOSUB which remembered the return address. Also, while the stack not being prominent in the high level language, they very well used one on the assembly level. For example on the C64 (probably other 6502/6510 based systems) it always started at $100 ($ being the old convention of writing hex), right after the zeropage.
- varjag 1y agoGOSUB was definitely there.
- MichaelRo 1y agoYeah, I think it was but I was just starting in programming and GOSUB didn't made much sense to me as it's not a proper structured programming procedure with input and output params but more like a hack with data passed through global variables. And by the time I learned structured programming I already moved to Pascal (HiSoft Pascal : https://www.cpcwiki.eu/index.php/Hisoft_Pascal https://www.cpcwiki.eu/index.php/Hisoft_Pascal ) and there was no turning back to BASIC.
- PeterStuer 1y agoFirst thing Hisoft Pascal did when you ran it was ask how much memory you wanted to reserve for the stack. (Or was that only in HiSoft C? I had both).