Readit News logoReadit News
NackerHughes · a year ago
This is incredible. I'll be tinkering with this for a while, guaranteed. As the advantages of combining Lisp and Forth in this way are slowly revealed to me it's like unlocking parts of my brain to interact with each other that never have done before.

Pretentiousness on my part aside, this is a pretty mind-blowing concept. The interpreter being in less than 1000 lines of (comprehensible) C is all the more commendable (most of these minimal languages turn out to be some monolithic Rust thing or similar, which kinda defeats the entire purpose imo).

Excited to take a closer look at the source to see how the various data structures etc. are laid out in memory. I won't be able to resist making comparisons to my current/other favourite mini-language 'fe' (https://github.com/rxi/fe), a sub-1000-line Lisp also written in C. If you haven't seen that one I'd definitely recommend checking it out.

Thank you for putting this online. Happy hacking!

xorvoid · a year ago
Thanks for the kind words. But if you’re looking for fancy data-structures, you won’t find them. Haha. It’s just a single object type (sum-type/tagged-union) and lots of cons cells. In other words, just a minimalist Lisp.
incanus77 · a year ago
I am in love with 'fe', as well as the slightly-better IMHO 'aria' by the same author.
um1 · a year ago
Very cool. I like that both lisp and forth were “discovered” and that this cvbp is more fundamental than both(?!). This reminds me of [pdf] https://dl.acm.org/doi/pdf/10.1145/181993.181999 and wonder if/how it relates.
xorvoid · a year ago
Also thanks for sharing; looks interesting. I’ll read this when I have time and re-comment then. Off the bat: Forsp variables are definitely not linear.
diffxx · a year ago
Thank for sharing that paper. I am currently implementing a compiler that has very similar ideas to those presented in it. It's very different syntactically, but the mental model is quite similar. It's simultaneously encouraging and discouraging to see your ideas reflected back to you from 30 years in the past :)
alexisread · a year ago
Looks complicated to reason about, but really interesting. Freeforth implements a similar mechanism to eliminate swaps via register renaming, obv. the focus is different in that Freeforth tries to still be an optimised stack, rather than a VLIW processor. I guess you could look at this paper as a vector processor, similar to the way APLs handle things with function composition. In that, you'd need the compiler to take care of things as managing it manually would be a nightmare. I guess the best way forward would be a specialized (forth) word lib which invokes the compiler to manage the top N stack cells for the duration of the word.
boltzmann-brain · a year ago
what is cvbp? google yields nothing.
boygobbo · a year ago
I think that was meant to be CBPV (Call-By-Push-Value)
tonyg · a year ago
It's a typo for CBPV, Call-By-Push-Value.
sevensor · a year ago
What I like about this is how neatly it reduces everything to a small set of concepts. Much like lisp and forth, but not the same as either. It's exciting to think that there may be more of these out there, waiting to be discovered!
thsksbd · a year ago
I been wanting to make a forth+lisp language for a while now - inspired by HP's RPL (its so close to being a lisp!).

Super cool

xorvoid · a year ago
A friend mentioned RPL, but that didn’t seem to even have first-class functions… unless I’m mistaken?
thsksbd · a year ago
Im not a CS guy, so I dont know what "first class" means.

I can do whatever to a function. I can use it as an argument. I can return it from another function. I can make a function that modifies functions.

All that w/out doing anything out of the ordinary day to day programing.

ceving · a year ago
You can put functions on the stack.
agumonkey · a year ago
with arrow syntax even

   << a -> << a a * >> >> 'SQUARE' STO
I still can't believe how advance RPL calculators were

pierrebai · a year ago
Reading the example, I really wish the syntax for push and pop had been "<foo" (push foo on stack) and ">bar" (pop from stack into bar). I find the choice of $ and ^ not obvious. Especially since, for me, ^ implies popping, not pushing.
xorvoid · a year ago
You can fork and fix that with sed. Haha.

I decided on using sigils and then my thought-process drifted to Perl/Php, so $ naturally felt like a variable definition (which naturally must pop from the stack). I guess ^ is “push ‘up’ to stack”. But it’s all really arbitrary irrelevant syntax. YMMV.

dandanua · a year ago
'$' is common for interpolation in many languages. It's a good choice.

Awesome language, and it's definitely important from a theoretical point of view. However, you've missed the chance to call it "LiFo" :)

quibono · a year ago
Interesting. I'm not sure about $ and ^ either but I think I'd keep getting confused about which one of < and > meant pushing vs pulling
dugmartin · a year ago
Maybe + for push and - for pop?
pmarreck · a year ago
This looks really neat, although I'm still wrapping my head around it! It's funny how things that are even more fundamentally simple than what has been discovered, can be (initially) harder to reason about!

So you could presumably also write a Lisp interpreter AND a Forth interpreter using it?

(Might as well write a Turing machine interpreter too for the trifecta... assuming one can decide on the syntax...)

That plus some additional functionality to make it more usable in the general sense (adding math functions, string manipulation, maybe some basic I/O) and it might be a VERY interesting instructional tool.

I've heard the term "thunk" but I forget what it means...

kazinator · a year ago
A thunk is a piece of glue machine code that adjusts some pointer (which is imagined to make a "thunk" sound) and then calls the real code.
pmarreck · a year ago
It's a delayed evaluation, as I understand it?
gct · a year ago
A thunk is just a function with no arguments representing a computation. In C++:

  int a=1, b=2; auto thunk = [=]() { return a+b; }

pmarreck · a year ago
so a deferred evaluation, like (in elixir) wrapping a computation in an fn (lambda of 0 arity)
kazinator · a year ago
What has Lisp semantics and a stack with "call by push value" and whatnot is any one of the stack-based virtual machines used for compiling Lisp over the past 60 years.
im3w1l · a year ago
Another recent attempt at a language combining features of Forth and Lisp https://github.com/rickardnorlander/misc/tree/main/cursed_la...

Someone even asked the same question

    ' seems redundant. 'x could just be (x)?
though for that language the answer was that yes it's exactly the same.