FORTH, PASCAL, and C--- which one would you choose (it depends ?)

Tom Almy toma at tekchips.UUCP
Fri Jan 3 03:15:48 AEST 1986


In article <1191 at princeton.UUCP> wei at princeton.UUCP (P Wei) writes:
>I compared the Eratosthenes sieve benchmark for Lattice C, Microsoft C,
>TURBO Pascal and HS/Forth for IBMPC. For 10 iterations, the execution looks
>like :
[ various timings ]
>
>Now, the question is :
>It seems that Forth is as extensible and structured as C and Pascal (to my
>understanding), and generates more compact and faster execution program.
>Its interpreter being far more faster than BASIC's makes developement time of a
>project much less than when using 'edit-compile-link-test' type of language.
>I wonder why Forth is still less popular (to my impression) than C and Pascal.

Well ignorance (and I mean to offend nobody by this) is a problem.  Most 
programmers don't KNOW Forth, and so cannot judge it.  "C" is popular amoung
UNIX users, because you just about have to use C under UNIX  (I have had no
good experiences with it in NON-UNIX systems).  PASCAL is taught in schools
so it has a guarenteed user community -- its rigidity is favored by academic
types.  I used it for programs heavily into data structures, but only for
those that PASCAL supports.  There are millions of potential Microsoft BASIC
users, since it is built into almost everyone's personal computer.  I use
Microsoft BASIC when I want to manipulate strings.

On the other hand, FORTH takes effort -- you have to go out of your way to
obtain it, and you have to learn it on your own.

>Is it because :
>--its somewhat 'awkward' syntax ? (Pascal is closer to human language)
Pascal closer to human language? GAG!  If you want to program in human
language use COBOL :-).  Actually Forth has simpler syntax rules than any
other language I know except for un-adulterated LISP;  I can explain the
syntax rules of Forth much faster than I could appologise for the semicolon
rules in PASCAL!

>--its lack of predefined data structure ?
This is certainly a disadvantage to learning Forth, but the ability to create
any data structure you want and placing them anywhere you please
(like an array on a remote system accessed via modem), hiding the access 
method like in Smalltalk, is very powerful indeed.
>--its putting great responsibilty on the programmer ? (the kernel is so compact
>  and simple that you must first extend the system and create many things which
>  in C and Pascal are taken care of by the compiler-writer.) In this sense,
>  if I compare the simplicity and primitiveness I get:
>  Assembly > Forth > C > Pascal (where > means simpler than).
But the extensibility of Forth allows making it "less simple" as applications
require. If you MUST have infix expressions, you can have them; if you want 
bounds checking on arrays, or or traps on arithmetic overflow, you can have
that too (and be just as invisible to the programmer as in PASCAL).
>  We know power comes from simplicity, however we must pay price for it.
>
[...]
>For Forth-lovers, do you think Forth is suitable for being used as a
>general purpose language instead of the one 'exclusively' designed
>for use in the lab and industry to control the machine...
Yes, in fact I have seen accounting packages in Forth, and scientific
programs in Forth.  In the past year I have been rewriting many of my
favorite CP/M and MSDOS utilities (mostly filter like programs) in Forth
using the Forth compiler I have written, getting typically 2-4x speedups
(4x for AZTEC CP/M programs that used "stdio"), and 75% code size reductions.
I have implemented a multi-tasking multi-user Forth in CP/M (three users and
a printer spooler on a Z-80!).  I also have written an IC layout program
in Forth.  I have used it in "traditional" Forth environments as well.

>Note: I am not a dedicated C, Pascal or Forth programmer.
>HP Wei   (wei at princeton)


At different points in time, I used almost exclusively all of these,
as well as Fortran, BCPL, LISP and APL.  Now I am using Forth almost 
exclusively.

Tom Almy

(Usual disclaimer, but you can flame directly at me if you want.  Why
wear out /dev/null?).



More information about the Comp.lang.c mailing list