37 points•dverlaeckt80•1 day ago•22 comments•

22 comments

veltasabout 13 hours ago
I think the first question I've got for JavaScript Forths is how you'd handle addresses, bytes, etc., because that's a staple of any conventional Forth, necessary to create tables, arrays, and handle strings. There are lots of ways of doing it but there are some nasty compromises required for a more standard-looking Forth.
PaulHouleabout 8 hours ago
A FORTH in Javascript should do what Clojure does for Java.

The object on top of the stack should be a Javascript value, numbers are all doubles, and you can use strings, arrays, objects-as-dicts and in fact ordinary objects you could write something like

   >> {"a": [1, 2], "b": "hello" }

   >> DUP

   >> "a" GET{ 0 GET[

   >> .

   1

   >> "something" "c" PUT{

   >> .

   {"a": [1, 2], "b": "hello", "c": "something" }
You could use all the metaprogramming tricks you use in other FORTHs, be able to do anything Javascript can do, I don't think it would be too hard to unpack the stack and turn a word that takes N parameters from the stack into a Javascript function the JS compiler can make fast

There is some precedent:

https://www.forth.org/svfig/kk/11-2019-O'Connor.pdf

I just realized there is exception handling in FORTH now

https://forth-standard.org/standard/exception

and wonder if that could be harmonized with JS exceptions

This strategy though competes with writing a Lisp which gives you better metaprogramming.

terminalcommandabout 8 hours ago
What about writing primitives using WASM?
jstanleyabout 13 hours ago
What about an array of numbers? What are the nasty compromises?
veltasabout 10 hours ago
Well if the array of numbers are bytes then that has a pretty significant overhead, and losing a lot of performance for dealing with larger numbers or floats even. If it's not then you're complicating handling of strings and writing off most conventional forth code by not using byte addressing. Etc.
shaknaabout 11 hours ago
Some Forths work by directly writing machine code. You need to add a fair bit of machinery to be able to turn a JS number array into an executable piece of memory that can be hotpatched into other pieces.
bitwizeabout 21 hours ago
"Writing things in a programming language" now seems to have the same quirky old-internet charm as "Flash games".
pjmlpabout 14 hours ago
Unfortunely, I forsee eventually LLMs will become good enough to deliver the 4GL initial vision, we are already seeing that take shape in iPaaS products, or code generation that is as readable as minified C code for IOCCC entries.
e12eabout 10 hours ago
Why unfortunately - if they actually deliver?

I'm rather exited by the prospect that everyone will be a developer - and so actual users, not merely consumers, of computers.

boomlindeabout 6 hours ago
"Not seeing a comment about LLMs on a HN item that has nothing to do with LLMs" now seems to have the same quirky old-internet charm as "marquee tags".
e12eabout 3 hours ago
Do you mean to say comments on LLMs - where not warranted - is about as welcome as marquee tags were?

Or do you genuinely feel such comments are missing?

I kind of agree with the first - and yet, I have an LLM related comment.

Just the other day I accidentally implemented a Forth - due to Google's LLM (search) result thingy - and its sort of interesting to contrast with this (ops) human written essay.

https://hypertekst.net/forth/

Fair warning - my current homepage is an experiment drenched in AI - at best it's probably an acquired taste.

It's not intentionally terrible, however.

bitwizeabout 2 hours ago
Sorry mate, but that article was from 2024, which means it's a relic of a different world which has since passed away.

Read the full thread on Hacker News →

Related stories