Wednesday, July 2, 2008

Am I missing something about Forth?

As part of my "educate myself about FPGAs" curriculum, I've noticed Forth turning up in a lot of Google hits. Forth has always been on my long-standing list of languages I wanted to learn. I remember spending my last bit of hard-earned cash in the early 70s to buy an HP-35 programmable calculator. It got me through my final Electrical Circuit Theory exam so was worth the hundreds of dollars it cost me. It had just arrived here in Oz and the examiners didn't have time to change the rules about pocket-size programmable calculators (they didn't exist before the HP-35).

The HP-35 was a Reverse-Polish stack machine. I loved it. Stack machines seemed so obvious I couldn't understand why they never took off.

So when Forth came out I was intrigued to try it but never found a way to do so. There was no Internet then so one couldn't just download a copy and try it out. I saw Forth mentioned in lots of places by people I respected. There was even a microcontroller project (Elektor again?) with Forth being the built-in interpreter rather than BASIC.

So I downloaded gForth and worked my way through the included tutorial. OK, I can print "Hello world" and add some numbers. I also started reading Thinking Forth.

But what makes Forth so interesting to so many obviously intelligent people? Found a 1-hour movie where a skilled Forth developer writes some code. It left me quite cold. It seemed to take ages to write the simplest things. And in the end it looked so much like a recursive decent parser I kept asking myself why didn't he just use one to begin with. OK so that wasn't the point. He was showing people how he thinks in Forth and he succeeds really well in that and deserves praise for that.

But I couldn't see any advantage in using Forth for that particular task and it actually seemed really slow and tedious to use Forth compared to, say, Perl and RecDescent. Part of my task as a Perl programmer when I am about to write new code is to check CPAN for modules which already do what I need. "The best programmers don't" as they say. So there's no doubt a different mind-set between Forth programmers who appear to want to write everything themselves "because it's so easy" and say, Perl programmers, who tend to just re-use existing code from CPAN and rarely write code themselves at all.

Something to ponder a bit further.

1 comment:

Blogger said...

If you need your ex-girlfriend or ex-boyfriend to come crawling back to you on their knees (even if they're dating somebody else now) you have to watch this video
right away...

(VIDEO) Text Your Ex Back?