What does HackerNews think of walt?
:zap: Walt is a JavaScript-like syntax for WebAssembly text format :zap:
> Self-contained toolchain: No emscripten, binaryen, wabt, etc.
Tangent: I am sincerely surprised by how few languages seem to do this. I know of Walt and... that's it (although I am sure there are more). I'd expect there to be more experimental small languages targeting WASM directly at least.
https://github.com/AssemblyScript/assemblyscript
https://github.com/FantasyInternet/poetry
https://github.com/ballercat/walt
https://github.com/MichaReiser/speedy.js
Unlike Rust, which has excellent support for wasm output but wasn't created with wasm in mind, the above languages appear to have been created specifically with wasm as the native compile target.
Also, there's an excellent curated list of languages that compile to wasm:
Eh, not really: you could write the compiler in any language that compiles to JS, then use the compiled output as your compiler. In the case of TypeScript or PureScript you could basically write a self-hosting compiler this way.
Walt is a compiles-to-WASM language that has partialy done so[0]. Its compiler written in JavaScript, and the generated compiler is also JavaScript. While not self-hosting, the guy developing it has rewritten parts of it in WASM to figure out what the best language design for strings and related JavaScript interop would be.
> which is not particularly efficient for this kind of task that benefits from parallelization
First of all, isn't WebPack written in JavaScript? Seems to do just fine.
Also, if we are talking about a somewhat modern browser that supports Web Workers parallelization is perfectly viable, no? Add Web Assembly and TextEncoder/TextDecoder in the mix and things could get even faster[1][2][3].
(The main performance issue I see is that due to SharedArrayBuffers being disabled (for now), each worker would need its own Uint8Array copy of the source input[4])
> Can we dump it into a file and load it programatticaly? I would be surprised if we could.
Saving a file is easy these days, just use a Blob[5].
> Eval() the output? Not without some serious security checks that would further compromise performance.
Creating Function object works. It just requires a string as input. I also don't see why this would be more insecure than compiling the same source string ahead of time - you end up running the same code. This isn't the typical user-context in which eval is dangerous.
> So I believe there is no motivation in not pre-compiling and distributing the result dist code.
You are arguing this from a technical point of view, which misses the entire point. Namely, that client-side compilation allows for browser-based apps, demos, and sharing. It greatly lowers the threshold to trying things out.
You may dislike CoffeeScript, but being able to try it out in the browser is quite a good sales pitch[6].
For a more ambitious example: Observable is a notebook environment similar to IPython, but for JavaScript, and with one of IPython's biggest quirks removed: cells track dependencies on other cells and re-evaluate as necessary[7]. The server is there for cloud storage and remote collaboration, allowing you to instantly share the notebook. However, I think it does most, if not all of its compilation client-side, since it still works when you are temporarily off-line (also, Jeremy Ashkenas is part of the developer team).
The aforementioned compiler for Walt can easily run in the browser, so last year I tried combining the two. It took me only a couple of hours to get it working[8].
Of course, you lose the benefit of a developer environment made for the language (but IIRC supporting compiles-to-JS languages is on the long-term Observable roadmap), but still: being able to quickly try out some simple WASM code without needing anything except a modern browser is quite powerful.
[0] https://github.com/ballercat/walt
[1] https://dzone.com/articles/webassembly-web-workers
[2] https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder
[3] https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder
[4] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
[5] https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob
[6] https://coffeescript.org/#overview
[7] https://beta.observablehq.com/
[8] https://beta.observablehq.com/@jobleonard/compiling-walt-in-...