http://www.phact.org/e/forth.htm
FORTH A PROGRAMMING LANGUAGE
FOR REAL PROGRAMERS
Links to great FORTH SITES:
Excellent article on FORTH in Electronic Design - November 22, 1999 Volume 47, Number 24
Forth Incorporated -they created the language and offer the most support
good overview on Forth
Forth Interest Group Home Page
THE JOURNAL OF FORTH APPLICATION AND RESEARCH
Commercial Forth Sites
The Forth Scientific Library Project
free sources of forth
other Forth resources
see Napier's and my article on Forth in Circuit Cellar Magazine
ESP - August '98 - Programmer's Toolbox -column on Forth by Jack Crenshaw
Forth links JForth home page ! Forth programs Forth for Mindstorms real time Forth
This page is found at: http://www.phact.org/e/forth.htm
note: Some of this is a paraphrased version of stuff where the copyright willbelong to Circuit Cellar Magazine. Consider
getting your own subscription for under 22$ !
This Forth Programming Webring site owned by Eric Krieg.
[ Previous 5 Sites | Previous | Next | Next 5 Sites | Random Site | List Sites ]
NOTICE: WebRing collects personal information on this page when you submit your site for inclusion in this Ring. To learn more about how we use your personal information click here. This information is shared with the RingMaster for this WebRing as described in the WebRing Privacy Notice. Any other information collected on this Ring's homepage is the responsibility of the RingMaster and is not subject to the WebRing Privacy Notice. By submitting your site you represent that you are 13 years of age or older and that you agree to WebRing's Terms of Service. To join this Ring click here.
-Eric's intro to Forth:
At this point, I presume the reader is too creative and free thinking
to knee-jerk succumb to the group think, "because a massive
company is pushing it, I must follow like a proverbial
lemming"
Sure, all languages allow you to think in a higher level and
be spared the slower development of assembler. Both can support
developing and simulating code on a PC. Any language will
support modular design, commenting and other good programming
practices. And Forth usually comes with simple tools to
explore call stacks, set breakpoints, trace execution. All
languages have syntax quirks and need programmer responsibility
to adhere to voluntary indenting standards. In C, higher level
functions keep calling lower indenting standards. In C, higher level
functions keep calling lower level functions - in Forth, later
defined words call lower level words. Forth insists on
a logical order of compile to eliminate need for C prototypes.
All the standard program control of C (do,if, else, while, switch,
etc.) are in there with just different names and syntax. The
important logical and mathematical operators are all there,
but transcendentals and advanced math are available
extensions. Unlike C, there is no goto - but good programmers
shouldn't need them. Conditional compilation, arrays and
unions are all supported with a unique Forth flair.
Forth data types supported are strings, bytes,
2 byte values, and 4 byte values. It's up to you to make
responsible use of address pointers, signed vs unsigned
or other matching constraints. Many versions come with advanced
data types. - But you can at least add support for your own
data types better than any language I've seen. Converts to forth
will be relieved to dispense with those cursed { }
all through code. Also, the ; still serves as a terminator.
the advantages of forth are as follows:
The whole development environment is far more simple: there
is no "development suite" with bunches of CD'
a forth development system can reside on a 330K floppy. You also
have a single tool set as compared with one compiler vendor, an
OS vendor, a debugger and maybe a target monitor program. Forth
gives you them all with one set of rules and one look-feel.
The object code can easily fit in 8K on most architectures. A major
up side is that you often can get all the source code for your
whole development environment. Forth is most easily
written in Forth - I used to follow all screens of code to generate
a new copy of Forth. Try telling a C or Ada vendor
that you want to upgrade the language and knock out a few
quirks.
Target systems can include the compiler. In my present C contracting
job, I use a overpriced Sun to run Make, compiles and link a target
executable. Then I go to a target machine and download the code, powerup
and test my code. If I want to make an adjustment to the code I take an
hour to go through the whole loop again. If I had Forth, I could type
in a new word (analogous to C function) right into the serial port of the
target push parameters on the stack and call it to see if it works. I
could then easily "splice" the new word to intercept any calls to the
old word. As a demonstration, I used to take a deep breath and do
all this on a Forth machine before taking another.
Compiler extensibility means you can track what ever new
coding fad that comes along with out switching languages. Forth
has really always been object oriented, JAVA-like, platform
independent, etc. from the get go. Adding data structures or
operator overloading is easy.
Shifting into assembly language is no problem and
and all data structures are accessible from assembler.
Target testing is intuitive. Exactly the same
commands you use in code are the same ones you
use for debugging. My present environment has a
whole different tool kit with a different look-feel.
Parametersfor words (Forth functions) can just be typed in as
numbers to be placed on the stack and then taken
by a word that you just type in to execute. To do
the same thing in C requires advanced knowledge and
lots of key pressing to dominate a debugger. In
C you may learn one companies make system, another's
C compiler and another debugger. In forth, you just
use the natural existing commands which are pretty
common to all versions.
Forget hunting for an OS (for easy apps) Forth likes to BE
the OS. It can't do preemptive multi-tasking and inherited priority -
but if you are into the design frugality endemic to Forth - you may
find bright ways to avoid such complexities and all their unexpected
side effects. It has a multi-User multitasker and it's simplicity makes
any kind of operation time determinate (as compared with the unknown
time typical OS's can spend defragmenting memory). You call the
word pause to allow other tasks to run - how much you sprinkle this
in affects priority (but at least you don't have the class of statistically
related bugs from unanticipated preemptive context switches. Forth doesn't
directly support some stuff I hate to put in real time apps: like
dynamic memory allocation: - you can code your own. I admit that
huge very complex real time applications
will quickly miss Forth's lack of semaphores, task priority,
resource management and messaging. Such things would not be
hard to implement in Forth.
I admit that Forth would be a little slower and slightly
more code in large programs than with newer C compilers. But a hello
world program would likely use less code in Forth than C - there are
no massive libraries to be linked in. Programs are generally faster in Forth
where programmers stay with the natural philosophy of using fixed
point notation. If you are the consummate engineer, you probably
have used old HP calculators and are mentally conformable with
a FIFO stack. Beginner C programmers delight in being spared
from having to visualize how data is stored and passed. Advanced
C people learn to think ahead how the stack is used by the compiler.
Forth programmers think in terms of stacks just as the computer does.
I admit that C does a much better job of hiding the complexities of
going from a 16 bit to 32 bit architecture. Running Forth in
true 32 bit mode does become slightly wasteful of space - but still
orders of magnitude more parsimonious than executing the most basic
function on a "Gates-infected OS".
Forth suffers from the self fulfilling (and sustaining) prophecy of
"golly, I don't want to use it because other people don't" that's the curse of
any upstart idea: there aren't many people who know it - and
people won't usually bother learning something unless everyone
else is already using it.
Forth in it's more simple versions is a little more Republican then
Democrat - it expects you to be responsible for yourself. You won't
see a whole book chapter dedicated to compiler error codes.
The language isn't designed around protecting the program from
an inept programmer.
Forth is called a programmer amplifier - a dubious programmer will
produce the kind of horrendous code that gave too many managers
a bad taste for the language; BUT a good programmer will reap
tremendous benefits.
Moving between any other language and C is much more natural
than between C and Forth. C merely continued with the mindset
lineage of mainstream status quo languages. Programmers seem
to be "programmed" to accept infix notation. The biggest
differences between Forth and C are rigidity of type
enforcement. The forth compiler considers numbers to be
just numbers to be manipulated - if you take the result
of a mathematical computation and use it for a pointer
to memory, Forth will not complain. In the world of C,
you are more protected - but then you also have to do
things like type casting to circumvent a patronizing compiler
that acts like your mother. A advantage of C is that it
supports structures from the get go. Newer versions of Forth
in an effort to provide C-like OS calls have acquiesced.
Unlike C, you have the power to easily extend Forth to support
any kind of structures you want - but then you would unfortunately
not have a universal standard. There are however many public
domain or sold proposed extensions to Forth. The most simple
versions of Forth do not support floating point. "Real Programmers"
can remember virtual decimal place position and then reap more
performance.
this page is available at:
http://www.phact.org/e/forth.htm
Are young C programmers losers?
Many of them have no idea of things like:
* writing disk primitives
* compiler theory
* how to represent real numbers with straight integers
* how to make a program go fast
* how to write their own OS
* how to store in their own interrupt vectors
* how to use a logic analyzer
* how to hack programmer in assembler
* saving disk space rather than wasting it
* counting up instruction cycles
* making your own tools
See, "now-a-days" kids coming out of school are spoiled with
lots of code space, run time speed and disk space to just waste.
Their "computational forefathers" built our own computers,
wrote our own monitor programs (often hand assembled) and
debugged everything. Even when we stole code, it took skill
and intelligence. There were fewer people into it because fewer
people could think in binary. In those days, we'd wire up a few
ttl logic chips and LED's to make a crude logic analyzer or convert
and old TV to a scope and debug stuff. We didn't have this wimpy
drag and drop interfaces where you don't even need to know
command line arguments. Wimps! Now compilers are so
dumbed down that you don't really need to think and debuggers
use enough cute icon keys where you almost don't need to read. I
envision Forest Gump pitching the next new programming paradigm.
The smart programmers don't seem to even want to write code.
They either live in a world flowing with new paradigms, models
and theory or they #$%&-ing sell out and become managers. In the
project I'm currently on - most routines have a history list starting
in 1993 and wasting a page. I just noticed a perfectly written routine
written in 1990, and I thought wow, how did that guy write it and have
it not need any changes since. Then I noticed the name was the
big fat ugly manager of our dept. He was able to code well, so they
promoted him to be a manager (maybe he got a lobotomy along the
way, I don't know). It's funny when two of us older guys meet -
we have inverse one-up-manship contests. "Oh, you may not
remember this, but we used to use the old XYZ 1k memory board"
- "oh, you guys were lucky - we had to get by using . . . - we
assembled them our selves"
I think Bill Gates has a vision of these palm tops being marketed
to the village idiot. Laugh at me if you will but just as America
no longer makes TV's - we are losing skills like how to write
disk primitives, video drivers, memory test code or monitor
programs. Maybe just as there are mechanically anachronistic
people with support groups for keeping antique cars and trains
alive, there will be people someday trading versions of pong
for TRS-80's. Half the stuff people use computers for are mind
numbing anyhow. As a final thought I ask you:
have we all bought so much into paradigms, entity relationships, etc that
we have lost our roots? No matter how sophisticated computers get -
they are built on a foundation of the same simple logical operations that
we cut our teeth on years ago. Ever wonder why old computing curmudgeons
like Jack Crenshaw spontaneous break into sentimental rants about "I worked
on stuff so old that . . ."? Well, it's that we "embedded" programmers must
keep the skills to thrive (please don't say bottom feed) - on that layer
of code close up to the HW. If we can't think in hex, maybe we should just
drift into the database end of the computer employment landscape."
Additional notes:
from Forth Inc., we hear they've expanded their line of SwiftX Windows hosted cross compilers to include the 6303, 6809, 68HC11, 68HC12, most 68K variants (68000 & CPU32 cores), UTMC69R000 (rad hardened RISC processor), 8051, 8086, Atmel AVR family, ColdFire, H8/300H, i386, and Patriot PSC1000. Leon has been working on a Linux cross-compiler host since many engineers are heading in that direction as a more stable networked development environment.
FastCounter by LinkExchange
A few notes by Beth Rather – one of the original gurus of the language:
The Forth Interest Group is no longer operational at the address given, or able to publish Forth Dimensions or sell
books. The web site is still being maintained, however.
As you note, Starting Forth is dated, and no longer available. But we offer two books on contemporary Forth, the "Forth Programmer's Handbook" (a reference book) and "Forth Application Techniques" (an introductory tutorial with problem sets). Both are available from our web site or (with a service charge) Amazon.
Cheers,
Elizabeth
>
==================================================
Elizabeth D. Rather (US & Canada) 800-55-FORTH
FORTH Inc. +1 310-491-3356
5155 W. Rosecrans Ave. #1018 Fax: +1 310-978-9454
Hawthorne, CA 90250
http://www.forth.com
>
>
go to more of Eric Kriegs wacky rants Eric's skeptic pages or info on the ITEC International Tesla Electric Company UCSA BWT program to distribute free energy
.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment