FORTH - the programming language.

For discussions about programming, and for programming questions and advice


Moderator: Forum moderators

Post Reply
User avatar
cobaka
Posts: 521
Joined: Thu Jul 16, 2020 6:04 am
Location: Central Coast, NSW - au
Has thanked: 87 times
Been thanked: 49 times

FORTH - the programming language.

Post by cobaka »

By some strange magic of the forum I began a thread about the syntax of the AWK command and (suddenly) the topic morphed to small compilers and FORTH - the language. So I cut/pasted the most recent posting by @6502coder here - where it belongs. Truly off-topic. His original is below, but to respond to 6502:

@6502coder
So to claim that CONVERS was faster than FORTH is to beg the question of how the FORTH was implemented.
Well, you are quite correct, of course. And - considering that some uPs had a faster clock than others, a claim for speed was generally short-lived. I spent some time considering the advantages of subroutine threading (where a program is essentially a sequence of call instructions) vs the disadvantages (a program takes approx. 50% more space, because one extra byte precedes the subroutine address). Speed worn. Looking back at a CPU with a clocking rate 1/1000 of the present shows how quickly design has moved over 40 years.

On the topic of software reliability: You wrote
the programmer had to do more mental work writing it in the first place.
Manipulating the stack certainly does take a great deal of effort, but any program error that imbalances the stack will be quickly revealed.

As for writing a compiler in AWK - that's an interesting task. So your language (THIRD) was a little 'less' than FORTH? Did you ever consider piping the output from THIRD into 'more'? That might just get 3rd promoted to 4th.

All the best

cobaka


- - - - - - - -
From @6502coder
Welcome to the world of AWK!

I once wrote a primitive FORTH interpreter in AWK. I think I called it "THIRD" -- because it wasn't quite FORTH. (That's not as bad a pun as it may seem because in fact Charles Moore wanted to name his language FOURTH (for "fourth-generation language) but the system he was working on at the time only allowed 5 letters for identifiers.)

I had a very brief look at the CONVERS document. I want to point out that FORTH was a language, not an implementation spec. That is, while most FORTHs were implemented as threaded interpreters, nothing in the language spec itself REQUIRED this. Even among the threaded interpreter implementations, there were variations: most were "indirect threaded," some were "direct threaded," others were "subroutine threaded", etc. So to claim that CONVERS was faster than FORTH is to beg the question of how the FORTH was implemented.

Regarding the "bug-free" nature of CONVERS, I would assume that, as in FORTH, most routines were very short -- Charles Moore found the idea of a program larger than a few dozen Kbytes to be totally absurd -- and thus there was less to go wrong in the first place. Also, as Jerry Pournelle once said in his Byte Magazine column (although he was actually quoting a friend of his), FORTH is basically a macro assembler language that uses the programmer as a precompiler. The two points being that a) since the programmer has to keep track of what's on the stack at all times, the language demands a mental focus that in and of itself probably tends to result in better quality code; and b) the resulting source code can very compact but that's because the programmer had to do more mental work writing it in the first place.

Pardon me for wandering off topic...but hey, you started it! :) ;)

собака --> это Русский --> an old dog
"so-baka" (not "co", as in coast or crib).

oui
Posts: 368
Joined: Fri Aug 28, 2020 9:35 pm
Has thanked: 6 times
Been thanked: 28 times

Re: FORTH - the programming language.

Post by oui »

Hum,

Why such a message and those transactions of ideas on a Puppy forum?

Forth is some ideal language for CPU's having a real free autoincrement for the major or most frequent commands. This is not the situation on usual modern CPU's because IBM and Microsoft did take the horrible decision to prefer Intel :mrgreen: with an idiotic memory management over that :!: .

since this time, Forth is dead.

Years ago, as 16 bit CPU's were usual, a student did create on Windows 95 an interesting new approach: Forth was the direct prolongation of Windows 95, that means, with other words, that Forth was the extension of Windows 95 and all Windows 95 commands directly available as Forth word :idea: . But the life time of Windows 95 was passed out...

I find a language as to be defined and (re)created in themself (*1 ! It is difficult in Forth as you need the assembler step. No way to proceed differently as part of Forth are some kind of super assembler (= uniformized assembler for all environments) needing to be coded in assembler to not be longer...

And the best way to implement forth is really to assemble it's code (for example in TMS9900 assembler as it is somewhat between low and high level language: porting onto an other CPU is then really easy: only search commands not available on those CPU's and redefine then with more long code and clock tact of those CPU's...)

I don't see where you would hang or add Forth in Linux and don't see the need.

(*1 turbo prolog came for ex. with as programm example an other prolog (only interpreter, the normal case in prolog, turbo prolog was an exception and a compiler)
WoodLark
Posts: 42
Joined: Fri Jul 17, 2020 1:48 pm
Has thanked: 2 times
Been thanked: 2 times

Re: FORTH - the programming language.

Post by WoodLark »

Many years ago, I read that FORTH is not a programming language; it is a religion.

User avatar
taersh
Posts: 951
Joined: Tue Jul 07, 2020 11:13 pm
Location: Germany
Has thanked: 53 times
Been thanked: 119 times

Re: FORTH - the programming language.

Post by taersh »

Off topic...

I wonder what has happened to Pascal AND especially Modula?

I used both of them when I was programming on the Atari ST series. The good old days! ;)

My Music:
https://soundcloud.com/user-633698367
Using my own build of Bionic64
The far-left is as fascist as the far-right is!

User avatar
foxpup
Posts: 186
Joined: Fri Jul 24, 2020 1:23 pm
Location: Europe near the Northsea
Has thanked: 75 times
Been thanked: 32 times

Re: FORTH - the programming language.

Post by foxpup »

taersh wrote: Mon Jan 11, 2021 2:49 am

Off topic...

I wonder what has happened to Pascal AND especially Modula?

I think it is almost abandoned now.
I still remember when it was getting popular.

My first (still best :? ) programming language was Fortran, Fortran77.
Fortran is still developed and used, mostly for fast big calculations, like models, quantum fysics, stars and space things ...

The one that probably everybody knows, but nearly nobody will admit, is Basic, in one form or another.
Still a good one.

user1111

Re: FORTH - the programming language.

Post by user1111 »

foxpup wrote: Thu Jan 28, 2021 1:08 pm
taersh wrote: Mon Jan 11, 2021 2:49 am

Off topic...

I wonder what has happened to Pascal AND especially Modula?

I think it is almost abandoned now.

https://www.freepascal.org/news.html

https://forum.lazarus.freepascal.org/in ... tion=forum

Their logo reminds me of Mike W's running dog gif ...

logo.gif
logo.gif (5.66 KiB) Viewed 675 times

I think I still have my original Borland Turbo Pascal installation 3.5" floppies and box/manuals around somewhere.

User avatar
rockedge
Site Admin
Posts: 5773
Joined: Mon Dec 02, 2019 1:38 am
Location: Connecticut,U.S.A.
Has thanked: 2051 times
Been thanked: 2130 times
Contact:

Re: FORTH - the programming language.

Post by rockedge »

@foxpup I like BASIC and have worked with some sophisticated BASIC programs. I still use QuickBasic 4.5 in DOSBox or in a true DOS virtual machine. I still have some QB45 programs that are compiled .exe (QuickBasic 4.5 has also a compiler along with interpreter) and will run great in Puppy using WINE. It is a blast from the past and QuickBasic has an integrated development environment (IDE) that allows stepping through lines or running a program and observe what is happening to variables in real time. Long ago I bought from a guy in England libraries for QuickBasic 4.5 written in assembly code and C+ that added functions like to create "windows" with scroll bars that could be layered and specialized software interrupts to access DOS functions and operations.....cool stuff.

User avatar
wiak
Posts: 3665
Joined: Tue Dec 03, 2019 6:10 am
Location: Packing - big job
Has thanked: 56 times
Been thanked: 1026 times
Contact:

Re: FORTH - the programming language.

Post by wiak »

I once wrote an 'oscilloscope program including Fast Fourier transform analysis', from 'first principles' using simple mathematics with Pascal for the user interface and 8086 assembly language (thereafter compiled) underneath to interface to an Analog2Digital converter board I had designed. That was actually a clone of same thing I had done years earlier in BBC BASIC and 6502 Assembler for the fast interface stuff. I once used awk as a programming language (and it is excellent for some purposes - particularly its associative arrays capability). I've never programmed in Forth though. Fact is, most 'procedural' programming languages are pretty similar conceptually and thus easy to learn (for simple cook recipe type programming exercises) if you know any of them.

Certainly C, has the huge efficiency advantage of providing 'pointers' to where variables and so on are in memory such that you often do not need to copy large structures from one place to another but rather simply move their pointer to new address location - alas that concept is a bit weird to those who have only used the likes of BASIC or PASCAL, but once mastered it is wonderful (particularly if you really understand it and can thus use pointers to pointers and so on...!!!).

The big problem for those who were brought up in 'procedural' style programming is getting their heads around the concepts involved in Object Oriented programming, which may seem an odd issue since object concepts may seem quite intuitive really - but the issue really is that procedural type language programmers (who are generally quite old since OO programming is where most students start nowadays) are used to understanding at quite a deep level what each single sequential instruction does - that understanding disappears from view when using objects and inheritance and so on... Fact is, to be a programmer, we just have to accept higher level abstractions (rather than 'needing' to understand how the underlying objects actually do what they do or how a single CPU can appear to process objects in parallel).

It is still useful, for some types of programming (such as the 'oscilloscope' I described) to be able to understand exactly what is going on at port binary and bit level instruction, but for the most part that would be impossible for the larger programming subsystems and user-interface sections of any program code. Abstraction, more generally, is exactly how it becomes possible to design huge systems without still taking thousands of human person/hours to accomplish such programming endeavours as modern-day computing services demand.

Sure, we can still write a simple BASIC or PASCAL program to get simple user input, process it, and print simple filtered output, but not much use for that really other than as a beginners programming exercise. Having said that, simple shell scripting does exactly that, and for an often very useful/efficient macro-language type purpose - so I take back my comment in that sense.

https://www.tinylinux.info/
DOWNLOAD wd_multi for hundreds of 'distros' at your fingertips: viewtopic.php?p=99154#p99154
Αξίζει να μεταφραστεί;

User avatar
rockedge
Site Admin
Posts: 5773
Joined: Mon Dec 02, 2019 1:38 am
Location: Connecticut,U.S.A.
Has thanked: 2051 times
Been thanked: 2130 times
Contact:

Re: FORTH - the programming language.

Post by rockedge »

Back in the day I used QuickBasic 4.5 with loads of libraries written in assembly like sort routines and network and GUI tools. Plus QB45 had a true compiler and could pump out executable binaries linked to the libraries. Then expanded to mixing C+ and assembly with QuickBasic45 which was relatively easy by converting the C+ and assembly into QB45's library format and loading the libraries as the QB45 IDE started. QB45 supported sub-programs, sub-modules and functions and had no line numbers.
Wrote some pretty sophisticated stuff with it. Wrote a complete Boomerang tournament score keeping package, one for a electronics dart league which later was converted to a check list program, to track sled dog health status across many veterinarian check points for the CAN-AM 250. Which is a professional - amateur 250 mile sled dog race held every year in Fort Kent Maine, United States which crosses into Canada for a stretch.

The programs still run great in DOSBox. Better in a MS-DOS virtual machine.

User avatar
cobaka
Posts: 521
Joined: Thu Jul 16, 2020 6:04 am
Location: Central Coast, NSW - au
Has thanked: 87 times
Been thanked: 49 times

Re: FORTH - the programming language.

Post by cobaka »

@wiak

most 'procedural' programming languages are pretty similar conceptually and thus easy to learn.

True. When people 'trash' Basic I think thoughts along the lines of your comment. At the same time I worked with a fellow called 'Ken Thompson' (a different Ken Thompson, not the great man). He said that some of his students could never progress beyond programming in Basic. So there you have two different opinions.

In an interview, Charles Moore said he could complete a project in a very short time using Forth. Forth is primarily a language that interacts with hardware. Given his experience, I tend to believe him. I wrote a number of applications using a Forth-variant and would like to install Forth on my hardware (Intel i3 running uPupBB32). If anyone has done this, pls tell me how you did 'it'. I favour GForth or Swift-Forth.

All the best,

cobaka

собака --> это Русский --> an old dog
"so-baka" (not "co", as in coast or crib).

User avatar
wiak
Posts: 3665
Joined: Tue Dec 03, 2019 6:10 am
Location: Packing - big job
Has thanked: 56 times
Been thanked: 1026 times
Contact:

Re: FORTH - the programming language.

Post by wiak »

https://www.whoishostingthis.com/resour ... ogramming/

"Stacks and Reverse Polish Notation"

Probably what puts off some programmers. My first calculator was made my Sinclair in the UK and used reverse polish notation so I became perfectly used to it - not surprising that RPN was used in early calculators since stack operations are naturally arranged in that order.

https://www.tinylinux.info/
DOWNLOAD wd_multi for hundreds of 'distros' at your fingertips: viewtopic.php?p=99154#p99154
Αξίζει να μεταφραστεί;

User avatar
cobaka
Posts: 521
Joined: Thu Jul 16, 2020 6:04 am
Location: Central Coast, NSW - au
Has thanked: 87 times
Been thanked: 49 times

Re: FORTH - the programming language.

Post by cobaka »

@wiak observed that Forth depends on

Stacks and Reverse Polish Notation & "Probably [the RPN] puts off some programmers.

Agreed, but I am intrigued by Charles Moore's comment that this type of language allows him to complete a project in a shorter time.
After that, I find the language yields remarkably reliable code. Most of my programs involved 'linear' programming without "P" and "V" flags.
Not too many shared resources.
Also, because the design is done 'top down' but the coding is written from the 'bottom up'.
For this reason every subroutine is tested as it is written. Plus: testing is remarkably easy; mostly the result is found on the stack and is thus 'visible'.

Plus: after programming in assembly language I found stacks are vy useful

cobaka

собака --> это Русский --> an old dog
"so-baka" (not "co", as in coast or crib).

forthuser
Posts: 10
Joined: Thu Feb 23, 2023 9:03 am
Been thanked: 1 time

Re: FORTH - the programming language.

Post by forthuser »

Hi,
Assembed BigForth 2.5.0
bigforth_2.5.0-70.1_i386.deb
Source: bigforth.zip
BigForth site
BigForth on Github

Run in TahrPuppy32, BionicPup32ng-19.03, ScPup32 ...

PS. gForth not complete assembled for PuppyLinux32.

VFX Forth Community

SPF4

...
and more, more, more :)

Forth on Github

Post Reply

Return to “Programming”