Pages

Wednesday, 8 February 2012

Go, FORTH, and multiply

In an exchange on twitter yesterday I was (gently) taken to task for suggesting that it would be a good thing to port FORTH to the Raspberry Pi so that young developers could learn about it.


It's hard to conduct a fully developed argument in 140-character bites, so this is an attempt to set out my position in a bit more detail.


My first assumption is that the goal of Raspberry Pi is education, not training: in other words, I think it's aiming to broaden the horizons of young minds rather than (just) teaching young people how to write programs for money.


To support my case, I'm going to rely on advice from one if the giants of computing: Alan Perlis. One of his epigrams was 'A language that doesn't affect the way you think about programming, is not worth knowing.'


Of course, we shouldn't infer that a language that does affect the way you think about programming is worth knowing: the most obvious counter-example is brainf**k. Admittedly, bf manages to do with eight characters what C++ needs the whole keyboard to achieve, but that is scarcely a recommendation.


I believe that there are some languages which have a big effect when you learn them, and are worth knowing. My personal list includes Snobol, APL, FORTH, Smalltalk, Python, Haskell and clojure.


I think these are landmarks of computing in much the same way that the works of Homer, Virgil, Chaucer, Dante, Cervantes, Shakespeare,  Moliére and Dickens are landmarks of literature. No 19th century European would call him or herself well-educated without a passing knowledge of them. When we read these authors we change the way we think about the world.


I'd argue that the languages in my list (among many others) can have a profound effect on the way we think about those stores of knowledge we call programs. We shouldn't force anyone to learn these languages, but we can  make them readily available, and might even seek to pique the interest of the young.


So what's special about FORTH?


Like the others on my list, it is a concise, expressive language. It's also easy to port, and amazingly compact. You can create a FORTH runtime in 2k bytes. You can create a self-hosted development environment, complete with file system and editor, in about 8k bytes.


FORTH enjoyed a minor renaissance with the advent of 8-bit microcontrollers, but 32-bit chips are more forgiving of bloat. It may get a third boost, though, when home-made 3D printers can print a few thousand transistors, which I suspect will happen within the next 5 years.


In the mean time, FORTH is worth looking at for embedded applications. It has been used on the majority of NASA space probes for the last 50 years; there's probably room for it in less ambitious engineering projects.

1 comment:

  1. We use forth for embedded systems in all our computerised products. The tremendous advantage is the the ability to interact with the unit and set up testing routines on the fly. It is great for controlling hardware and very easy to debug problems.

    ReplyDelete