Forth

Anything QL Software or Programming Related.
Derek_Stewart
Font of All Knowledge
Posts: 3928
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

Forth

Post by Derek_Stewart »

Hi,

I see that there is an interest in Forth on the QL, I like to use Superforth by Gerry Jackson, which was sold by Digital Precision, but now free, available at:

https://github.com/gerryjackson/QL-SuperForth

A good ebook to read I have found is 'Starting Forth" by Leo Brodie, see:

https://www.forth.com/starting-forth/

If anyone has any good Forth listings, I would be interested in seeing them.


Regards,

Derek
User avatar
polka
Trump Card
Posts: 196
Joined: Mon Mar 07, 2011 11:43 am

Re: Forth

Post by polka »

Hi,
I discovered FORTH on my ZX81. But it was rather unusable. Then, for my QL, one of my first moves was the acquisition of ComputerOne FORTH.
This was a good move, indeed, because on an unexpanded 128K machine with fragile microdrives, it was actually IMO the only alternative to SuperBasic :
Its "kernel" was loaded once for all for programming interactively, and it had only a few compact extensions such as an integrated Editor, a MacroAssembler, and a Tasking manager. The editor worked with "paged" source files (in the spirit of FORTH, organised in 1024 bytes "screens"), and so, the microdrives were very scarcely sollicited.
On the opposite, when I bought also Lattice C, even for the simplest code development, the microdrives whirred like crazy (compiling and linking), thus soon I had to add to my QL a Sandy SuperQboard with more RAM and a floppy disk interface.
With my first laptop (386 processor - DOS 2.2 and Windows 3.1), I used TurboForth (not a Borland product) which, like the QL ComputerOne FORTH was a 16 bit FORTH83 release, with the main difference using plain text source files.
When it went PD, I tried also SuperForth, but I found it rather disappointing :
It has a paged source management that sees each screen as a separate file, and a plain text source management that contrary to my TurboForth, does not accept LOAD-FILE instructions within a file being loaded. So you cannot manage modular tools.
Besides, it has no MacroAssembler, so you cannot easily add machine-code words, and as it does not use the same registers as ComputerOne FORTH for its "forth engine", you cannot port machine-code from one implementation to the other. Actually, the user manual discourages machine-code programming.

The ComputerOne FORTH was developped and adapted for the QL by Stephen Pelc (head of MPE software company) who also wrote a very complete book on FORTH (google for it). Too bad that the copyright of ComputerOne Forth is very unclear and that it may not be made PD !

Anyway, may the FORTH be with you !

What do you mean by "Forth listings" ? user developped programs ? I showed some here, and can show more, but I have to "english-ize" them and convert them for SuperForth.

By the way, there is another book by Leo Brodie, called "Thinking Forth", which is much interesting, because it develops the philosophy of Forth. I saw that today, it is freely downloadable as a PDF or a Kindle.

POLKa


May the FORTH be with you !
POLKa
User avatar
pjw
QL Wafer Drive
Posts: 1286
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: Forth

Post by pjw »

When I got my first QL back in March 1985, I saw its main use as a number cruncher for maths and physics problems. Since I was comfortable with RPN, thanks to my beloved HP programmable calculator, Forth seemed a good choice for my first "real" programming language, so I ordered Computer One's Forth and borrowed Broidie's Starting Forth from the library. That was an unmitigated disappointment. Thanks to Brodie I learnt some Forth, it is true, but as a mathamatical tool C1's Forth was pretty crap - at least in comparison with the slick, math-oriented HP41CX.

Computer literature was hard to come by back then. Perhaps because I didnt even know what to look for. The library told me there was a book on C up in Trondheim, where the technical university was located. They could put me on the waiting list and order it when it became free, but MC68 assembler? Wot dat?!

At the time, BASIC sounded like something for wimps. However, at least it was immediately available at switch-on, a basic tutorial came with the QL, and on balance it seemed a lot more flexible than Forth.

Due to SuperBASIC's lack of range and precision I plumped for Prospero's Pascal when it arrived. But with all that faffing around with REPeat: load: edit: save: compile: test.. I packed it in. It just wasnt worth the pother. SuperBASIC and the QL seemed made for each other. Why resist?


Per
dont be happy. worry
- ?
User avatar
polka
Trump Card
Posts: 196
Joined: Mon Mar 07, 2011 11:43 am

Re: Forth

Post by polka »

Hi,

"Me too" was locked to RPN by the little HP calculator, but I didn't have the HP41, but its elder HP67. Thus FORTH.
One program that I did on this machine (and that used its whole program memory) was to compute the "cross-sectionnal charasteristics of beams" of any complex shape (eventually with hollows).
Anasec67.zip
Anasec67 Use and list
(101.15 KiB) Downloaded 129 times
My program could be loaded reading only one magnetic card (the magnetic card reader of my HP67 no longer works, by now, I may program only emulators :-) ). HP sold an analog program but you had to swap two cards to complete the computations (I did not try it, because I had no reason to buy it).

About your view on SuperBasic, Forth and number crunching :
I don't think that SuperBasic is for wimps. It let you program structured and modular and I find it much better than all the other Basic dialects that I know (even much better than the BBC basic, that I used on a ZX88). I am simply a little disappointed with its peculiar floating point format and the fact that integers are limited to 16 bits.

FORTH has no floating point, but integers of 16 and 32 bits and mixed operations that let scale them robustly. Indeed, it's not a langage for "number crunching". For this, I use a general purpose langage like C. For instance : I developped a linear algebra and signal processing application with "number crunching" by a C module, communicating with the Forth langage for managing the work-space and the sequences of elementary computations in user written programs.

I shall have it working again and show you...

POLKa


May the FORTH be with you !
POLKa
User avatar
pjw
QL Wafer Drive
Posts: 1286
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: Forth

Post by pjw »

Nice! :) The language looks identical to that used by the 41C+, except the "Alpha" stuff is missing; no textual lables or prompts.
All my programs were hand writen, as everything HP was outrageously expensive, so printers were out.
Here is tiny a piece of the only surviving program, after the latest cull of my life's debris.
Derivative.jpg
Derivative.jpg (53.8 KiB) Viewed 3566 times
I believed BASIC was for wimps before I got to grips with SuperBASIC. And yes, to my mind the biggest flaws were the lack of long integers and double floats, hence my brief dalliance with Pascal.
I really enjoyed Archive, though, which had much better precision. Sadly it was rather slow and, unlike SuperBASIC, confined within its own little world.


Per
dont be happy. worry
- ?
User avatar
polka
Trump Card
Posts: 196
Joined: Mon Mar 07, 2011 11:43 am

Re: Forth

Post by polka »

Hi
Here the link to the site with the HP67 emulation that I tested and use on my WindowsXP machine
Actually, it is a HP41 emulation with a transparent translation of HP67 instructions
On the same site you may also get the original HP41 emulation
https://sim41.webcindario.com/
Here another link to an HP67 emulation coded as a .net application.
So it needs the .net3.5 runtime. I will install and try it
This is said to work also on Windows 8 and 10, whereas the first works only up to windows 7
http://www.panamatik.de/html/hp-67.html

POLKa


May the FORTH be with you !
POLKa
User avatar
Sparrowhawk
Super Gold Card
Posts: 624
Joined: Wed Dec 15, 2010 12:33 pm
Location: @131072
Contact:

Re: Forth

Post by Sparrowhawk »

I don't know Forth at all well but I remember being intrigued by the Jupiter Ace when it was released, with its magical programming language that was supposedly so much faster than BASIC. The Ace is way too pricey on sites like eBay to actually buy one, but I did buy myself the 35th anniversary re-release of the manual when that came out a few years back, and tried some of the concepts on an emulator. Conclusion: my mind does not work in RPN! :D

Here is the Amazon link, but I think I got my copy on eBay

https://www.amazon.co.uk/Jupiter-ACE-Ma ... 1785387294


a.k.a. Jean-Yves
User avatar
pjw
QL Wafer Drive
Posts: 1286
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: Forth

Post by pjw »

polka wrote:Hi
Here the link to the site with the HP67 emulation that I tested and use on my WindowsXP machine
Actually, it is a HP41 emulation with a transparent translation of HP67 instructions
On the same site you may also get the original HP41 emulation<>
Hi,
It looks like fun :) However, I fear we are veering off topic here..

Perhaps somewhat still on topic: Laurence Reeves, of Minerva fame, produced (sometime in the nineties?) everyone's wet dream of an RPN calculator: ECalc. Its not programmable, but has "unlimited" precision and lots of functions. Unfortunately it is for Windows but, amazingly, it still works in W10 (except Help)!

I corresponded with him about it once. He wrote, in part: "ECalc actually started on the QL. I've just realised that I've never put a copy of that on the web site. It was a bunch of extensions (separately assembled for each of a selection of 2^n bit precisions) that did the number crunching and an SB program that handled all the stuff that didn't need any speed."


Per
dont be happy. worry
- ?
User avatar
polka
Trump Card
Posts: 196
Joined: Mon Mar 07, 2011 11:43 am

Re: Forth

Post by polka »

OK I stop talking HP67 or HP41 and RPN : Forth is not at all about RPN :!:

Forth is a virtual machine for interactive use with 2 stacks instead of one and 2 interpreters instead of one :?:

When you type in a word Forth looks for it in a list called its "dictionnary"

When you type in a sentence composed of Forth words and numbers, Forth looks for the words in its "dictionnary" and executes the sequence of operations on the numbers that it has stored in its "data stack". This interactive "conversation" with Forth uses the external interpreter (a search of its dictionnary).

Some Forth words are compilation words, capable to add new words to the "dictionnary" as sequences of any words which already exist.

These words are stored (together with their new name) as tables of execute addresses of the words composing the sequence. So when you call such a defined word, it will jump successiveluy to the execute addresses and do so on recursively down to the (most primitive) machine code words, thus using an "inner interpreter" and the "return stack". This inner interpreter makes Forth execution speed almost as fast as an assembled program ; because running your application programs has Forth looking with its external interpreter just for one word* in its dictionnary and then do all the jumping around with its inner interpreter.

*to be noted : this search is actually itself very fast, because your application program name is usually the last (or one of the last) defined word, which is the first to be found by the external interpreter.

So, using Forth is not at all about computing in RPN. It is designing application oriented user interfaces for a very fast virtual machine.

POLKa


May the FORTH be with you !
POLKa
User avatar
polka
Trump Card
Posts: 196
Joined: Mon Mar 07, 2011 11:43 am

Re: Forth

Post by polka »

Hi,

I am sure that you all know where to download the best emulator for ZX80, ZX81, Spectrums, ... and Jupiter ACE :
https://sourceforge.net/projects/eighty ... -emulator/
To be noted : the Jupiter ACE follows the FORTH79 standard, whereas the QL FORTHs are FORTH83.
To see a list of all the predefined Forth words of the Jupiter ACE, type in the Forth 79 word VLIST (instead of WORDS, that does the same thing in Forth 83).
Seeing all the words that Jupiter ACE offers, you would not need anything else (apart maybe the Forth 79 standard).
Anyway, you can download its manual freely here : http://jupiter-ace.co.uk/usermanual.html

POLKa


May the FORTH be with you !
POLKa
Post Reply