• Please review our updated Terms and Rules here

FORTH PLASMA + PLFORTH !

resman

Veteran Member
Joined
Jan 1, 2014
Messages
604
Location
Lake Tahoe
There are probably more FORTH programmers here than PLASMA programmers (perhaps not really saying much), but I spent the Holiday break to implement a minimal FORTH in PLASMA. Although I've spent a lot of time in the lower level plumbing of FORTH, I never used it or really programmed in it. So I'm looking for feedback on the implementation I've come up with for the PLASMA environment. I put together a poor video as an introduction and a quick description of its unique features.

You can find the video here: https://youtu.be/picPyXAk77I

Quick overview here:https://github.com/dsch.../PLASMA/blob/master/doc/PLFORTH.md

And a floppy disk image to play at home here: https://github.com/.../blob/master/images/apple/PLFORTH.PO

If you have no idea what PLASMA is, you can satisfy your curiosity here: https://github.com/dschmenk/PLASMA
 
Although I've spent a lot of time in the lower level plumbing of FORTH, I never used it or really programmed in it.
This is the FORTH curse. Everyone writes their own and marvels at, but nobody uses FORTH for anything but writing FORTHs.
 
This is the FORTH curse. Everyone writes their own and marvels at, but nobody uses FORTH for anything but writing FORTHs.
That is just not true. Forth exist is several places. I have no idea what Plasma Forth is but to say Forth is not used anywhere is broken thinking.
While I don't use Forth at work I use it for most all of my hobby programming. Most people that first look at Forth get lost in RPN. Mostly because they were taught complicated rules about how math should work.
2+3
To actually do it, even at the lowest level code in a processor is: "take 2 and take 3 then add them together"
The same as in Forth " 2 3 + "
It is not: "take 2 then take plus ( save that thought ) then take 3 and mush them together, but first check to see if there is a multiply that may change to order of doing it and while your at it look for any ( or ) as that will change things as well"
RPN is about doing it, not some complex rules about order of +or * being done first because of some rule.
It is about doing things as you see them in the same order as you read them "left to right, top to bottom".
This makes programming more like writing sentences instead of using a lot of boiler plate to fill the page ( more text fill more pay ).
I recall one of the people using Forth and giving the program to his manager, that didn't understand forth.
He was accused of just writing the definition of the code, even though it was the executable code!
Yes, it is quite easy to write ones own version of Forth. It doesn't have to handle a lot of complicated syntax rules to get working code.
It is just left to right, top to bottom!
How many times have you used the chip on your credit card in the past, Forth! That was because the code was provably correct.
Not that is couldn't have been done in some other language, it was just that it was harder to prove it was correct, for both the compiler and the end code.
It is not that you can't write really bad Forth code. I've seen some really bad code. I was asked to help a friend at Seagate.
They'd used one of the early 6502 development boards ( I forget which, but that is not important ).
The person, that coded it, looked like they were trying to write BASIC code in Forth. All the variables used names like A, B, C and so on.
This is where Forth gets the "write only" label. Anyway, the problem was found to be that the programmer didn't understand the physics of stepper motors and inertia.
Dwight
 
Last edited:
This is the FORTH curse. Everyone writes their own and marvels at, but nobody uses FORTH for anything but writing FORTHs.
Except I wrote it in PLASMA ;-) For me, it was the choice of symbols (word names) that put me off. RPN wasn't a problem (HP calculator user for 40 years), more the foreign look to the source. I mean, not as bad as APL, but why use '!' to store a value into an address? Certainly there is a long history and momentum with the naming choices, but I had some inclination to pick more comfortable word names that would be palatable to programmers coming from traditional languages. Ultimately I chose to stick with the standard naming (although I may have got some wrong) and aimed to make the programming process easier with the ability to view the state of the FORTH VM, set breakpoints, and generally have about the same experience you might have in interpreted BASIC.

PLASMA has always been missing a scripting component. A quick and easy way to manipulate files, get user input to launch other programs, etc. To that end, a FORTH intimately tied to the PLASMA subsystem works perfectly. Some things can be compiled, but many thing can just run as a batch of commands. You would hardly know it was FORTH. So I may be 35 years too late to shift anyone's mindset, but who knows? Better late than never?
 
