Live data from Hacker News

Starting Forth

forth.com

21–30 of 71 posts

Re: Starting Forth

#21
post #9
post #3

It's really cool to see all of this interest in Forth. I think when I learned Forth, it made me a significantly better developer over all; it's also an awesome base for DSLs and really a fascinating paradigm.

Honest question, wouldn't you just write a lexer with yacc/bison for a DSL? How does a full programming language act as a base for a DSL, which is usually more limited than a programming language?

A typical use case for Forth to launch from bare metal (more like bare silicon) into the application on embedded systems or as the bootstrap mechanism/BIOS for a more advanced OS on a larger, perhaps desktop, system. A Forth console over a serial port can provide a user with tons of low and high level access to a system. I built a 12 processor "parallel" robotics controller back in the '80's using a bunch of Rockwell R65F11 Forth processors (6502's with Forth in ROM).

Re: Starting Forth

#22
post #9
post #3

It's really cool to see all of this interest in Forth. I think when I learned Forth, it made me a significantly better developer over all; it's also an awesome base for DSLs and really a fascinating paradigm.

Honest question, wouldn't you just write a lexer with yacc/bison for a DSL? How does a full programming language act as a base for a DSL, which is usually more limited than a programming language?

> Honest question, wouldn't you just write a lexer with yacc/bison for a DSL?

Perhaps this article[1] can help answer the question (BTW, the title of the page belies its applicability). Check out Figure-1 specifically.

> How does a full programming language act as a base for a DSL, which is usually more limited than a programming language?

IMHO, this is what makes Forth both beautiful and mind bending, as Forth is a "full programming language" in which programs/systems written in it are expressed as a DSL defining the system itself. If that sounded recursive, then you're well on your way to grokking Forth :-).

1 - http://www.forth.org/lost-at-c.html

Re: Starting Forth

#23
post #9
post #3

It's really cool to see all of this interest in Forth. I think when I learned Forth, it made me a significantly better developer over all; it's also an awesome base for DSLs and really a fascinating paradigm.

Honest question, wouldn't you just write a lexer with yacc/bison for a DSL? How does a full programming language act as a base for a DSL, which is usually more limited than a programming language?

Well for a lot of devices I've worked with, you can shoehorn Forth places that most (if not all) other languages short of assembler can not go (Forth is _really_ lightweight). Forth was designed with DSL's in mind (Forth has "vocabulary" which is targeted specifically at this); the language usually comes with a basic syntax and some core primitives built in, but features a really profound ability to define new primitives, even things like "if" that most languages have built-in and have no facilities for constructing variants. You might liken it to macros in Lisp.

A good place to learn more (if you have some familiarity with Lisp) is: http://stackoverflow.com/questions/24282153/comparison-of-co...

I guess the other huge nice thing abort Forth for DSLs is that it is (unlike assembler or C), an interactive language, even on the most stripped down platforms (like bare bones $0.50 8-bit MCU stripped down), and still encourages the sort of REPL experimentation typically only seen in much much higher level languages. All of this comes at a big price though, in that the caliber of developer required to wield Forth in a sane manner tends to be very high.

Re: Starting Forth

#24
post #5

Is Forth still being used in industry other than for legacy systems? (genuine question)

Yes, for starters, some hardware companies still use Forth for low level testing of devices.

Re: Starting Forth

#25
post #10

Earlier quoted context omitted.

Not much. Forth is from an era when it was hard to program small microcontrollers and the tools for doing so were expensive. Today, everybody cross-compiles to microcontrollers. I've done robotics programming in Forth. I do not expect to use it again.

What has the industry moved onto now?

Embedded stuff is nearly always C. Arduino have made the "Wiring" language popular for rapid prototyping (based on processing and hence javascript).

But these days, embedded full Linux systems are just too cheap to not be the default option when you want to develop on the device itself.

Re: Starting Forth

#26
post #5

Is Forth still being used in industry other than for legacy systems? (genuine question)

postscript is a dialect of forth http://hyperpolyglot.org/stack

I wouldn't go as far as saying Postscript is a dialect of Forth, influenced by or perhaps "Forth-like" (i.e. stack-based), but certainly not a dialect.

Re: Starting Forth

#27
Forth seems to have one thing in common with Lisp: a small dedicated following that believe it's the way forward and considerably easier to learn, despite never really having taken off.

I suspect this is something to do with different ways of conceptualising programs.

Re: Starting Forth

#28
post #27

Forth seems to have one thing in common with Lisp: a small dedicated following that believe it's the way forward and considerably easier to learn, despite never really having taken off. I suspect this is something to do with different ways of conceptualising programs.

if you take away the parentheses from Lisp you end with a Forth

Re: Starting Forth

#29
post #27

Forth seems to have one thing in common with Lisp: a small dedicated following that believe it's the way forward and considerably easier to learn, despite never really having taken off. I suspect this is something to do with different ways of conceptualising programs.

Another common thing, it also had its own computers, for example:

https://en.wikipedia.org/wiki/Jupiter_Ace

Post reply on HN