Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Show HN: R3forth, a ColorForth-inspired language with a tiny VM (github.com/phreda4)
86 points by phreda4 1 day ago | hide | past | favorite | 17 comments




Back in the VIC-20 days, I had the VIC Forth (https://ia800304.us.archive.org/34/items/VIC_Forth_1982_HES/... and https://photobubba.com/wp-content/uploads/2016/06/an-intervi...) cartridge and the book Starting Forth (https://www.forth.com/starting-forth/). It was my second programming language, after BASIC.

Like everything else, it was easy do simple things, much harder to do anything else. My brain also rejected doing stuff with postfix notation.

It always fun trying to explain Forth to developers used to higher level languages. It always came down to "a word is like a function, but not really"


Word is an internal call, it's a function, but the key is that the parameters and local variables are on the data stack and are separate from the return stack. I can call many levels without touching the data stack! Impossible in other languages. However, this does require practice and a change of mindset. At runtime, the dictionary doesn't exist, and under certain conditions and with the correct compiler, the stack doesn't either; it's converted into registers.

Forth invented as a monitor and control system for one of the radio telescopes at NRAO in West Virginia...

So I have a tribal affinity for Color Forth, by original creator of Forth.


Forth was invented before Moore worked at NRAO. Granted, it was gradually expanded from a very small interpreter, so it's hard to say exactly when it became "Forth" as we mean it today.

Source: "The Invention of Forth", by Chuck Moore. https://colorforth.github.io/HOPL.html

Forth should be considered a family of languages; Anton Ertl took its picture some time ago [1].

Chuck Moore agrees I think with the idea [2]:

That raises the question of what is Forth? I have hoped for some time that someone would tell me what it was. I keep asking that question. What is Forth?

Forth is highly factored code. I don't know anything else to say except that Forth is definitions. If you have a lot of small definitions you are writing Forth. In order to write a lot of small definitions you have to have a stack. Stacks are not popular. Its strange to me that they are not. [...]

What is a definition? Well classically a definition was colon something, and words, and end of definition somewhere.

    : some ~~~ ;
I always tried to explain this in the sense of this is an abbreviation, whatever this string of words you have here that you use frequently you have here you give it a name and you can use it more conveniently. But its not exactly an abbreviation because it can have a parameter perhaps or two. And that is a problem with programmers, perhaps a problem with all programmers; too many input parameters to a routine. Look at some 'C' programs and it gets ludicrous. Everything in the program is passed through the calling sequence and that is dumb.

[1] https://www.complang.tuwien.ac.at/anton/euroforth/ef04/ertl0...

[2] https://www.ultratechnology.com/1xforth.htm


Sadly, Chuck Moore is old, and Microsoft, in their unyielding quest for innovation, somehow broke the API contract for the BitBlt call in a way that permanently broke ColorForth, and Chuck has decided simply not to continue with it.

When he told about that in the Fireside chat, I was really puzzled at first. I think Chuck was just being the eccentric guy he is was telling a cautionary tale for the shock effect, in a kind of dark humorous way. Also the guy is 88 years old now, so it's somewhat understandable when your energy levels are extremely low, both physically and mentally. With the little time left of your life, you wouldn't want to spend it fixing some random breaking API change from Windows.

I imagine his ColorForth has been more like a retirement hobby for the past decade. He used to screenshare from his ColorForth during the calls, but that could have been overcome more easily with a VGA->HDMI capture dongle and running ColorForth natively. And I doubt he needed the TCP/IP stack directly on his ColorForth based on what he shared so far. So I don't see the point of porting over to Windows to begin with. After all, ColorForth runs more easily on bare metal, on UEFI/BIOS or whatever, so it didn't ever need BitBlt to draw things on screen for sure. The guy built a ColorForth processor, and the devkit from GreenArrays has a VGA connector, etc. So I believe Chuck was on to something else when he shared that, perhaps just to stimulate thinking, but people tend to take things at face value.

On another note, ColorForth (or FORTH for that matter) is not meant to be owned/controlled by him or a committee. So it's not like he was maintaining it. AFAIK, he didn't even endorse or support FORTH standardization efforts, and somewhere said it's silly. I also find it interesting that in his book A Problem Oriented Language, there is not a single mention of FORTH even once (except in the preface, and in his bio) yet he describes FORTH in the book, just calls it as "A Problem Oriented Language" without naming it. So it's almost like FORTH doesn't exist. It's just an idea. And what doesn't exist cannot be broken.


Jonathan Blow is famously working on a programming language for games, called Jai; but he never mentions it by name when he streams. I think his concern is similar to Chuck Moore's: that the language should exist in the abstract, and when you start nailing it down too tightly by naming and standardizing it, you create problems later when you want to change those things. It's clay he can mold, something to experiment with. How much more true is that of Forth for Chuck.

The strange thing is that imho, as in many other things around language design, Scheme sort of had the right idea. I like having a well-defined semantics with wide agreement that I can write programs on. The fact that the Common Lisp standard is practically unchanged since the 80s, and the core of Ada has survived with only significantly useful extensions added on in later standards, is real neat to me, compared with C++0x/1x/2x being a completely different beast than the C++ of the 90s, and Rust and JavaScript undergoing constant churn. The RnRS process, historically, was all about defining a core that implementers could all agree on, calling it Scheme, and then letting implementers fuck around on top of that basis. R6RS and R7RS were controversial precisely because they deviated from this; although R7RS tried to please both the "small core" camp and the "Python with parens" camp. Which is kind of like trying to please both classic Sonic fans and post-Adventure Sonic fans.

But yeah, I think Chuck's advanced age and a general feeling of "I'm too tired for this shit" were the primary reasons for making that announcement. And you may be right, he may be just telling us not to get too attached to a particular artifact but to embrace the idea of Forth. Maybe the real ColorForth was the friends we made along the way. May the Forth be with you, my friend.


Very impressive demos! I did a quick look through the docs- it’s single threaded (in the cpu sense) and not multi process yes?

not for now, just launch many instances!

Very interesting, great work! This reminded me of something. I just checked and to my amazement Mike Hore's Powermops is still around and even has an ARM version.[1]

[1] https://www.powermops.org


Yes, that's neat -- it is basically a modern Neon, which was an object-oriented Forth for the Mac in the 1980s.

In the first code example in the readme ("First program"), there's `sdlcls`, `SDLinit`, and `SDLShow`. Is there some significance to the capitalisation?

r3forth is case insensitive

Ah, it might be nice to mention that before the first code example, then. Or just use consistent case in the first example, to avoid distracting people with details that aren't the thing you're trying to demonstrate.

Very nice graphics using SDL2!

So many features-- sprite sheets, etc. Well done!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: