Small languages (was Re: Lua, Lunatic and Python

Julian V. Noble jvn at nowhere.virginia.edu
Thu Dec 18 13:42:12 EST 2003


Charles Steinkuehler wrote:
> 
> Paul Rubin wrote:
> > Charles Steinkuehler <charles at steinkuehler.net> writes:
> >> Which is why I think that a small Forth kernel talking directly to the
> >> linux kernel is the best solution.
> >
> > Forth is such a contorted language though, it's best to avoid it
> > unless you're desperate.
> 
> Forth as a language is not at all contorted.  Programming in Forth is
> essentially creating a custom language to solve the problem at hand, so
> Forth is simply reflecting the structure (or lack thereof) of the mind
> of the programmer solving the problem.
> 
> Forth code can be as elegent or as twisted as you desire to make it.  In
> this regard, Forth is far more unrestricted than even C, allowing just
> about any form of nonsensical code.  While I generally like highly
							      ^^^^^^
> structured languages with strong typechecking and other features to keep
  ^^^^^^^^^^

> the programmer out of trouble (ada, pascal, etc), the small size and
> potent abilities of Forth make it highly suitable for specific problem
> domains, especially if there are any resource constraints to deal with.


I agree with some of that, but fear you may have left a wrong impression
with some of the people who peruse this group. 

The "structured" aspect of structured languages has nothing to do
with type-checking and/or enforcement "to keep the programmer out
of trouble". It has to do with _structure_, namely modularity, in-
formation hiding, appropriate control structures, and avoiding
multiple entry points to subroutines. As well as the obnoxious
and dangerous GO TO.

>From this point of view, Forth is as well-structured as any language
around: 

   Everything is either a numeric literal or a subroutine.

   Subroutines have only one entry point.

   There are no GO TO's.

   You can hide information through a multiplicity of mechanisms---
   simple CONSTANTs (that cannot be altered once defined), separate
   wordlists to avoid name-space collisions, embedding "magic"
   numbers as literals within the words that use them, etc.

   Forth lends itself to factoring and modularity better than any other
   language I know (including Modula 2 !) as well as to finer-grained
   decomposition by virtue of its direct use of the stack for argument-
   passing.

   CORE Forth has no typing or safety mechanisms to protect the incom-
   petent, but anything desired along those lines is easily added by
   virtue of Forth's extensibility (and I often do so when I debug
   something tricky, just to eliminate the more obvious mistakes).

Whaddya want, egg in your beer?

-- 
Julian V. Noble
Professor Emeritus of Physics
jvn at lessspamformother.virginia.edu
    ^^^^^^^^^^^^^^^^^^
http://galileo.phys.virginia.edu/~jvn/

   "Science knows only one commandment: contribute to science."
   -- Bertolt Brecht, "Galileo".




More information about the Python-list mailing list