3 ms·
For years I've been railing about how lousy the language FORTH is. I have a confession to make, I actually think it has some charm. Despite the horribly coupl
by kabdib 15y ago
For years I've been railing about how lousy the language FORTH is. I have a confession to make, I actually think it has some charm. Despite the horribly coupled and low-level thinking that needs to go into writing a program of even moderate length in FORTH, I believe that there is hope for the language, and that it is even quite appropriate for use today, in modern systems, because in some circumstances it is better than the alternatives.
But first, we need to agree on the problem space.
FORTH was originally used for non-critical real time control of telescope hardware. The computation requirements were quite modest, there was limited storage available, and the audience was pretty technical. The programs did not have much dynamic state.
Generally, FORTH has been a failure outside of this envelope. While there are very whizzy specialized implementations of FORTH that are very close to equally specialized hardware, and that are capable of exceptional performance and turning really neat tricks, the usual result of bringing FORTH to bear on problems that have a large amount of state or very hard real-time requirements are: Slipped schedules, eventual cancellation of projects, and the labeling of anything dealing with the language as unhealthy fanatacism.
In the hands of a moderately skilled programmer, FORTH is good at:
- near-real-time operations involving modest amounts of computation
- rapid prototyping of same
- stuff whose consumers are very technical and can Deal With support along the lines of "comment out that line, stick this code in and try it again"
In my experience FORTH has not demonstrated success at projects that involve more than three or four engineers, projects that have extensive or complex data structures, or that require high performance (i.e., when microseconds count). This counts out video games (I've seen a lot of these attempts fail), operating systems (ditto), and commercial applications like word processors (shudder).
But if you've got a telescope to control, or a mass spectrometer, or you're doing new hardware bringup, FORTH is great stuff, and I've seen it shine.
- kabdib 15y agoI'll add: FORTH is incredibly easy to bring up. It was the first compiler I ever implemented, after getting started with Z-80 assembly and BASIC. I recommend building a FORTH implementation as a project that everyone should do; it'll take you about a weekend.
- gnosis 15y ago"One of the most pervasive unknown Forth successes has been FedEx's handheld package tracking devices. They were all Forth powered, under-time and budget, and worked remarkably well. The new generation of FedEx package trackers (the ones that look like scan guns) use Forth as well." Much more here: http://pages.cs.wisc.edu/~bolo/forth/#projects http://pages.cs.wisc.edu/~bolo/forth/#projects
- kabdib 15y agoIIRC the "new" Denver airport luggage handling system was a disaster, and it was written in FORTH. [I tried to find references, but couldn't. I do remember finding this out, and saying "That explains /everything/!"] You can code a train-wreck in anything, I guess.
- uxp 15y agoOn the other hand, the FreeBSD bootloader is written in Forth. Per installation, the Denver Airport luggage handling system was massively much more complex, but that doesn't make one terrible implementation representative of the entire language. Good things can still be well written in languages that aren't C. http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/boot/forth/ http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/boot/forth/ And for some sources for the Denver Airport claim: http://developers.slashdot.org/story/05/08/27/1634255/Denver-Airport-Automated-Baggage-System-Abandoned http://developers.slashdot.org/story/05/08/27/1634255/Denver... http://www.44342.com/forth-f381-t4059-p1.htm http://www.44342.com/forth-f381-t4059-p1.htm Edit: it should be noted that the mechanical side of the baggage handling system was extremely complex, and at the beginning was prone to breaking.
- stewbrew 15y agoI wouldn't call it a failure outside the telescope market. IIRC the first Mac apps were written in forth. There is a forth interpreter for every platform. Quite a few smaller apps for older computers or handheld devices were written in forth. AFAIK it's still used for embedded systems programming. But the language is rather old. The standard was never updated to turn forth into a "modern" language. And then there is the community. Even things like named "function" arguments are scowled at.
- kabdib 15y agoI used MacFORTH back in 1985 because I wanted to get a leg up on Mac programming, and it was one of the few environments that worked on a 128K Mac with two floppy drives. It was awful; I'll note that MacFORTH sank pretty rapidly once even halfway decent IDEs became available. http://www.dadhacker.com/blog/?p=1468 http://www.dadhacker.com/blog/?p=1468 One of the reasons there is a FORTH interpreter for every platform is that it's so easy to port or bring up that it's /always/ an early arrival. It's sure not modern. Unextendeded FORTH has nothing like a heap (just stack-like allocation). I could go on. And yeah, you get yelled at by FORTH purists who see nothing wrong with the language. They can be an interesting crowd to deal with; the most incompetent ones seem to be the loudest and most arrogant about FORTH's universal applicability to everything (and if you can't see this, you're a moran). See earlier comment about projects running late, then killed. [Back in the day, when I was working on database engines at a largish computer company, a manager of mine said, "I've got to go over to building 123 and evaluate a proposal by some people who want to sell us an O(N) sorting algorithm." "Don't they know that's impossible?" "No. They claim they've done it. They got some people in Marketing all excited. They think it could be really big." "Huh." "They've written it in FORTH." (pause) "They're stark raving loonies," I said. Oh, and it was about as miserable and as confused and misguided and very nearly fraudulent as you can imagine. Go figure.]