LO – simple WASM native language
github.com
github.com
I've been working on integrating it with WASM-4 runtime this past week. And with minimal changes to the compiler I created this demo game: https://rawcdn.githack.com/glebbash/LO/da8305293f5438967619e...
Game source here: https://github.com/glebbash/LO/blob/main/examples/test/demos...
Given you have includes I guess you'd need to provide a loadFile(filename) callback to provide it with data.
For includes to work compiler uses WASI which can be implemented in the browser. LO playground and VSCode extension use this approach. Playground link: https://glebbash.deno.dev/lo-playground/ and source: https://github.com/glebbash/glebbash.dev/blob/main/static/lo...
I can see some problem here. Probably, it means the author is under heavy influence of the implementation language, that limits their thinking and creativity scope to the concepts of that language.
A single individual is likely to miss a lot of edge cases that a larger organisation (like the Rust foundation) has thought of while creating the language.
In that sense, I believe following the conventions created by a large and well-known entity is likely to produce better results.
You would write a compiler in the language that is the closest to your perfect. Trying to fix the original language by making a "clone" of it and adding/removing features to your liking.
That is what I want to change here by making a very simple language that if someone would like they could just fork it and add/remove the needed features instead of building one from scratch.
If this idea won't work then at least a very simple compiler would be a good learning resource, so a win win anyways.
If someone has some particular domain problem to which they need to introduce the new programming language, then, probably, it should look somehow different to all existing languages, otherwise they would be used.
Alternatively, the motivation could be: OK I need ExistingLanguageX(-alike) but in the domain/environment where it's not present yet, for example, WASM.
The motivation question is always of interest to me since it allows to judje for the long-term perspectives of the project.
However don't take this as a discouragement rant, learning case is a good motivation/raison d'être too.
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.
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.
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...
I think the superset of WAT idea is very viable and someone more comfortable with s-expressions should explore that for sure.
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.
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.
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.
https://developer.mozilla.org/en-US/docs/WebAssembly/Underst...
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.
And is it intentional that the repository does not have a LICENSE file, or do you intend to open-source (by OSI definition) it?
Hmm, I haven't thought about it the license actually, I would default to MIT, but wanted to keep the number of files minimal in repo, hehe.
Will figure it out asap, thanks.
Disclaimer: I'm the co-author
Why do you need WASM?
But there's a relation, two years ago I prototyped a thing that tried to make a headless version of instadeq that could run in the browser and the server, the idea was a dataflow language where the data was represented as apache arrow tables where filters and transformation expressions where compiled to wasm. The prototype kind of worked and I had a lot of fun, I thought about sharing the fun by writing a small book about creating 10 toy languages that compiled to Wasm, I shared the idea with Patrick, he said he was thinking about something similar and the idea evolved into the current book.
Some interesting data-related Wasm projects:
- DuckDB Wasm | https://github.com/duckdb/duckdb-wasm
- Row Zero | https://news.ycombinator.com/item?id=39551064
- PGLite | https://github.com/electric-sql/pglite
Please add a license so it's clear how people can / can't use the project!
Here is the source for the allocator: https://github.com/glebbash/LO/blob/81f96bb09e3a0b1455b32497...
It also links to where I learned how to build the "proper" allocator from scratch.
As for now, you can check the examples folder and explore the compiler sources, tried to keep everything simple.