[HN Gopher] LO - simple WASM native language
___________________________________________________________________
LO - simple WASM native language
Author : glebbash
Score : 112 points
Date : 2024-05-26 16:28 UTC (6 hours ago)
(HTM) web link (github.com)
(TXT) w3m dump (github.com)
| glebbash wrote:
| Hi, it's my first time posting here, just wanted to share the
| language I was working on for some time now.
|
| 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...
| JonChesterfield wrote:
| Straight to wasm is a good choice. You could get something
| close to a native binary by packaging the result with wasm3 or
| similar.
| airstrike wrote:
| you might want to consider changing the title to a "Show HN"
| https://news.ycombinator.com/show
| Lerc wrote:
| Do you have (or plan to support) a Wasm build of the compiler
| so you can compile from within the browser?
|
| Given you have includes I guess you'd need to provide a
| loadFile(filename) callback to provide it with data.
| glebbash wrote:
| Yes. Compiling single files is supported by calling the
| exported `compile` function, example setup here: https://gith
| ub.com/glebbash/LO/blob/60b80d1b325136ce1ceaf4dc....
|
| 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...
| ceronman wrote:
| Very nice project! I love the fact that you have almost no
| dependencies for the compiler. I'm interested in learning how
| to build a compiler for web assembly and your code seems very
| clean, simple and easy to follow. Thanks!
| teucris wrote:
| So far I'm loving this. Would love a language tour doc!
| glebbash wrote:
| Thanks, I will definitely do that once the feature set will get
| stable enough. Don't want to update docs constantly :)
|
| As for now, you can check the examples folder and explore the
| compiler sources, tried to keep everything simple.
| j-pb wrote:
| 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.
| the_duke wrote:
| 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.
| glebbash wrote:
| 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.
| j-pb wrote:
| Thank you for your insights, again very cool project!
| MatthiasPortzel wrote:
| > 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.
| RodgerTheGreat wrote:
| 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.
| ravxx wrote:
| it would be assembly script, the most simple possible typed
| language to make scripts for wasm. its almost identical to js.
| csjh wrote:
| I like that you have a vscode extension already - I'm making a
| similar language project, and you really don't notice how much
| you miss even basic syntax highlighting until it's gone
| arijun wrote:
| Doesn't tree sitter make it pretty easy to add highlighting?
| vlakreeh wrote:
| For editors that support it, yeah. Sadly vscode doesn't
| natively support tree-sitter.
| varispeed wrote:
| This is very nice! What is missing for me is the answer to
| question "Why?"
| glebbash wrote:
| Mostly for recreational programming. And then for exploring
| what the languages with minimal infrastructure could look like.
| ledgerdev wrote:
| Any plans to use wasmgc?
| glebbash wrote:
| I don't see a need for it. Maybe for some higher level
| scripting, but I don't have any plans for that.
| azakai wrote:
| A big advantage of WasmGC is it would allow your binaries to
| be smaller, since you wouldn't need to bundle an allocator
| for heap::alloc and free. Kotlin and Java binaries can in
| some cases be be much smaller than C++ and Rust for that
| reason.
| glebbash wrote:
| Alright, will take a look at it sometime. But the more
| interesting proposal for me right now is the component
| model.
| marianoguerra wrote:
| If you would like to learn how to build your own then check
| https://wasmgroundup.com/
|
| Disclaimer: I'm the co-author
| thomasfromcdnjs wrote:
| How is this project related to the work you do? e.g. instadeq,
| gloodata
|
| Why do you need WASM?
| marianoguerra wrote:
| it's not that related, I like to create
| compilers/transpilers/weird languages, see the "Language
| Projects" section here: https://marianoguerra.github.io/
|
| 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.
| csjh wrote:
| In-browser data analysis is a great place to use Wasm.
| Javascript is great, but larger datasets really benefit from
| SIMD + tighter memory control/controlled memory layouts.
|
| 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
| thomasfromcdnjs wrote:
| Thanks for this answer
| kettlecorn wrote:
| Looks very cool! I can see myself using this for some Wasm
| experiments.
|
| Please add a license so it's clear how people can / can't use the
| project!
| niutech wrote:
| How does LO compare with AssemblyScript?
___________________________________________________________________
(page generated 2024-05-26 23:00 UTC)