6 ms·
A few years back I too built my own Z80 based machine, and considered FORTH, but ended up writing a LISP-like language for it, including (very primitive) turtle
by fred256 10y ago
A few years back I too built my own Z80 based machine, and considered FORTH, but ended up writing a LISP-like language for it, including (very primitive) turtle graphics. You could do things like:
(define (square n)
(repeat 4 (fd n) (rt 90))
)
(square 50)
- qwertyuiop924 10y agoI could never do this. Because I would want a real Lisp. And that means things like GC. Do you want to implement GC in 64k? Also, I don't know compilers super well. And you have to know compilers to actually write an efficient lisp. I plan on learning that, at some point, but while I'm also writing an OS (or at least a monitor) for a Z80? Nope, forth it is.
- kazinator 10y agoThose BASICs have GC in <= 64K. (Well, for just character strings.) How about that IBM 704 from which we have the terms CAR and CDR? "The 737 Magnetic Core Storage Unit had 4,096 36-bit words, the equivalent of 18,432 bytes and served as RAM." [Wikipedia]
- qwertyuiop924 10y agoI didn't say it was impossible. But do you want to implement it? Besides, the 704 had some helpful features the micros didn't. Also, it was a 36-bit machine. That's a massive advantage.
- kazinator 10y agoIf I could relive the 80-s, that might be something I would work on.
- fred256 10y agoYes, my LISP(-like) did have a primitive GC. The heap consisted of fixed 4-byte cons cells (2 byte car, 2 byte cdr). The cdr value was assumed to always be a pointer, which meant that since the cells were aligned at a 4-byte boundary, I had a few spare bits to implement mark-and-sweep GC and track which data type the car value was (number, atom, list or function). Edit: I got curious and dug up the code. The entire GC code is less than 100 lines of Z80 assembler (admittedly some of the hairiest code in the interpreter, though)
- qwertyuiop924 10y agoHuh. Not so bad after all. Ah well. The other problem becomes space efficiency, but that's not unsolvable.
- pjmlp 10y ago> Do you want to implement GC in 64k? Why not? The IBM 704 had around 18k and yet it was good enough for a full Lisp system. Sometimes I think that people don't really grasp how constrained the computers using Lisp, Smalltalk and memory safe systems programming languages were and yet those systems were already there running, being used to doing actual work. Somehow C's adoption has created a strange distortion of what those computers were actually capable of, in spite of their resource constraints.
- qwertyuiop924 10y agoYeah, but the 704 was a 36-bit machine, and was otherwise well-suited to the task. Still, I might give it a shot. Once I get the damn thing working, that is.