Hacker News new | past | comments | ask | show | jobs | submit login
Thinking Forth (1984) (sourceforge.net)
84 points by brudgers on July 7, 2015 | hide | past | favorite | 31 comments



Here's a PDF version that can open in your browser, for folks who don't relish opening unknown binaries from SourceForge:

http://www.dnd.utwente.nl/~tim/colorforth/Leo-Brodie/thinkin...


And if you want to build your own: https://github.com/forthy42/thinking-forth


This was one of the first programming books I read as a kid, after Brodie's "Starting Forth" and a bunch of not very memorable books about BASIC.

It remains the standard to which I hold all programming books I read. The author's enthusiasm and patient but never patronizing style drew me in, and the book's recognition that language and methodology are not inseparable changed how I viewed programming; the observation that design and implementation a dance rather than a handshake changed how I looked at software.

A classic worth reading even if you never intend to use Forth.


I am new to programming. So far I dabbled a bit in Scheme, Python, Smalltalk(Pharo). I quickly realized I don't care for Python, but Scheme is an awesome language(it's like doing Abstract Algebra a bit) and Smalltalk is an unbelievable environment. Now Forth also piqued my interest. How is it different from, say, Pharo? Apparently, one of Forth's selling points is related to "philosophy of problem solving". In that regard, how does Forth compare to Scheme? For example, it's trivial to solve certain problems by recursion in Scheme. Thanks.


Forth is by far the easiest to understand under the hood 'high level' language. It works by defining words from other words and uses a stack to do the bulk of its computation (words operate on the stack by consuming elements and leave their return value(s) on the stack). It's extremely elegant and powerful, I've used it for embedded stuff on very small cpu's (with only a few 100's of bytes of RAM).

Forth has some interesting quirks and has a very long history of success in various fields (space travel, radio astronomy, automotive).

The two books mentioned in this thread are a great intro (Starting Forth and Thinking Forth), for some more history have a look here:

http://www.colorforth.com/HOPL.html

One way to think about Forth is a language that is so extensible that the only way to write your program is to extend it with a DSL to solve your problem.



I don't remember when I first read jones forth, but it's been on my mind ever since. I love it. Thank you.


Thank you for writing jonesforth!


Thinking Forth is a FANTASTIC book -- by all means read it to learn the most important universal lessons from Forth, even if you're not going to program in it!

Forth is a "glass box" instead of a "black box", and it's simple enough that you can easily understand EVERYTHING about how it works right down to the most primitive words defined by machine instructions. It like scheme in that it's great for meta programming and creating higher level domain specific languages, but its approach is different enough and much lower level than Scheme that it's worth learning scheme as well as forth, to contrast them for a better perspective.

Another interesting related language is PostScript, which is a lot like Forth in some ways (rpn stack based, separate return and parameter (and dictionary scope) stacks, how the threaded interpreter works, and its extreme simplicity and power) but a lot like scheme in other ways (data is code, polymorphic arrays and dictionaries, typed object references instead of raw untyped pointers, with typed objects bound to names in dictionaries as opposed to typed variables holding values (you can redefine the same name to different types, since the object with its type is associated with the key in a dict, the type is not declared for the variable name itself like C), a safe high level language with bounds checking, garbage collection (in a modern implementation -- old printers tend to use simpler heaps), etc).

PostScript (and scheme) is a lot more of a "black box" than Forth is, since there's a lot of magic stuff going on under the hood that you can't see, to make it seem simple on the surface. And I'd say that on the surface, PostScript is simpler than Forth, because of how it's higher level and you don't have to worry about a lot of details. But Forth is actually extremely simple all the way down!

    \ First you should:
    FORTH ?KNOW IF
        HONK!
    ELSE
        FORTH LEARN!
    THEN

    \ Then you can:
    BEGIN
        FORTH THINK!
    AGAIN


You might be entertained by this minimalistic Forth compiler/vm written in PostScript: https://github.com/JohnEarnest/Four.Ps


Forth is a stack-based point-free[1] programming language where Scheme is a functional programming language. Both Forth and Lisp/Scheme offer functional composition. Forth is similar to Smalltalk in that they're both a live programming environment. You interact with and manipulate the running system.

[1] https://en.wikipedia.org/wiki/Tacit_programming


Forth is the 100% opposite approach to the same philosophy of scheme/lisp.

You write your program by creating a dsl.

They are both 'syntax-less' in scheme you have an AST in forth you have two stacks and a dictionary of words.

As many people say about Scheme it is highly enlightening to write yout own forth interpreter.


It's a bit more difficult to write a Scheme in Forth than the other way around, but how about a Logo?

https://github.com/JohnEarnest/Mako/tree/master/demos/Loko

