CSH-- : what modern script languages boil down to on the 6502
Posted: Wed Nov 11, 2020 3:58 pm
Take Python, and shake it down to the X16's hardware. We'd probably lose space-awareness in exchange for block delimiters and statement terminators (no, really) -- call it syntactic sugar in exchange for less parsing code, and probably less memory. Naturally, we'd lose most or all of our regular expressions and all the other powerful things that make Python modern. Lambdas gone. Multiline comments gone too (not because it's hard, but because every little bit helps, and we can sacrifice some things to keep others, such as slices). Dictionaries are gone. And of course, no importing libraries. Other things would end up on the chopping block -- in short, if you want to keep Favorite Feature X, you'll have to sacrifice Features Y+ to get it.
But we WOULD still need the REPL, and in fact, the REPL would have to be expanded to be more of a regular execution environment: in a word, a SHELL, with a management layer built on top of the KERNAL.
In short, we'd be left with a 3GL that, except perhaps for visible features, differs little from some 3GLs of the early 70s with some Pythonic syntax. This feature set is:
* "untyped" variables (or, more appropriately termed, "multi-type" variables).
* tuples, and maybe slices.
* typical control structures (if, while).
* comparison, arithmetic, logical, and bitwise operators of course.
* list comprehensions (foreach).
* typical built-in functions (len).
* # comment
* nested control blocks, to some degree (depending on how we do the stack).
Plus something 3GLs of the 70s didn't have:
* an execution shell (the REPL might have to be grown in some ways, and shrunk in others).
Now take Perl, and do the same thing. Gone are hashtables, regexes, curly braces. Gone is CPAN. Gone are first-class functions. Gone are most of the sed- and AWK-like features. And so on. And its debugging runtime would have to be expanded into a full execution environment: in a word, a SHELL, with a management layer built on top of the KERNAL.
In short, we'd be left with a 3GL that, except perhaps for visible features, differs little from some 3GLs of the early 70s with some Perlish syntax. This feature set is:
* "untyped" variables (or, more appropriately termed, "multi-type" variables).
* arrays, and maybe slices.
* typical control structures (if, while).
* comparison, arithmetic, logical, and bitwise operators of course.
* list comprehensions (foreach).
* typical built-in functions (len).
* # comment
* nested control blocks, to some degree (depending on how we do the stack).
Plus something 3GLs of the 70s didn't have:
* an execution shell (the debugger might have to be grown in some ways, and shrunk in others).
Do the same thing with Groovy, or Ruby, and you get the same results (Yeah yeah, I know, Groovy and Ruby and Perl are more similar than different. Sue me.)
Look familiar?
The more I squint, the more this resembles a minimal shell. C shell, in particular, for its tradeoff of relative power and simplicity.
Call it "CSH minus minus".
Alex Johnson, an online nerd friend, stated this obvious fact to me yesterday, and I immediately realized he was right.