Not my main work, but a fun little programming pro...
# share-your-work
k
Not my main work, but a fun little programming project that's relevant in a number of ways, despite apparently being more about the Past of Coding, than the Future. I wrote a small (<500 lines of code) BASIC to JS compiler, that lets me run the programs from the class book 101 BASIC Computer Games from 1978. It's interesting for two reasons I think: 1. for those who want to learn about languages and compilers, this provides a very simple example 2. philosophically, I think BASIC really exemplifies the Worse is Better approach outlined by Richard Gabriel and covered in a FOC podcast. It is a terrible language in many ways, but it was small enough to be stored in a 4k ROM and be used to to useful things on an early microcomputer with only 4k of RAM. If we had waited for machines with enough memory to run Lisp, Smalltalk or Algol, the microcomputer revolution would have been delayed by a decade or more. Source: https://github.com/kgrgreer/foam3/tree/429f2fd2b4cef0e37996a4c4ad35cdf5f83a8b97/src/foam/demos/basic Online version: https://codepen.io/kgr/details/yLQyLjR
k
If we had waited for machines with enough memory to run Lisp, Smalltalk or Algol, the microcomputer revolution would have been delayed by a decade or more.
By my personal tastes, the best language for early microcomputers would have been Forth. It was around by then, but maybe not known widely enough. Or maybe someone decided it was too weird for ordinary people. There was one home computer model based on Forth (the Jupiter Ace), which was not much of a commercial success, but it also appeared too late - BASIC was already everywhere.
k
Yes, that's true. I'm a big fan of FORTH, having used it a lot in the 80's and am even writing a lexically-scoped OO FORTH-like system: https://github.com/kgrgreer/TURTLES/tree/main . Also, some early microcomputers (https://en.wikipedia.org/wiki/MCM/70) used APL, but neither APL nor FORTH were as accessible as BASIC. LOGO, which is a simplified dialect of LISP, and actually a pretty good language, might have been a better choice. But people looked down on it because of its use with Turtle graphics and being for kids, but it is actually a much better language than BASIC (or just about anything else at the time).
Also, I think that a big difference between FORTH and BASIC was that BASIC was suitable for use with a tape drive, whereas FORTH required a much more expensive floppy. This is because you would need to save much more frequently with FORTH because it wasn't memory safe and running your program could crash your machine and lose your changes. BASIC, on the other hand, would just give something like a 'SYNTAX ERROR: line 20', and nothing would be lost. With BASIC, you could program for hours and just save once at the end, which is something you couldn't do with FORTH. This effectively raised the price of a minimally viable machine.
k
Memory safety is indeed a big advantage of BASIC!
m
I think BASIC is underappreciated these days. Apart from memory safety (with the concept really not even surfacing), BASIC also has some advantages in being very straightforward and linear, rather than hierarchical. Which is not just easy to understand. but actually also a close analogue to how the CPU executes instructions, at least conceptually. That also enables a very direct transition from immediate mode execution to stored program: just add a line number in front.
k
That's an interesting observation for me because (1) it's clearly true, (2) looks like a good characteristic for newbies but (3) is also exactly why I didn't like BASIC. I wanted to get details out of my view, to focus on a bigger picture. My solution was printing the code, with subroutines on separate pages, starting with a comment that gave a name to the subroutine. Each
gosub
also had a comment with the name of the subroutine being called.
m
Yes, the very things that are good are often also bad in different ways. Trick is then to understand the good well enough to figure out a way of getting it without the bad.
k
And vise-versa. That's what half of the book "The Innovator's Dilemma" is all about.