Forth compiler?

Jeff Fox Fox at UltraTechnology.com
Sun Apr 30 23:47:58 EST 2000


We have advice here from a couple of people who
dropped out of using Forth twenty years ago. Their
opinions are based on comparing twenty year old
Forths (the last they remember) to the C that they
use today.

To be fair one should compare today's commerical
Forths to today's commercial C or today's public
domain Forths to today's C.

Harry H Conover wrote:
> 
> Paul Victor Birke (nonlinear at home.com) wrote:
> : Dear Jeff
> :
> : Was there every a higher level language like BASIC that could be
> : compiled into FORTH code?
> 
> Learn C Language programming, it's much more intuitive to program in
> than was FORTH, 

C is more mainstream.  What is intuitive to you will depend on
your background and how it is presented to you.

> and with today's optimized compilers produces much more
> efficient code than does FORTH.

Today's optimizing Forth compilers are compeditive with today's
optimizing C compilers.  However many people base their opinions
on what they saw twenty years ago without realizing that native
code optimization has been in widespread use in Forth for at
least a decade.

> : In other works you could write in non forth terminology yet get the
> : speed and compactness.
> 
> You can get the same benefits using C, only better.  

Except of course where we are talking about an environment or
application that includes the compiler.  A C compiler can never
compete with Forth in that way.

> FORTH pushed and
> poped everything onto and from the stack, which in its day was kind of
> novel but today, largely due to it's total lack of type checking, its
> inability to be useful in anything but minimal code implementations,
> and the horror of trying to maintain and expand an application written
> in FORTH, FORTH is now an anachronism.  Fortunately, today only a
> few legacy FORTH applications are in common use, and those mostly in
> Radio Astronomy.

Wow, many myths strung together.  Yes, Forth is based on a stack.
The stack can be optimized by hardware and software mostly into
registers. Forth is not a typed language but this has never
been a problem for the many NASA space missions or industrial
applications running Forth.

Where Forth has been used professional there are no unusual 
problems with maintenance or expansion.  There are in fact 
some very impressive stories.  However I can well imagine the
horror that a C programmer who doesn't know Forth might feel
at being told that he was going to have to be a Forth maintenance
programmer instead of working in C. ;-)

Today Forth is still in widespread use in places like NASA, SUN, IBM,
Motorola, ...  Forth is widely used in embedded programming, robotics,
and real time programming.  However much of the press it gets comes 
from people who played with it a little twenty years ago and 
continue to tell people what they know about Forth.
 
> With today's compilers, anything you could do in FORTH you can do in
> C better, and much safer.

This is simply not true.  Today's optimizing Forth compilers
do about the same as today's optimizing C compilers do.  There
are also some versions of Forth that are smaller and simpler than
any C compiler.  

> : I left Forth in the early 1980s when I got my first 
> Ohio Scientific PC
> : in 1979 with Interpretive BASIC from Bill Gates BTW!
> 
> Most of us abandoned FORTH when we obtained our first C 
> compiler. Since
> that time I know of no one who has ever returned to FORTH.
> 
>                                                      Harry C.

You dropped out from Forth near the beginning.  Things have
changed a lot in Forth, just like in C in the last twenty 
years.

There are many people who have used both C and Forth together
and still do.  They can be mixed in different ways.  All SUN
machines boot in Forth before going into the C and Unix 
environment.  They have been doing this for a long time
because it makes a lot of sense.    If you don't believe
me ask the people who write the Forth compilers used at
SUN and Moto.

Many more projects are done in Forth than most people realize,
but most people have only heard about 20 year old Forths.  
There are many impressive stories about Forth and C battling
over some big historic commercial projects.

Jeff Fox




More information about the Neur-sci mailing list