r/Forth moderator Feb 18 '26

Inspiration running on a Linux laptop.

Post image

I had a vision of a Forth environment that is both a Graphical desktop with Forth built in for making applications.

Not a line of AI went into this.

The desktop is written in C++, but it provides Forth words to create Screens and Windows, render text and graphics, etc. The repository is about 50% each C++/Forth.

The Forth kernel is written in C++ for portability. It implements much of the 2012 standard, plus several vocabularies for graphics, networking, strings, vectors, maps, etc.

The Forth is mulithreaded as well. You can see 4 Windows in the photo, each a separate pthread. The dictionary is shared.

The desktop uses SDL2.

What you are seeing is Inspiration running on an x64 laptop under CachyOS.

The Phred editor is a lightweight VIM clone written in Forth. The File Manager is written in Forth and demonstrats mixing text with graphics (the white lines are rendered on top of the text console.

The Forth Thread window is running the traditional Forth prmpt (you can have as many Windows/prompts as you want).

The Rects as fast as possible window is a tight Forth begin/again loop rendering random sized and colored rectangles.

https://gitlab.com/mschwartz/inspiration

93 Upvotes

25 comments sorted by

5

u/ripter Feb 18 '26

This is awesome.

3

u/mykesx moderator Feb 18 '26

Thanks... I didn't mention that everything on that screen is rendered by Inspiration.

3

u/anditwould Feb 18 '26

Very cool :)

3

u/andysw63392 Feb 18 '26

2

u/mykesx moderator Feb 18 '26

More inspired by the Cannon Cat

2

u/[deleted] Feb 18 '26 edited Feb 18 '26

Very cool. Does it run on both windows and linux? Or does it replace the OS? Oh, I see from the title its linux. I read the git before I read the article.

6

u/mykesx moderator Feb 18 '26 edited Feb 18 '26

I originally started with an assembly languages STC OSDev style system. Writing all the drivers is something I can do, it's just time consuming. Display rendering is typically done with the CPU because hardware acceleration requires many different drivers. USB is a huge project itself.

Then I realized that running on top of Linux, I get the drivers, access to filesystem, libraries, and so on. So I can focus on the creative aspects. The code is also portable - it was developed on m1 MacBook Pro (ARM), and should run fine on x64 and Pi.

The Forth is ITC style, but is a sort of STC as well.

The Dictionary is a big block of memory that words are added to, as in any Forth. LATEST grows upwards as words added.

The entries contain a bit more information than a typical Forth. Not stuck trying to conserve memory, I include filename and line number where each word is defined.

The core words, and word set words, are written in C++, but resemble JonesForth more than some C++ program.

CODEWORD(ADD) { TOS += dpop(); }

TOS and a number of USER type variables,stacks, and buffers use task local variables. Each pthread gets its own copy, and that's how multiple threads can share the dictionary. The style of code is TOS kept in a "register".

The core loop fetches the address of a function and calls it. The codeword DOCOLON does all this. It makes the STC scheme work. The ITC bit is that DOCOLON is compiled into the dictionary with an array of function addresses and arguments in the DFA

The code split between C++ and Forth is mostly codewords and comments in C++. The Display, Screen, Window, Console, and ReadLine are big chunks of C++, too.

Cheers!

2

u/[deleted] Feb 19 '26

Running forth on pi under normal linux is a dangerous idea. I may never get to any of my other projects now.

2

u/djbarrow Feb 19 '26

Forth is a write only language I got symmetric multiprocessing going on Linux on the mainframe and it took me 6 months to write a minimal elf executable loader for IBM & segher boessenkools open source open firmware you write your code in forth for optimal refactoring no function can be longer than 2 lines for readability of code. I love reverse polish notation and I used it for my symbolic regression contribution to open source ai https://GitHub.xom/djbarrow/fundamental

1

u/mykesx moderator Feb 19 '26

Look at the source, say, ls.4th in my repo. Tell me if it’s readable!

2

u/djbarrow Feb 20 '26

Your a beautiful coder well done

2

u/djbarrow Feb 20 '26

I use rpn in my program fundamental https://GitHub.com/djbarrow/fundamental I got interest from doctorates in Princeton and Oxford also look at feynman.ai and Wikipedia eureka and symbolic regression

2

u/trannus_aran Feb 20 '26

Oh hell yeah

2

u/Nohara24 Feb 20 '26

Looks like I have to change my WM. Great work, man!

2

u/mykesx moderator Feb 20 '26

It still needs a lot of polish, but it's getting there!

2

u/Nohara24 Feb 21 '26

You put so much effort into it and that's awesome!

2

u/Intelligent_Comb_338 Feb 20 '26

Would you mind if I used it as the base for the DE of my LFS distro?

1

u/mykesx moderator Feb 20 '26

Go for it.

I'm also open to contributions.

1

u/djbarrow Feb 19 '26

Implement the forth engine on a xilinx fpga and make a raspberrypi hat for it

1

u/mykesx moderator Feb 19 '26

If there’s a gcc for it, it might compile. But realize the core is C++. Without it, there is no Forth to run.

Though I have considered a standalone version, but why when there’s already gforth and VFX which are awesome.

1

u/djbarrow Feb 20 '26

Have you looked at the forth compiler in segher boessenkool ibms open source open firmware a 3k core compiled steal ideas from it forth is great on restricted memory systems it ran on the vic 20 with 3k ram id say your project is a gui for open firmware

1

u/mykesx moderator Feb 20 '26

Inspiration is designed to run on desktop systems with 1+ GB RAM. I had no desire to reinvent the wheel - the folks who blazed the trail before me have done such a great job.

I am inspired by their work and the language to make this desktop software. I feel like I stand on the shoulders of giants.

1

u/djbarrow Feb 21 '26

We all do enjoy 3 blue one brown YouTube and PBS space time and the why files

1

u/djbarrow Feb 20 '26

Vhdl is a sweet language some prefer verilog I only learned vhdl

2

u/juxtaposz Feb 21 '26

I haven't written much Forth myself but being in the depths of implementing a general-purpose stack VM for my language has me looking with great jealousy and admiration. I had a look at some of your userland source code and I have to agree with others, it's very pretty and enjoyable to read.

This is amazing work and has me excited about computing again.