[net.lang.forth] Portable Forth for Unix

merg@bunker.UUCP (Jim Stephenson) (01/12/84)

Hi,
	Are there any versions of Forth available which are portable
across Unix's. KPNO Forth is written in MACRO-11 for both the VAX and
PDP-11. Caltech Forth is written in MACRO-11 for the PDP-11. What I am
looking for is a version of Forth that is written in some portable 
language (preferably "C") which will run on most versions of Unix.
If you know of any please tell me.

				Thanks,
				Andrew T. Rodnite
				Mergenthaler Linotype
				201 Old Country Rd.
				Melville, New York 11747
				(516) 673-4318
				ittvax!bunker!mergvax!rodnite
				ittvax!bunker!merg
				ittvax!bunker!mergvax!mergee!andy

smith@umn-cs.UUCP (01/19/84)

#R:bunker:-32100:umn-cs:14200006:000:1982
umn-cs!smith    Jan 18 18:49:00 1984

A Portable Forth Kernel?  Hmmm.

My first impression is to say "Nonsense!" but then, maybe not.  Discussing
such a thing might drag this newsgroup out of the doldrums...

Building a 'portable' kernel may be a real pain.  I see several problems,
none impossible, but still problems:

1. Forth dictionary storage is completely unstructured, so you'll need
   to do typeless references to it.  I wouldn't want to use Pascal, even
   with variant records.

2. The inner interpreter ("address interpreter") would be a sight to behold
   in any high level language.  It wouldn't run very fast, either.
   Forget Pascal, since you'll be manipulating addresses of procedures.
   (Ooooh noooo, Mr. Wirth!)

3. The code might compile a kernel that works over a broad range of
   machines, but I'd expect there to be problems porting applications,
   especially between 16 and 32 bit machines.

4. How many of the 'classical' elements of Forth would be lost?  I've talked
   to people who have tried to build Forth kernels in Fortran, etc, and
   they generally discard the traditional structure of Forth for something
   that better fits the language they're writing it in.  Also, I've never
   spoken to anyone who's actually used one of these Forths, only people
   who are trying to build one.
   
   I'm not saying that Forth text always (or even often) depends on
   such things as the location of the dictionary header, but in Forth
   you usually rely on such facts during debugging.

5. My definition of a 'real' Forth system is one that can support
   some sort of assembler.  This knocks out those high level languages
   that make it impossible to branch into a data area.  Does anyone think
   it can be done in C?  Maybe with the inner interpreter written in
   assembly language?  Or a special function branch(addr) written in
   assembler? (be sure to clean your stack when you're done...)

Enough for now.  Comments?

Rick.
[smith.umn-cs@CSNet-Relay]
 [...ihnp4!umn-cs!smith]

blk@sytek.UUCP (Brian L. Kahn) (01/23/84)

First of all, a portable anything for Unix should be written in C,
and use unix calls where needed.

Second, i think that forth programmers only need assembler for
increased speed and efficiency, which your system adminstrator
probably doesn't want to have you mucking about with, anyhow.

So i vote for a traditional Forth with a more or less normal
dictionary (using callot() or some such system call) sans assembler.
Might not be too slow, either.  Especially compared to a 6502.

B<

smith@umn-cs.UUCP (Richard Smith) (02/02/84)

#R:bunker:-32100:umn-cs:14200007:000:1546
umn-cs!smith    Feb  1 09:46:00 1984

  I favor having an assembler with Forth because I occasionally need an
assembler.  Forth is the only system I know of that allows me to deal
with assembler in a reasonable fashion.  An assembler in Forth lets you:

1. Work with very small pieces of machine code.  It's almost impossible
   to write small assembler programs in any other environment (i.e. 2
   or 3 instructions).  You can do all of your I/O on the stack.

2. Experiment with the machine's instruction set.  A fine way to learn.

3. Diagnose hardware problems.  This isn't as useful on our Berkeley Unix
   since kumem is broken and Berkeley doesn't handle bus errors nicely.
   BUT... there's been many a time I've wanted/needed to tweak a device
   and there's no better device tweaking language than Forth.

4. Build REAL TIME stuff.  I'm speaking to you via a 1200bps modem link
   handled by Forth running on a Z80.  Most of the modem handling code
   is in hi level Forth, of course, but most of the words called by the
   innermost loop are in Forth assembler.  High level Forth just didn't
   have the speed.

  The main use I see for Forth on Unix is for hacking around with small
algorithms (i.e. a toy).  Sure, it provides a nice variable radix
calculator, but if I want it to be something more than a toy I need
an assembler.

Rick.

p.s. Arguments that "systems administrators don't want you to execute
     assembly code" are bogus.  If assembly code is a security breach,
     then you can certainly breach security with most other high level
     languages, too.