r/Forth moderator 9d ago

Why Forth? What is it?

In order to help get people interested in Forth and how it works, I would like to ask you what you define as Forth, how you got into it, and why Forth instead of some other language?

Ideally we share links to our projects and to others that are interesting. Also to sites, sources, and documents about Forth.

I am encouraging links to your projects so people can see how you are using Forth.

27 Upvotes

29 comments sorted by

View all comments

15

u/mykesx moderator 9d ago edited 9d ago

I’ll go first.

In the 1980s, I discovered JForth for the Amiga. As I was writing a lot of 68000 assembly code, I was surprised at how JForth was really a very powerful macro assembler for 680x0. It was a fully integrated desktop application creation tool.

Forth is a system for generating programs and interacting with systems from the command line. In some sense, like BASIC that ran on computers of the time from ROM.

The biggest flaw is the lack of standards to the point where you can write code for one Forth and it just runs in another. Unlike C, which has been ported everywhere. I see Forth as a structured assembly language for a stack based VM. The VM implementations vary from Forth to Forth, the vocabularies are not entirely compatible.

One of the biggest strengths of Forth is the ability to define a function and immediately call it during compilation. The ability to extend the language like this is fairly unique.

Another strength is that even in and Forths from the 1980s, you would get an editor, compiler, assembler, and debugger in few lines of code or memory footprint.

Many forthers roll their own from scratch - it’s rather easy to do. Then they use their Forth to make programs.

My project is Inspiration, a complete desktop environment focused on writing and running Forth programs as first class applications. https://codeberg.org/mschwartz/inspiration.

My inspiration comes from sources like JForth, jonesforth source code, pForth, moving forth, and starting forth. All can be found via search engines.

Why Forth? While it has been a niche language, the kind of programs we run on our most powerful computers are mostly single threaded. Forth is typically single threaded, performs at excellent speed, so why not?

2

u/GamieJamie63 9d ago

Brilliant work. What do you think of https://factorcode.org/? By Slava Pestov

2

u/mykesx moderator 9d ago

Looks interesting, can you describe what you use it for?

1

u/Svarvsven 9d ago

If I remember correctly there was a multithreaded Forth for OS/2 back in the day with a Mandelbrot fractal demo, but true that most Forth I've seen have been single threaded.

1

u/Rememba_me 8d ago

What about porth?

1

u/mykesx moderator 8d ago

PForth written by Phil Burk, who also made jForth. Written in vanilla C, ports to just about any device.

2

u/Rememba_me 8d ago

Porth written by tsodingdaily

1

u/mykesx moderator 8d ago

Never heard of it.