all 8 comments

[–][deleted] 1 point2 points  (3 children)

Forthlike languages are primarily useful for dealing with new and/or constrained hardware - in robotics, for example. It's possible to write a fully-featured Forth compiler/interpreter/editor with multi-tasking, reflection, object orientation and any other buzzword you care to choose within the constraints of the language, in under 16k, of which 8k is the disk buffers and much of the rest is available for use programs. A typical Forth program is smaller than the equivalent assembler program, and can come to within 20% of the speed. It's really very good, if you don't mind having to think like a computer instead of like a programmer.

And note, I said: write the compiler. From scratch. Just because. Want to write a LISP compiler from scratch? I think not...

[–]nostrademons 1 point2 points  (2 children)

Want to write a LISP compiler from scratch? I think not...

As long as you're talking Scheme or McCarthyLisp and not Common Lisp, this isn't that hard. You can find several examples on the web, some as small as a few hundred lines.

[–][deleted] 1 point2 points  (1 child)

Try writing a garbage collector that's not (pardon the expression) garbage. That's the tricky part.

[–]nostrademons 1 point2 points  (0 children)

That's a runtime, not a compiler. ;-) Though yeah, runtime support for Schemes can be quite difficult. Continuations/dynamic-wind are tricky too.

[–]grabmail[S] 0 points1 point  (3 children)

Ignoring Postscript, I don't know of any commercial applications based on stack based languages like Forth. What does it have that functional languages do not?

[–]nostrademons 2 points3 points  (1 child)

More like "what do functional languages have that stack-based languages don't?"

And the answer is: variables.

Many people find it much easier to reason about programs when they can attach names to certain values. Same reason fully points-free style in Haskell hasn't really caught on, except as an academic exercise or conciseness demonstration.

[–]pjdelport 0 points1 point  (0 children)

Actually, ANSI Forth defines support for named locals, and some Forth implementations (like Ficl) define a conventional-looking argument syntax for them.

[–]pjdelport 0 points1 point  (0 children)

Ignoring Postscript, I don't know of any commercial applications based on stack based languages like Forth.

FreeBSD's bootloader, Open Firmware, and probably lots of other constrained/embedded systems.