Live data from Hacker News

Forth: The programming language that writes itself: The Web Page

ratfactor.com

11–20 of 89 posts

Re: Forth: The programming language that writes itself: The Web Page

#11

anecdata (and warning some people might not like that domain brought here), there's a mini vm in bitcoin that a subset of forth https://en.bitcoin.it/wiki/Script I just learned that this week

It's a stack machine, but calling it a subset of Forth is maybe an exaggeration if you can't (afaik) define new words.

Re: Forth: The programming language that writes itself: The Web Page

#12

Earlier quoted context omitted.

Probably not. It turns out that it doesn't map to modern computer processors terribly well. It's an amazing and elegant language, but anything that does register-to-register operations is always going to be faster than register-to-memory.

Stack code can be mapped to register code trivially if you impose some restrictions (each word has a static effect and both branches of a conditional have the same effect). Then lowering to SSA form performs an “abstract interpretation” where evaluating a word pops SSA values from a “abstract stack”, creates an SSA node and pushes its output values on the stack.

I wouldn't say that sounds trivial exactl...

> slavapestov

... ok, fair enough: it probably is trivial for you, lol.

(For the uninitiated: Slava Pestov created Factor, a modern concatenatvie language which (IIRC) did a lot of innovative stuff regarding optimizations in that domain)

[0] https://factorcode.org/slava/

Re: Forth: The programming language that writes itself: The Web Page

#13

A great introduction is the book Starting Forth [0]. It has the most charming illustrations I've ever seen in a text book. [0] https://www.forth.com/starting-forth/

There is also Thinking Forth, which is a kind of sequel

[0] https://www.dnd.utwente.nl/~tim/colorforth/Leo-Brodie/thinki...

Re: Forth: The programming language that writes itself: The Web Page

#14
Tangent: I remember reading this in its original presentation-prototype form, which is basically this article with much less text and more plotholes. The reason I'm mentioning it is because it's also a beauty of minimalism in terms of underlying website technology.

[0] http://ratfactor.com/forth/forth_talk_2023.html

[1] http://ratfactor.com/minslides/

Re: Forth: The programming language that writes itself: The Web Page

#15
I have implemented yet another forth by myself. It works a little bit different and it is not intended to be a true copy of the original idea.

Since the post says you can discover Forth, here's my part:

https://github.com/loscoala/goforth

The main difference is that in this Forth variant, the source text is completely translated into bytecode and there is no runtime in the sense of classic Forth. This makes it easy to translate the bytecode to C.

I use my own Forth to generate C code with it, which I then embed in other software.

Re: Forth: The programming language that writes itself: The Web Page

#16

anecdata (and warning some people might not like that domain brought here), there's a mini vm in bitcoin that a subset of forth https://en.bitcoin.it/wiki/Script I just learned that this week

It's a stack machine, but calling it a subset of Forth is maybe an exaggeration if you can't (afaik) define new words.

fair point, they say "forth like", I pushed it too far

Re: Forth: The programming language that writes itself: The Web Page

#20

Why did some ancient programming languages emphasize on CAPITAL LETTERS? Was there no "Shift" button on keyboards back then?

No, in some cases there were not. In addition, capitals served as a method of differentiation for language keywords and such.
Post reply on HN