It is just tradition. The thing is with Forth if there is something you don't like about how it was done, you can just replace it with what you like.
I think the the store operation was used so many times by Chuck that it just stuck. I suspect he was looking for a single key operate, a little like APL of the time.
Most have since added some form of local storage. If done write it can help with things like scope. Having global variables is almost as bad as being able to
point the things that are not protected and being global. "Garbage collection comes to mind". Where I work, we constantly find vendor bugs where things are
pointed to that no longer exist.
Dwight
 
I ultimately decided on a vocabulary that satisfied my desire to have a glue & scripting language for PLASMA. Keeping it minimalistic allows for quicker loading (PLASMA modules are relocatable and relocation is done at load time) and smaller size (still about 13K). Additional features can be loaded from source and PLASMA modules if desired. I forwent the more esoteric FORTH compiler, input, and number formatting words. What's left is a good match to the intended usage; PLASMA linkage, debugging and flow-of-control words:

forthwords.png
 
There are probably more FORTH programmers here than PLASMA programmers (perhaps not really saying much), but I spent the Holiday break to implement a minimal FORTH in PLASMA. Although I've spent a lot of time in the lower level plumbing of FORTH, I never used it or really programmed in it. So I'm looking for feedback on the implementation I've come up with for the PLASMA environment. I put together a poor video as an introduction and a quick description of its unique features.

You can find the video here: https://youtu.be/picPyXAk77I

Quick overview here:https://github.com/dsch.../PLASMA/blob/master/doc/PLFORTH.md

And a floppy disk image to play at home here: https://github.com/.../blob/master/images/apple/PLFORTH.PO

If you have no idea what PLASMA is, you can satisfy your curiosity here: https://github.com/dschmenk/PLASMA
Thanks for sharing it with us.
 
>> This is the FORTH curse. Everyone writes their own and marvels at, but nobody uses FORTH for anything but writing FORTHs.

Somebody should have told SUN that. *grin* I believe that their boot firmware for lots of the SPARC architectures was written in 4th. I have a copy of it somewhere? Too bad it's not portable. As I remember it, it also had an extensive interface to X11.

Roger
 
I have seen a disk emulator replacement for a misson-critical computer system written in 4th. I didn't realise this myself until we were replacing the replacement...

Dave
 
>> This is the FORTH curse. Everyone writes their own and marvels at, but nobody uses FORTH for anything but writing FORTHs.

Somebody should have told SUN that. *grin* I believe that their boot firmware for lots of the SPARC architectures was written in 4th. I have a copy of it somewhere? Too bad it's not portable. As I remember it, it also had an extensive interface to X11.

Roger
I've used the OpenBoot ( Forth ) to trouble shoot a couple of SUN Sparc machines.
Dwight
 
One of my, perhaps nontraditional, use for Forth is to have a batch/script language that can be used for mundane tasks such as software install. Since PLFORTH is a first class citizen of the PLASMA environment, it can easily execute all the PLASMA utilities directly. In this case, it builds a command line string, then loads the module by name (everything in PLASMA is a module). I also needed a way to conditionally execute code as the script was being interpreted, so I added that as well. It could have all been compiled and run that way, but I liked the idea of doing it as the script was read off the disk. Felt much more *batchy*. Here is a snippet from the install script:

Code:
CONFIRM" Copy build tools?"
?EXEC
  DEST " BLD" STRCAT
  " NEWDIR" SWAP LOADMOD
  INSERT.FLOPPY" PLASMA.BLD"
  FILELIST " /PLASMA.BLD/BLD/PLASM /PLASMA.BLD/BLD/CODEOPT " STRCPY
  DEST STRCAT
  " COPY" SWAP LOADMOD
  FILELIST " -R /PLASMA.BLD/BLD/INC " STRCPY DEST STRCAT
  " COPY" SWAP LOADMOD

  CONFIRM" Copy sample PLASMA code?"
  ?EXEC
    FILELIST " -R /PLASMA.BLD/BLD/SAMPLES " STRCPY DEST STRCAT
    " COPY" SWAP LOADMOD
  RESUME>

  CONFIRM" Copy sample FORTH scripts?"
  ?EXEC
    FILELIST " -R /PLASMA.BLD/BLD/SCRIPTS " STRCPY DEST STRCAT
    " COPY" SWAP LOADMOD
  RESUME>

RESUME>

FILELIST and DEST are strings used as the, well, file list and destination for the COPY program. I don't think it looks too *Forthy* and reads pretty well. The conditional execution is bound by ?EXEC and RESUME>, and they can be nested.

Overall, I'm very pleased with my decision to go the Forth route.
 
Back
Top