Thursday, January 5

Browsing Forth

Forth has a strong following among embedded developers. There are a couple of reasons for that. Almost any computer can run Forth, even very small CPUs that would be a poor candidate for running programs written in C, much less host a full-blown development environment. At its core, Forth is very simple. Parse a word, look the word up in a dictionary. The dictionary either points to some machine language code or some more Forth words. Arguments and other things are generally carried on a stack. A lot of higher-level Forth constructs can be expressed in Forth, so if your Forth system reaches a certain level of maturity, it can suddenly become very powerful if you have enough memory to absorb those definitions.

If you want to experiment with Forth, you probably want to start learning it on a PC. There are several you can install, including gForth (the GNU offering). But sometimes that’s a barrier to have to install some complex software just to kick the tires on a system.

We have all kinds of other applications running in browsers now, why not Forth? After all, the system is simple enough that writing Forth in Javascript should be easy as pie. [Brendanator] did just that and even enhanced Forth to allow interoperability with Javascript. The code is on GitHub, but the real interesting part is that you can open a Web browser and use Forth.

If you want to learn Forth, you could do worse than start here. You can also use the Web browser-based Forth to try things as you read. If you want to create you own Forth, though, you really ought to read JONESFORTH. Not only is it a Forth system in two files (an assembly language file and a Forth file), but it is one of the best examples of literate programming we’ve ever seen.

In addition to a lot of older computers and–of course–the PC, you can find Forth for many modern processors. For example, we’ve seen systems for the LPC ARM chips. There’s even a version for the ESP8266 and the Arduino (see the video about that Forth, below).


Filed under: Software Development, software hacks

No comments:

Post a Comment