

Starting Forth – the classic Forth language tutorial - synchronise
http://www.forth.com/starting-forth/

======
bjz_
Factor is another interesting concatenative programming language (inspired by
Forth): [http://concatenative.org/](http://concatenative.org/) I've been
playing around with it for the past few days and found it to be very well
documented. Well worth a look if you're looking for something to bend you mind
in new ways!

~~~
ggchappell
I like Factor a lot. Forth has always struck me as something with potential;
but, alas, it's stuck in the 70s. Data structures are painful. You can forget
about anything like generics, polymorphism, interfaces, etc. It supports
functional programming poorly. It fails to benefit from modern ideas about
modules/namespaces or type systems that stay out of your way. And there is no
protection from anything at all. When I look at Factor, I find myself
thinking, "This is what Forth should have been."

So, yes, Factor is worth a look. Certainly as a mind-expander, and possibly as
a practical production language (just guessing here).

------
synchronise
This combined with JS-FORTH allows a person to learn and test examples without
having to download any extra software.

[http://forthfreak.net/jsforth80x25.html](http://forthfreak.net/jsforth80x25.html)

~~~
RodgerTheGreat
[http://repl.it/](http://repl.it/) has a JS-Forth mode with a somewhat nicer
interface- I often use it when tinkering from an office machine or public
computer.

~~~
amasad
Coincidentally, I was just updating the editor on repl.it and added Forth
syntax highlighting mode.

------
fizfaz
Just wanted to mention that Thinking Forth "A Language and Philosophy for
Solving Problems" (also from Leo Brodie) is available here: [http://thinking-
forth.sourceforge.net](http://thinking-forth.sourceforge.net)

I learned a lot from this book.

------
liyanchang
tl;dr

Forth is a programming language from the 1970s. This is the canonical book,
published by someone who works at Forth Inc. (as K&R is to C)

Forth is interesting, not because of widespread usage, but because it has a
different way of looking at things. Reminiscent of people who tell you that
you should learn LISP because you'll never use it, but it will make you a
better programmer.

The key difference is that it is stack based. (For those who are more mathy,
you may have heard of RPN on the HP calculators)

e.g. 2 5 * 3 -

is take 2 and 5, multiply them. Take the result and 3, subtract them. get 7.

The wiki article has a nice picture of stacks that may help:
[http://en.wikipedia.org/wiki/Forth_(programming_language)](http://en.wikipedia.org/wiki/Forth_\(programming_language\))

(btw, not super knowledgable about this stuff; just super confused, did some
digging and figured others would be confused as well. Happy to edit.)

EDIT 1: Habits die hard. Corrected Fourth to Forth.

------
rwmj
[http://git.annexia.org/?p=jonesforth.git;a=tree](http://git.annexia.org/?p=jonesforth.git;a=tree)

Start with 'jonesforth.S'

------
tikhonj
I've always wanted to write a Forth tutorial just to take advantage of all the
"forth" puns that come to mind. I could call it "setting Forth" :).

Seriously though, I could probably write something interesting about
ArrayForth and GreenArray chips--I've been playing around with them for a
while and even wrote an emulator for their instruction set. Yet another topic
in the queue for my blog, which doesn't even exist yet :P.

------
robomartin
I love Forth and used it extensively for many years. I wonder how much real
use it is seeing today. I remember a situation many years ago where a friend
of mine chose to code his embedded product in Forth. As the company grew it
became difficult to find programmers. As things got to the point where
acquisition started to become a possibility Forth became a liability. He had
to convert the entire code base to C in order to remove objections. I pitched
in and helped with the effort. While it wasn't terribly difficult it did take
time and cost money.

That experience probably marked the last time I used Forth on an embedded
system. Every time I considered the idea for my own work I remembered what
happened to him. As a result I pretty much stayed with C/C++ for embedded work
from that point forward.

My gut feeling is that today Forth is a liability for most applications
outside cases where there might be an existing code base that must be
leveraged.

EDIT: I still think it is important for programmers to learn about TIL's and
Forth. You'd gain valuable perspective and a different way to see and approach
problems.

~~~
bcoates
Stories like this always astound me. Learning Forth is probably less difficult
than the average GUI widget library. Anyone who I'd trust around a C compiler
could probably become a serviceable Forth coder in a weekend.

Do moderately bright kids not get exposed to HP RPN calculators anymore?

~~~
smoyer
I did exactly that ... learned FORTH to get a job and (almost) immediately
started helping with embedded systems using assembly and C.

------
zaf
I've just recently started to dig into stack-based programming languages and
would love to get hold of the Leo Brodie manuals.

One question to programming language experts: Is it possible to have a stack-
based programming like forth but without the need for the extra characters
needed in the syntax (like quotes, brackets etc..) and only use whitespace to
separate the 'words'?

~~~
dvdkhlng
Stack-based programming does _not_ need extra syntax characters (what you call
quotes and brackets) to structure the program.

    
    
      arithmetic syntax:  (a+b)*c
      lisp syntax (polish notation): (* (+ a b) c)
      forth syntax (reverse polish notation):  a b + c *
    

In fact all words in Forth are only separated by whitespace. However, to
"emulate" more complex syntax, some words in Forth are marked to be executed
immediately upon parsing (somewhat like "macros" in lisp) and then access the
input stream to extract more than whitespace-separated tokens. Exampes:

    
    
      '('  parses comments :   ( comment)
      's"' compiles string literals :   s" abc"
      '[if]' conditionally skips code fragments:   0 [IF] bla [THEN]
    

Still the macro word itelsf needs to be whitespace-delimited.

~~~
zaf
Ah, so you mean that certain words can not only look at the stack but also
look at manipulate the input word stream.

Thanks for the explanation. I really ought to do a practical session with
Forth.

~~~
dvdkhlng
There are various levels of abstraction when accessing the input stream. The
lowest level is by inspecting the input (line) buffer. Just realized how that
allows one to write a three-word quine [1] in ANS-compliant Forth:

    
    
      SOURCE TYPE BYE
    

[1]
[https://en.wikipedia.org/wiki/Quine_%28computing%29](https://en.wikipedia.org/wiki/Quine_%28computing%29)

------
bjpcjp
My first job after grad school with at Harris Semiconductor. We were selling
RTX processors which natively ran Forth instructions. (The architecture was
completely stack-based.)

I agree that Forth is a liability today. I could see it being used as an
introductory language - in junior high school, for example - but not much
beyond that.

------
jim_lawless
Here's a list of some other free books on Forth and stack-machines.
[http://www.linuxlinks.com/article/20130618144353106/Invaluab...](http://www.linuxlinks.com/article/20130618144353106/InvaluableForthBooks.html)

------
jyf1987
there is jeforth running on js and have canvas support

[http://www.jeforth.com](http://www.jeforth.com)

------
Pitarou
Always wanted to study Forth! :-)

------
jacques_chester
I have what I believe is a first edition. I grabbed it from the giveaway pile
at my university, thinking it was not the kind of book you could buy anymore.

Great to see it online.

~~~
gngeal
Scan it and post it! Some of us love old time typography.

