[comp.lang.forth] Forth for VAX, Sun

web@garnet.berkeley.edu (William Baxter) (05/06/89)

To my inquiry about Forth systems for the VAX and Sun, I received two
responses, both mentioning the same programs.  

C Forth 83: 

Runs on both VAX (VMS or Unix) and Sun, and in fact on just about every
computer with a half decent C compiler.  The price is $50, which gets
you C kernel source, Forth utilities source, on-line documentation, and
a printed glossary.  It's a Forth-83 dialect with 32-bit stacks, real
files, and several utilities.

Sun Forth:

Runs on any Sun 2, Sun 3, or Sun 4, and also on most non-Sun 680x0 Unix
machines.  The price is $200, which gets you the binary, source code,
metacompiler, 200+ page printed manual, and a ton of utilities (for
instance, it can load C object files into the Forth dictionary and
execute the C subroutines as Forth words.  It also has a disassembler
and both high level and assembly language debugging tools.)


Both are available from:

Mitch Bradley
Bradley Forthware
P.O. Box 4444
Mountain View, CA 94040

----
Disclaimer:  Endorsement?  I haven't even used them.

William Baxter

ARPA: web@{garnet,brahms,math}.Berkeley.EDU   
UUCP: {sun,dual,decwrl,decvax,hplabs,...}!ucbvax!garnet!web

don@brillig.umd.edu (Don Hopkins) (05/10/89)

In article <24085@agate.BERKELEY.EDU> web@garnet.berkeley.edu (William Baxter) writes:
>To my inquiry about Forth systems for the VAX and Sun, I received two
>responses, both mentioning the same programs.  
>
>C Forth 83: 
>
>Runs on both VAX (VMS or Unix) and Sun, and in fact on just about every
>computer with a half decent C compiler.  The price is $50, which gets
>you C kernel source, Forth utilities source, on-line documentation, and
>a printed glossary.  It's a Forth-83 dialect with 32-bit stacks, real
>files, and several utilities.

I used a version of CForth when I was working for Mitch, summer before
last at Sun. It's a very nice Forth system, and quite portable. You
can define your own Forth primatives in C, by adding them to this big
switch statement! We linked CForth together with a schematics CAD
system (CADroid), so you could call the CADroid commands from Forth,
and then we wrote a user-friendly extension language in Forth. It
accepted postfix commands, and prompted for arguments in English. You
could interactivly define macros for laying out circuit bodies and
wiring them up, by typing commands, pointing with the mouse, selecting
from menus, pressing function keys, putting in your own prompts for
arguments, bindings macros to keys, etc. It also supported interactive
loops and conditionals. Mitch came up with a really neat unified
syntax for them:

condition? [ <stuff to do if true> ]

condition? [ <stuff to do if true> ][ <stuff to do if false> ]

count [ <stuff to do in a loop> ]

count [ <stuff to do in a loop> ][ <stuff to do if count is 0> ]

The last one (the loop-with-an-else-clause) was particularly useful
because it could be used instead of the otherwise common construct:
	
