Tuesday, February 10, 2009

Two Forth Resources

Last night I was poking around for Forth programming resources and found the following interesting:

  • OLPC's Forth Lessons. This is an interesting approach to learning about programming. It makes use of Open Firmware, which is included with the OLPC's hardware. The lessons not only teach some programming basics, but also talk about poking around the guts of the machine. If nothing else, it's an intriguing example of a DSL.
  • I wanted to play with a Forth on my Windows box, but wasn't sure what my best implementation was (suggestions anyone?). I ended up going with minforth which compiled under Cygwin fairly painlessly. All I need to change was:
    /* ---------------------------------------------------------------------------
       GCC for Linux
    */
    #elif defined(__GNUC__) && defined(linux)
    

    To:

    /* ---------------------------------------------------------------------------
       GCC for Linux
    */
    #elif defined(__GNUC__)
    

    I then followed the instructions for compiling the app and it worked just fine. As for what appealed to me about minforth: I like it's simplicity, yet it isn't too basic - as it provides command line history, native function access, and seem quite robust. And while it wasn't updated too recently (3/2007), considering how old Forth is, that's still what I would consider relatively fresh.

If you've never encountered Forth, it's definitely a mind bending experience. And one definitely one worth having.

5 comments:

  1. Check these out:

    The intro from:
    http://www.annexia.org/_file/jonesforth.s.txt

    and:
    http://hcsw.org/reading/forth.txt

    One of my friends says that Forth and Scheme are spiritually similar.

    ReplyDelete
  2. I love the jonesforth.s.txt implementation.

    Thanks for the pointer to http://hcsw.org/reading/forth.txt - I don't think I've seen that in the past.

    There's definitely a relationship between Scheme and Forth. Both can be said to have simultaneously no-syntax and extremely extensible syntax.

    Also, both Forth and Scheme tend to be not very useful to the production programmer in their out of the box state. It takes libraries and syntactical extensions to make these languages really sing. And of course, the programmer can enhance these libraries with their own extensions to make them even more customized to the task.

    The result is that Java with it's hundreds of classes makes R5RS and the typical Forth implementation look like a joke. But, once you've grown Scheme or Forth properly, the result is a language that seems custom built for your problem space.

    They're definitely both valuable languages to learn and appreciate.

    I have to admit though, some of the Forth philosophy I find to be utter nonsense. But, that's another post for another time...

    ReplyDelete
  3. Please go take a look at the Factor programming language. All the cool kids on Lambda the Ultimate officially endorse Factor as a cool language. It's closely related to Forth and even resembles it in many respects. Like Forth, it's a concatenative language. That means it's made by cats, unlike Java which is clearly a dog language.

    ReplyDelete
  4. I was trying to choose between Joy, Forth, and Factor for a first stack-based languague to learn.

    Luther, thanks for giving concatenative the treatment it deserves. Stack-based is perfectly fine.

    ReplyDelete
  5. Luther -

    That's one terrific sales pitch for Factor. I'm sold on checking it out.

    Thanks,
    Ben

    ReplyDelete