News for hackers. Stuff that matters.
Re:LO – simple WASM native language by j-pb on Sunday May 26, 2024 @02:05PM (#40484125)
Very cute project!

I personally wouldn't call anything Rust based "simple" (I'm not trying to hate on Rust, it's my daily driver.), so I have to ask: Wouldn't be the simplest possible wasm language, a small macro system for WAT, that bootstraps a slightly more highlevel lisp dialect?

Wasm already seems like an increadibly high-level language, given that it's a low-level compilation target.

Re:LO – simple WASM native language by the_duke on Sunday May 26, 2024 @02:15PM (#40484189)
I don't see how WASM is that high level. It doesn't have types except numbers (ignoring reference types and the GC proposal), which makes it lower level than LLVM IR. The control flow constructs are also much closer to SSA form than anything viable for humans.

If you ever try to write WAT by hand you realize that it's very much a compilation target, not something you'd ever want to manually write.

Re:LO – simple WASM native language by j-pb on Sunday May 26, 2024 @08:06PM (#40486438)
Unlike LLVM, control flow is actually structured, no arbitrary jumps, functions, tables, real harvard separation of code and data.

The restriction to only number types, is more a byproduct of trying to keep the 1.0 spec as mvp as possible, and reference types are gonna be a big shift in that regard.

I mean compare these two. One is a (very low level) language, the other is (high level) assembly.

https://developer.mozilla.org/en-US/docs/WebAssembly/Referen...

https://mapping-high-level-constructs-to-llvm-ir.readthedocs...

Re:LO – simple WASM native language by MatthiasPortzel on Sunday May 26, 2024 @02:31PM (#40484302)
> a small macro system for WAT, that bootstraps a slightly more highlevel lisp dialect

Lisp traditionally has immutable data structures and a garbage collector, in which case I would consider it more complicated than LO.

I would be very interested if it’s possible to create an extremely simple garbage collector or an ergonomic Lisp that isn’t garbage collected, but a solution doesn’t spring to mind.

Re:LO – simple WASM native language by RodgerTheGreat on Sunday May 26, 2024 @05:06PM (#40485393)
A classic mark-and-sweep GC for a heap of uniform structs (like cons-pairs) can be implemented in a few lines of code. Garbage collection is not inescapably complicated, it just gets more challenging as you impose more constraints: multithreading, generations, compaction, minimizing bookkeeping overhead, etc.
Re:LO – simple WASM native language by j-pb on Sunday May 26, 2024 @08:11PM (#40486473)
While I'm a huge fan of immutable persistent datastructures, I don't think that they are a neccesity.

And linked lists with reference counting are really easy to do, and don't have any leaks if you don't allow cons cell abuse. (which would mess with immutablity anyways)

You could also do linear types like carp [0], or you could just do manual memory management.

I feel like most people will call something with macros and s-expressions, a reasonable, if brutalist, lisp.

0: https://github.com/carp-lang/Carp

Re:LO – simple WASM native language by koito17 on Monday May 27, 2024 @01:24AM (#40487816)
> Lisp traditionally has immutable data structures

Can you provide a source for this? Common Lisp and its predecessors certainly do not have immutable data structures out of the box. The usual data structures are cons cells, lists (composed of cons cells anyway), vectors, and hash tables.

> I would be very interested if it’s possible to create an extremely simple garbage collector or an ergonomic Lisp that isn’t garbage collected, but a solution doesn’t spring to mind.

PreScheme immediately comes to mind for me as does ulisp. The latter in particular is designed for microcontrollers with limited memory.

Re:LO – simple WASM native language by pjmlp on Monday May 27, 2024 @03:49AM (#40488617)
That much be a very special kind of Lisp, given the amount of variations since the Lisp 1.5 Programmer's Manual came to be.
Re:LO – simple WASM native language by davexunit on Monday May 27, 2024 @07:54AM (#40489949)
Pairs in Lisp are mutable, traditionally, and there are other mutable data types like vectors. For targeting wasm only there's no need to figure out a GC solution as that is something the host provides in wasm 2.0.
Re:LO – simple WASM native language by sn9 on Monday May 27, 2024 @06:37PM (#40495444)
You could probably do something similar to what Roc is doing: https://www.roc-lang.org/
Re:LO – simple WASM native language by glebbash on Sunday May 26, 2024 @02:23PM (#40484244)
That was how it started actually, I wanted to make a superset of WAT. But then I switched to a more familiar C-like constructs and that gave me a big boost in productivity.

I think the superset of WAT idea is very viable and someone more comfortable with s-expressions should explore that for sure.

Re:LO – simple WASM native language by j-pb on Sunday May 26, 2024 @02:57PM (#40484494)
Thank you for your insights, again very cool project!
Re:LO – simple WASM native language by ravxx on Sunday May 26, 2024 @02:31PM (#40484304)
it would be assembly script, the most simple possible typed language to make scripts for wasm. its almost identical to js.
Re:LO – simple WASM native language by j-pb on Sunday May 26, 2024 @08:19PM (#40486500)
While that may be easy it's definitely not simpler than WAT.

https://developer.mozilla.org/en-US/docs/WebAssembly/Underst...

Re:LO – simple WASM native language by pjmlp on Monday May 27, 2024 @03:52AM (#40488634)
Yes, this would be similar approach how Lisp Machines, and Interlisp, came to be.

Low level forms for systems programming, and then everything else was built on top of it.

Picking something like "An Incremental Approach to Compiler Construction", but instead of Scheme, stay in WAT and move from there, adding features.

http://scheme2006.cs.uchicago.edu/11-ghuloum.pdf

Re:LO – simple WASM native language by davexunit on Monday May 27, 2024 @07:50AM (#40489929)
Re:LO – simple WASM native language by pjmlp on Monday May 27, 2024 @07:54AM (#40489947)
Indeed.