I also wrote a browser based VM so you can give it a spin without compiling anything yourself:

http://johnearnest.github.io/Mako.js/?rom=Loko


Everything dmux said, adding the fact that Forth can be implemented by extremely simple and compact code, think of it as the smalltalk of the embedded world (For instance Apple bios - open firmware - give the user a Forth REPL)


That same Open Firmware Forth system [1], which was developed by Mitch Bradley [2], was not only in the PowerPC Mac bios, but it was originally used for the SparcStation boot roms, and eventually in the OLPC, and it was even an IEEE Standard 1275-1994!

[1] https://en.wikipedia.org/wiki/Open_Firmware

[2] https://en.wikipedia.org/wiki/Mitch_Bradley

In fact: the Open Firmware boot loader and plug-in card firmware interface technology, commonly used by both Sun and Apple, is the only firmware standard in existence to ♫ have its own theme song ♫ [3] !!!

[3] https://web.archive.org/web/20070204145613/http://playground...

    : OpenFirmwareSong ( 🎸- ♬ )
        \ By Mitch Bradley.
        \ Sung to the tune of "The Flintstones".
        𝄞
        ." Firmware" cr
        ." Open Firmware" cr
        ." It's the appropriate technology," cr
        ." Features" cr
        ." FCode booting" cr
        ." Hierarchical DevInfo tree." cr
        ." Hack Forth" cr
        ." Using Emacs on the keys," cr
        ." Save in" cr
        ." NVRAM if you please." cr
        𝄒 cr
        ." With your" cr
        ." Open Firmware" cr
        ." You can fix the bugs in no time" cr
        ." Bring the kernel up in no time" cr
        ." We'll have an FCode time!" cr
        𝄒 cr
        \ Thank you and good night!
        reboot
    ;


Open Firmware is an amazing piece of software. Mitch's Forth Lessons on the OLPC wiki are a great resource too, especially if you have an OLPC XO that you can boot to the firmware prompt. http://wiki.laptop.org/go/Forth_Lessons

OpenFirmware is one of the main inspirations for the design of Snabb Switch too. I was impressed that Mitch writes his own drivers faster than most people can integrate off-the-shelf ones. He sets a great example of getting more done by making a habit of self-sufficiency instead of accumulating ever more dependencies and keeping them up to date.


As a huge fan of Snabb Switch, I'd love to hear more about what inspired you in OF .. !


Oh thanks for the kind words :-)

Relevant blog entry: http://lukego.github.io/blog/2012/10/28/firmware-vs-software...

I worked with Mitch on "bringup" of the OLPC 1.5 hardware and got to see him doing amazing things. The best was when he needed to initialize the memory controller to make RAM available and so he flashed a small Forth system that could run strictly within cache and then connected to that with a serial port and poked the memory controller registers until he had the RAM working. Made an impression on me :-).


www.serialice.com expands on the idea with a stub that runs completely from registers.


Glorious, I never thought to dig OF history, there's more to it than meet the i.

ps: I did buy a Mac Mini with the idea that I could play with bare metal Forth.


Forth is as lispy as stack langs get. Though nowadays, Factor is the new Forth.


Excellent book as an introduction to Software Engineering. Also, Forth is a fun language/live-environment to play around with. When I first started using Forth (Gforth) the live-programming matched with point-free programming is left with me the unshakable impression that 'this is what programming should be like.'


One of the best programming books I've read.


Beautiful. I wish I had the first 30 pages of this book during my SE 101 days.

A direct link to the PDF might have been better though. I almost skipped this when I saw the Sourceforge URL.


I was amused to see that uBlock Origin's default filter lists now include sourceforge and thus I was momentarily stopped from seeing it.

https://github.com/gorhill/uBlock/wiki/Badware-risks


It came across my radar via Michael Fogus's Six Works of Computer Science-Fiction[0]. After reading the first chapter, the reasons that people love/loved Forth suddenly make sense. Like Lisp it's full stack - from close to the metal to arcane abstractions.

[0]: But only after the second time it was posted to HN. http://blog.fogus.me/2015/04/27/six-works-of-computer-scienc...


I read this book a few years back, it's quite good even if you never do actual Forth programming, at least to skim.


You guys know that PDFs can load web assets right? They can de-anonymize you just by opening them right?

Don't trust it if you don't trust the host.


You guys know that PDF readers can turn off loading of web assets right? That you should turn it off or prompt or people can de-anonymize you just by getting you to open a PDF right?

Don't trust it if you don't trust the host, regardless. Exploits do exist.


As ignorant/oblivious as HN users are, (see your post for reference) it needed to be mentioned.


Sources are available here: https://github.com/forthy42/thinking-forth




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: