
Starting Forth - brudgers
http://www.forth.com/starting-forth/sf0/sf0.html
======
AdieuToLogic
An approachable platform for hacking Forth is the OLPC laptop[1]. For about
$25 USD[2], that's a pretty cheap way to go Forth and multiply :-).

1 -
[http://www.openfirmware.info/Forth/FCode](http://www.openfirmware.info/Forth/FCode)

2 -
[http://www.ebay.com/sch/items/?_nkw=olpc+laptop&_sacat=&_ex_...](http://www.ebay.com/sch/items/?_nkw=olpc+laptop&_sacat=&_ex_kw=&_mPrRngCbx=1&_udlo=&_udhi=&_sop=12&_fpos=&_fspt=1&_sadis=&LH_CAds=&rmvSB=true)

~~~
lukego
If you have an OLPC XO 1 then you can also download the specifications for the
AMD CPU here:
[http://www.versalogic.com/support/Downloads/PDF/LXManualMay0...](http://www.versalogic.com/support/Downloads/PDF/LXManualMay08.pdf)

That tells you how to do graphics hacks and so on. I had fun with that on my
OLPC. I optimized the Forth console to scroll using hardware BLIT (much faster
than CPU copy of the framebuffer) and I ported Squeak Smalltalk to run
directly on OFW using hardware graphics primitives e.g. for the mouse pointer.

Fun times :)

~~~
lukego
The biggest hack I did was to rewrite the builtin PONG game to try and be more
in the spirit of Thinking Forth:
[http://lukego.livejournal.com/10847.html](http://lukego.livejournal.com/10847.html)

------
jcr
" _Starting Forth_ " is recommended reading, and so is " _Thinking Forth_ "
which was posted a few days ago:

[https://news.ycombinator.com/item?id=9842557](https://news.ycombinator.com/item?id=9842557)

~~~
dmytrish
I tried reading "Thinking Forth", but never got why it is praised so much.
Looks like a bunch of war stories from 80s from veterans who discovered some
basics of encapsulation in need to handle Forth programs complexity.

------
avodonosov
And here is what Forth creator Chuck Moore does today:
[http://www.greenarraychips.com/](http://www.greenarraychips.com/)

~~~
NhanH
Asking the obvious question: What should I use that for? (The computer, and
Forth too)

~~~
dmpk2k
Its power consumption is ridiculously low; IIRC, at full utilization, it can
be powered by a solar panel the size of your hand.

------
rpcope1
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.

~~~
VieElm
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?

~~~
rpcope1
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...](http://stackoverflow.com/questions/24282153/comparison-of-common-lisp-
macros-and-forth-metaprogramming-capabilities)

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.

------
userbinator
Those who enjoy Forth may also like to try PostScript for a more graphical
experience.

~~~
protomyth
I liked programming in PostScript more than Forth because of all the
additional non-graphic things it had. Look at the Blue Book ("The PostScript®
Language Tutorial and Cookbook")
[http://partners.adobe.com/public/developer/ps/sdk/sample/ind...](http://partners.adobe.com/public/developer/ps/sdk/sample/index_psbooks.html)
for some examples.

~~~
arethuza
Many years ago I did a project with a lisp back-end, a front end in PostScript
(NeWS/HyperNeWS) and C code gluing the two together - it made me appreciate
than an interactive PostScript environment is surprisingly lisp-like.

Edit: This has made me wonder about a NeWS-like server sitting on top of
OpenGL and using an interactive PostScript like language.....

~~~
protomyth
I started my career with a Turbo C complier, a PostScript printer, and a
government database written in FoxBase. I learned a lot of PostScript
programming in order to generate the report we needed. I later got NeXTSTEP
3.3 which made interacting with PostScript a true joy.

I have often thought a NeWS-like server would be a fine replacement for a lot
of web stuff.

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

~~~
Animats
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.

~~~
minikomi
What has the industry moved onto now?

~~~
pjc50
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.

~~~
technomancy
My understanding is that the link between Arduino and Processing is solely in
the IDE. I don't think the two share any common ground beyond just the fact
that Java (which Processing is a very thin layer on top of) is similar to C
(which Arduino is a very thin layer on top of.)

~~~
Animats
Arduino's language is just GCC C++ with some extra Arduino-specific libraries
and some standard libraries missing.

I think there's now Rust for the Arduino Due, which is ARM-based.

------
j_m_b
Is there any resource for learning how to implement Forth? It would be really
cool to have a book that showed you how to determine your machine's
capabilities and gave example of how you could implement it from scratch
starting on Windows, Mac, Linux and onto other systems like Raspberry Pi, TI
calculators and than how it is implemented on more esoteric systems like
satellites.

~~~
Avshalom
it doesn't go into specifically exploiting your machine but the infamous Jones
Forth is ~1000 lines of assembly and ~a billion lines of comment explaining
the assembly and this gets you into a functioning Forth, then it starts
writing everything else in forth, including IF, WHILE, DO UNTIL... which shows
how you can use the parsing words to write new language features.

[https://rwmj.wordpress.com/2010/08/07/jonesforth-git-
reposit...](https://rwmj.wordpress.com/2010/08/07/jonesforth-git-repository/)

------
emersonrsantos
Jupiter Ace (a 8-bit microcomputer from the 80's) used its own dialect of
Forth instead of BASIC, and there's lots of files and documents at
[http://www.jupiter-ace.co.uk](http://www.jupiter-ace.co.uk)

------
llebttamton
There was a Forth debug/service terminal included in an electronic typewriter
/ typing tutor device from the 80's with an integrated CRT display. So an
educated guess is that its software was also written in Forth. It was made
between 1981 and 1987 and I think it was a golf ball-style printer, so if
anyone have an idea as to the make and model, that would be great.

~~~
peteri
I'm guessing you're thinking of the Canon Cat. There was also a plugin board
version for an Apple //e which went in the 80 column slot.

------
linuxlizard
Question for the Forth folks in this thread. Does Forth support loadable code
modules?

Here's the problem I'm trying to solve (still in the tinkering stage). I have
an embedded processor with small on-board SRAM but huge external address space
and a NAND flash. Can't add external RAM.
[http://www.atmel.com/tools/ATSAM4S-XPRO.aspx](http://www.atmel.com/tools/ATSAM4S-XPRO.aspx)

Would like to be able to run more code than can fit in the SRAM. With C, I was
looking at the old style overlays.
[https://en.wikipedia.org/wiki/Overlay_%28programming%29](https://en.wikipedia.org/wiki/Overlay_%28programming%29)

Also want to be able to support downloadable code modules.

Was looking into a Tcl dialect
[http://wiki.tcl.tk/1363](http://wiki.tcl.tk/1363) but I keep thinking Forth
would be perfect.

~~~
srean
Jim the minimal Tcl dialect that your link points to is a pretty interesting
animal, notable in its own right. I believe its one of the few Tcls to have
lambda and tail call elimination. Its author would be a familiar figure to HN
readers but perhaps associated with a different tool he wrote, redis. I for
one knew about Jim and knew about Redis but made the connection that they were
written by the same person much later.

~~~
linuxlizard
The Tcl might be less of a learning curve for myself and new employees. Forth
is quite different.

~~~
brudgers
Forth will might attract a different pool of candidates. That might be a good
thing if the idea of programming in Forth excites more people than programing
in TCL does. And my unsupported by data gut suggests that Forth is more likely
to excite people than TCL.

------
llebttamton
Trivia: the FreeBSD boot loader uses forth

------
pjc50
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.

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

[https://en.wikipedia.org/wiki/Jupiter_Ace](https://en.wikipedia.org/wiki/Jupiter_Ace)

~~~
gaius
I believe the Jupiter Ace was the only Forth-native home computer, tho' I have
it on a ROM for the Beeb.

------
Estragon
This book inspired me quite a bit as a teenager.