count 0= [ 
  <stuff to do if count is 0> 
][ 
  count [ <stuff to do in a loop if count isn't 0> ] 
]

The way these constructs worked interactivly (and during macro
definition) was that you started a loop by typing a count and a [, and
it would execute commands as you typed them in, the first time through
the loop, and once you typed the matching ] (they nested!), it would
re-execute the now-compiled loop count-1 more times, real fast.  The
conditional form had just the same behavior: It would either execute
what you typed as you typed it, or ignore your commands, according to
the condition (|-1| or 0).

So when we carefully consider all of these facts, we are forced
to ask ourselves the following question:  What was today's topic
again? Wait, I remember:  Bradley Forthware.

>
>Sun Forth:
>
>Runs on any Sun 2, Sun 3, or Sun 4, and also on most non-Sun 680x0 Unix
>machines.  The price is $200, which gets you the binary, source code,
>metacompiler, 200+ page printed manual, and a ton of utilities (for
>instance, it can load C object files into the Forth dictionary and
>execute the C subroutines as Forth words.  It also has a disassembler
>and both high level and assembly language debugging tools.)
>
>

Sun Forth is an excellent, rich, fast, fantastic Forth system! I've
used it for all kinds of things, on the Sun-2, the Sun-3 (68K), and
the Sun-4 (SPARC). It also runs on the Atari ST, and the Mac, I think.
(I haven't used those versions) On the Sun-2, I had a good time using
Sun Forth to figure out how to frob the CG1 color graphics card, by
printing out the cg1reg.h file, mmap'ing in the device registers, and
frobbing around with them. (I finally discovered that you could only
write to the color table during vertical retrace, when I got mad and
frustrated that my unsucessful attempts at loading the color table
were taunting me by kinda sorta working occasionaly, and I decided to
punish it by running it in an infinite loop. My color table slowly
faded into view!)

It's got a kick-ass decompiler, that pretty prints forth code and
disassembles primatives! Who needs manuals or source code? (But you
get them anyway! ;-) There are a lot of other nice features, like an
emacs-like command line editor, with history, and command completion
over your Forth vocabularies. It's very well interfaced with Unix. It
also runs stand-alone without Unix. Mitch uses it in the hardware lab
at Sun to debug decadent wayward hardware, by dropping in a Forth ROM,
talking to it through a serial port, and running it in the framebuffer
memory! [It looks real neat munching away on the screen, and it can
work even when the main memory is fried!] The list of features goes on
and on...

The ability to dynamicly load in C object files makes Sun Forth useful
for a whole lot of things you'd normally never think of (or at least
admit to thinking of) using Forth for! On the Sun-3, I linked in a
version of the X10 "uwm" window manager I had modified to do pie
menus. I could call all the window manager functions from Forth,
passing them arguments on the stack, and I could bind mouse actions
and menu selections to Forth functions. I moved the main control loop
that dispatched events into Forth, so I had a crack at the events
before passing them on to uwm. Forth could could respond to window
system events, track the mouse, pop up menus, change the cursor, move
windows around, etc... It had complete access to all the window
manager function and data structures. One thing I used this system for
was to implement an experiment that Jack Callahan designed, comparing
pie menus with linear menus. (A paper describing the experiment is in
the CHI'88 conference proceedings.) The Forthified window manager
administered the experiment by randomizing the order in which the
menus were presented, prompting the test subject to select a certain
item from each menu, and recording the menu selections made and the
time each took, etc...  The Forth system was very useful for
prototyping different mouse tracking techniques for pie menus -- it
would have been very painful to have to go through the old
edit-compile-link cycle every time I wanted to tweak something! NeWS
is an example of how useful it is to have a window manager with an
interactive extension language! (But I didn't have NeWS yet.) X window
managers are big messy programs (even in the X10 days!), but I was
able to plug X10 uwm right into Sun Forth, and start hacking away --
instant extension language! (Though uwm wasn't exactly /designed/ for
that kind of abuse!)

I've also used Sun Forth for other projects, like prototyping a
hypertext markup language interpreter (NeWS HyperTIES), and as a
Cellular Automata Machine rule compiler. I cloned Tom Tofoli's CAM
rule language in Sun Forth, and wrote a tool for computing and
displaying them in NeWS. Not anything like as fast as the real CAM
hardware [256x256 cells @ 60 frames/sec], but if you feed it the right
rules and initial conditions, and wait a while, it will make lots of
pretty patterns that take up lots of disk space.

>Both are available from:
>
>Mitch Bradley
>Bradley Forthware
>P.O. Box 4444
>Mountain View, CA 94040
>

Mitch swears the PO box number was totally coincidental!

>----
>Disclaimer:  Endorsement?  I haven't even used them.
>
>William Baxter
>
>ARPA: web@{garnet,brahms,math}.Berkeley.EDU   
>UUCP: {sun,dual,decwrl,decvax,hplabs,...}!ucbvax!garnet!web

Disclamer: Of course I'm quite biased, since I worked with Mitch for a
summer, and I just love his Forth system. But so does Mitch, or it
wouldn't have so many great features!

	-Don