Walt: JavaScript-like syntax for WebAssembly
github.com
github.com
I thought: Great! Let's try it! So how do I use it? How do I hand over a string of Walt and get a string of WebAssemblyText back?
I though there is a javascript file somewhere in the project that has a compile() function that does that.
And then I clicked on the Quick Start Guide and it looks much more complicated. It tells me to install node, npm, webpack, walt-compiler, walt-loader... set up a project with a certain structure, create a landing page...
Help :) That's not what I want. I just want a function that takes a string and returns a string.
Would it be possible to just offer a javascript file to be used directly in the Browser? That exports a function which translates your JS dialect to WasmText?
Is that file somewhere in there maybe?
It's written in JS so you'll need node to run it, and npm is a package manager for node so you should use that to install and call it.
If you just want a hosted site to play with code, it's linked right at the top: https://ballercat.github.io/walt/
It's written in JS so you'll need node to run it
I happily run JS in my browser all day. Why do I need node for this code?The next paragraph of the comment you replied to answers that — you don’t, you can use https://ballercat.github.io/walt/ in your browser.
[0] https://github.com/ballercat/walt/blob/master/packages/walt-...
The only reason this "needs" NPM is because it's become convention that all javascript projects need NPM and some related toolchain regardless of their complexity.
It doesn't translate to wasm text format,
but to wasm binary format.
Oh, ok. That is interesting too. But I would have liked to build a tool where I type Walt on the left and see the resulting WASMtext on the right. So this seems to not be a solution for that.It's not the interface that I would like to use. I want to write Walt on the left and instantly see the WasmT on the right.
Also, that tool does not work here. It gives me 'Uncaught ReferenceError: getAST is not defined' as soon as I type something in the code tab.
Perhaps you should try unpkg:
<script src="https://unpkg.com/walt-compile"></script>
And if that doesn't work, perhaps you can submit an issue or a PR.This is what makes Hacker News great!
And yes! I think answering these kind of simple questions is important, so thanks for asking them.
I'm already having fun with it.
If you want the walt->wasm function, it’s usually the loader.
And yes, you can invoke the loader standalone.
Perhaps they should give a much simpler example and then later a webpack example.
It’s open source, open a PR may be?
You can then play with the `Walt` global.
EDIT: I see that this project actually existed slightly before AssemblyScript. Still seems like two very similar projects.
That said, the familiar tooling, editor support, are wins over other WASM options.
[0] https://github.com/AssemblyScript/assemblyscript/blob/master...
But that being said, usually when people are interested in the language, we usually direct them to the "n-body" example: https://github.com/AssemblyScript/assemblyscript/blob/master... . Which kind of looks more typescript-y :)
Also, just to stay on topic, I think walt is awesome. Stoked to see so many projects coming up with a "Wasm for JS devs" approach/story.
@inline
function rot(x: u32, y: u32, v: u32): void {
var a = max<i32>((v >>> 24) - BIT_ROT, 0);
set(x, y, (a << 24) | (v & 0x00ffffff));
}
You must be working on a different set of problems than me to be able to identify this as vanilla TypeScript.Not given the context of a file extension, I would forgive anyone for mistaking this to be some kind of low level driver code and be confused on source language.
It is so impressive that this is valid TS though!
[edit: code formatting]
The two projects are really similar no doubt. I can't speak for AssemblyScript, but my own motivation was simple. I wanted to learn WebAssembly and I wanted an accessible platform to do so with. At the time this wasn't really possible, tools like emscripten took forever to set up and were clunky to use. Plus I knew C already, I wanted to learn WebAssembly instead.
So where Walt is an attempt to write WebAssembly with a familiar syntax, AssemblyScript is an attempt to compile TypeScript to WebAssembly. To do so AssemblyScript comes with many more niceties/features out of the box IIRC, like optional(?) GC for example. Walt makes no such attempts and takes a more DIY approach.
Walt also has language extensions, via customizable syntax and compiler pipeline, where AssemblyScript is a TypeScript compiler more or less. My hope is that this allows for a babel-like situation for WebAssembly in the future via the tooling setup for Walt. I don't think this is a goal of AssemblyScript.
IMO this is a good decision. I much prefer a platform with a small API than I can personally extend over a large platform that has specific customization options or lots of extra features that all just "kind of" solve whatever problem I have.
Reading this makes me more interested in the project than I was before.
One quick recommendation, it was kind of hard to find the documentation for the Webpack free compiler (https://www.npmjs.com/package/walt-compiler). This is purely anecdotal, but I suspect that at least some of the people who are turned on by having a low-level library that doesn't include Typescript niceties will be turned off by seeing the quick-start immediately say to install Webpack. Might be a good idea to have the compiler documentation inside the wiki alongside the quick-start?
Assembler setup: https://github.com/serprex/luwa/blob/master/rt/make.lua Resulting code for a gc looks like this: https://github.com/serprex/luwa/blob/master/rt/gc.lua
& it leaves the full Lua language at my disposal for metaproramming. At the end of a day a human usable assembler needs to be a macro assembler
It'd be neat to have a JS macroassembler, could then have the host browser runtime compile wasm modules dynamically
Use fengari (https://fengari.io/) to run your lua assembler?
Nice! That's a compact gc, perfect for browsers.
Wasabi: A Framework for Dynamically Analyzing WebAssembly
E.g. Python is used a lot together with NumPy/SciPy, but for performance the actual computation in NumPy/SciPy is done in C since Python is too slow. Would it be possible to create Walt-native versions of NumPy and SciPy... e.g. NumWalt and SciWalt? Or even Jupyter notebooks based on Walt?
Or even figure out how to run a Python interpreter + WASM-compiled C extensions together to be able to use Numpy, Scipy, etc.
You might want to check that you’re actually gaining any performance, the JIT compilations of JavaScript aren’t often slow.
However, I wonder whether Walt is markedly faster than JIT-compiled javascript? Have you benchmarked the performance gain?
I like the progress of where webassembly is heading! :)
I wonder if we could make a boiled down typescript language server that would give excellent code completion and squiggles for Walt.
> No C/C++ or Rust required, just typed JavaScript.
That's not a flaw...!