Usenet January 2, 2003 Exit

comp.lang.forth.mac:

Newsgroups: comp.lang.forth.mac
From: Doug Hoffman <dhoffman@oakland-MUNGEDinfo.com>
Message-ID: <B88B2E8A5A028A61@v90-00-207-241-138-97.sag.michix.net>
Date: Sun, 10 Feb 2002 00:49:36 GMT

Most Forth programmers I've encountered are not zealots and appreciate other programming languages as well and are also aware of the weaknesses of Forth. But we all generally like Forth quite a bit (or else we wouldn't be visiting this newsgroup very often!).

I would also say that you should try Forth and C and whatever other language you might think you'd like. Learning a programming language can be a large investment of time and energy, hence you want to be reasonably sure of your direction before you get too far. Yes, that is why you are here asking questions...

Forth offers:
1) Fast interactive development (fast edit/compile/test).
2) The compiler does not require type declarations, hence the compiler does not get in your way. 3) Easy parameter passing between functions/procedures.
4) Forth is both a high level *and* a low level language.
How you use it is up to you.
5) The compiler can be extended, although this may not be that important to you.

Forth offers an extremely interactive and fast edit/compile/test sequence.
Forth is both an interpreter and compiler. So you can execute the smallest portion of code using the interpreter and verify that it works. This is very much like your HP calculator. On the HP, you can see all of the intermediate results of the calculation as you go. Mistakes become obvious. With algebraic notation you must use parentheses, sometimes nested several levels deep, and then hope the right answer is achieved when you finally hit "=".

I presume you use the HP calculator at least partly because of the more natural (to some, including me) stack for manipulating numbers. Then you would like Forth for the same reason.

You ask: "Or are we rotating and rolling for the exercise?"
No more or less than when you manipulate the stack on your HP calculator. Actually, depending upon the particular Forth, I would say less. Dup and swap are more common than rotate and roll, and are simply used to postion things on the stack in the correct order as needed by the function at hand.

Let me dispel some common misconceptions about Forth.
I think most of these misconceptions have their roots in the very early Forth implementations, say back in the 1980s. In other words at one time they may have been true but are no longer true of many (most?) modern Forths. I will use Mike Hore's Mops as an excellent example of a modern Forth.

Misconception #1:
"Forth uses these wierd blocks files for source code and editing."
No. Modern Forths use plain text files and usually have a standard GUI multi file text editor to go with. Many of these editors are closely integrated with the Forth development environment. Automatic source lookup and other browsing tools are offerred.

Misconception #2:
"Programming (in Forth) essentially consists of keeping track of where you are on the stack; since the stack can be many thousands of variables deep this can get complicated"
No. I suppose you could try that but even if it worked no one uses the Forth stack that deeply. Incredibly, the quotation above is directly from Carey Lu's book, "The Apple Macintosh Book".

Misconception #3:
"Forth requires the use of all of these wierd stack gyrations that are hard to follow."
No. Modern Forths like Mops easily allow for named input variables so stack gymnastics are a non-issue. Excessive stack manipulation is discouraged by leading Forth experts.

Misconception #4:
"Forth does not support floating point. One must use all integers and resort to strange scaling schemes for non-integer arithmetic."
No. Modern Forths fully support floating point.

Misconception #5: "Forth code is unreadable."
Well, I've seen unreadable Forth, and I've seen unreadable C. Making the code readable is up to the programmer. One might view this as a weakness of Forth. It *allows* you to write unintelligible code, but that doesn't mean you must. It is the freedom of compiler constraints that allow the programmer to write very eloquent, readable code or the unreadable. The two-edged sword. One of Forth's weaknesses *and* strengths.

I should add that Mops also provides very complete support of OOP including multiple inheritance and a large built-in class library. Mops generates very fast code due to its built-in compiler optimiser. The support is excellent.
The price is quite reasonable. It's free.

 


Up arrow
 
http://PowerMops.html/Usenet.html