Hacker News new | ask | show | jobs
by progman 3434 days ago
I'm reminded of my good old Forth times (6502 on Commodore PET), and I'm glad that Forth gets the increasing attention which it actually deserves.

I don't know if there is any other programming environment at all where you can have a extensible programming language, editor, compiler, interpreter, debugger, libs, and interactive shell in a few KB.

1 comments

As much as I like Forth, it isn't the only player in the restricted memory arena. Several models of the Commodore PET came with 32kb of RAM, and 18kb of ROM. Here are some that reflect similar requirements.

uLisp [0], 2kb of RAM, and 32kb to store the interpreter in. You can write programs at the REPL, and burn them into the EEPROM.

TinyBASIC [1], since dead, is a port of the version of BASIC that used to run on the Altair 8800, which was an even more constrained system than most PETs! Altair BASIC could run on 4kb of RAM.

Python-On-A-Chip [2], is a subset of Python. At a guess, from the supported platforms, it can run on around 2kb of RAM.

iArduino [3], is a C interpreter that can run in 2kb of RAM.

MicroPython is looking to come to the ESP8266 [4], which is much, much bigger at 512kb. Which basically makes it the fattest of these, and impossible to run on something like the PET.

Bitlash is a completely new language [5], and can run on 2kb of RAM, and takes up surprisingly little storage space.

All of these languages offer at least a REPL, as well as compatibility with a wide range of libraries, and most have at least traceback and exception support.

This is not to say Forth is a bad choice! It works great in tiny memory, with better support for a full language specification than many other languages.

But not everyone wants a Forth... And there are plenty of choices out there.

[0] http://www.ulisp.com/

[1] http://hackaday.com/2011/08/28/basic-programming-on-an-ardui...

[2] https://github.com/jsnyder/python-on-a-chip

[3] http://n.mtng.org/ele/arduino/iarduino.html

[4] https://github.com/micropython/micropython/tree/master/esp82...

[5] https://github.com/billroy/bitlash/wiki

Yes, there are plenty of options. However, most of those options lack something while Forth is all-inclusive. All your options have no compiler while Forth compiles to threaded code which is pretty fast, about 1/10 the speed of assembler according to my experience. Your options have a linear space consumption while Forth code compiles "logarithmic" due to its extensible vocabulary. That means, if you have an 8K system (like on my former PET-2001) you need 4K for a convenient basic Forth for instance, while you can put a lot more stuff in the other 4K, due to the threaded code.
Well, TinyBASIC was available as both an interpreter, but more often, as a compiler.

Though it was a primitive compiler compared to today, due to the size of the language, it easily fit within 2-3kb, which on your 8kb system, would leave 5kb or more for program memory.

In fact, some TinyBASIC systems had a virtual machine and JIT compiler in 120 instructions, or around 2kb, as early as 1964.

Though BASIC is slower than Forth, or was in those days, the main benefit is instant availability. BASIC syntax was the jumping on point for more than a few programmers, myself included, because of it's simplicity.

Btw. for those who are interested in Forth, I recommend to read the "Forth Dimension" archive. It was rightly called the "best special-interest technical magazine ever".

http://www.forth.org/fd/FDcover.html

Additionally one should add that the mainframes where Lisp was initially developed, were quite constrained, even when compared with 8 bit micros.