TekMol 60 days ago [-]
I was excited at first. Compile Javascript like code into WebAssembly text format? Zero dependencies? Count me in!

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?

manigandham 60 days ago [-]
Yes, that's the compiler: https://github.com/ballercat/walt/tree/master/packages/walt-...

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/

TekMol 60 days ago [-]

    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?
manigandham 60 days ago [-]
Because different runtimes support different features and performance (like dealing with files and disk access) but I already posted the link for the browser version in that comment.
cousin_it 60 days ago [-]
I think that's not quite what was asked for. What was asked for is one JS file with a function that takes a string and returns a string. Not a node package, not a website. Check out Three.js, it's a big library which can be used as one file three.min.js.
gchq-7703 60 days ago [-]
If you check the `dist` folder within the linked Git repository you can see a `walt.min.js` file[0]. You should be able to include that file and try out the package in your browser in a similar way to how you use `three.min.js`.

[0] https://github.com/ballercat/walt/blob/master/packages/walt-...

rymate1234 60 days ago [-]
Maybe so you can deliver precompiled wasm to a browser rather than having to deliver the source and a compiler?
krapp 60 days ago [-]
You don't need node to compile WASM or deliver it to the browser, either.

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.

derefr 51 days ago [-]
No, the convention is that Javascript projects are distributed as source rather than as "binaries" (single minified JS files.) Source code generally needs a build tool. NPM is a build tool.
codetrotter 60 days ago [-]
> 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.

undershirt 60 days ago [-]
TekMol 60 days ago [-]
Awesome! Thanks man!

This is what makes Hacker News great!

undershirt 60 days ago [-]
Actually, check again! I just updated it to NOT use wabt. Walt-compiler has its own semantic printer, so its output is more readable.

And yes! I think answering these kind of simple questions is important, so thanks for asking them.

TekMol 60 days ago [-]
Even better.

I'm already having fun with it.

simen 60 days ago [-]
It doesn't translate to wasm text format, but to wasm binary format. The walt-compiler (https://github.com/ballercat/walt/tree/master/packages/walt-...) readme shows how to use it to compile text into a a buffer which you can write to disk or instantiate into a webassembly module.
TekMol 60 days ago [-]

    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.
cygx 60 days ago [-]
That tool already exists: https://ballercat.github.io/walt/ - though you have to switch 'tabs' to see the WASM code.
TekMol 60 days ago [-]
Yes, I saw 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.

KenanSulayman 60 days ago [-]
What? Just use wasm2wat [1] and you’ll get the text format.

[1] https://github.com/WebAssembly/wabt

nojvek 59 days ago [-]
Your argument is valid, the QuickStart example isn’t wrong though. Webpack is somewhat the bundling standard in front end. What they showed, I can easily get it working in a large project without a lot of kungfu.

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?

runarberg 60 days ago [-]
These look less like questions about the project and more like feature requests.

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.
pygy_ 59 days ago [-]
Go to https://flems.io/walt-compiler

You can then play with the `Walt` global.

PaulBGD_ 60 days ago [-]
What's the difference between this and something like AssemblyScript?: https://github.com/AssemblyScript/assemblyscript

EDIT: I see that this project actually existed slightly before AssemblyScript. Still seems like two very similar projects.

abuldauskas 60 days ago [-]
I wrote/maintain Walt. This question comes up a bunch.

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.

danShumway 60 days ago [-]
> Walt also has language extensions

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?

burfog 60 days ago [-]
Your project is weird to begin with, and then "knew C already" makes it even weirder. The whole point of WebAssembly was to find some way to get away from JavaScript, and to support languages like C. Here you are, going right back to the JavaScript that we've been trying to escape for the past 23 years.

Also, on your page you say that "A competent Front-end engineer should be able to edit WebAssembly as easily as any other systems programmer." The "any other" seems to imply that a "Front-end engineer" is a "systems programmer". This is typically not the case.

konaraddio 60 days ago [-]
> The whole point of WebAssembly was to find some way to get away from JavaScript

The goal is to "Define a portable, size- and load-time-efficient binary format to serve as a compilation target which can be compiled to execute at native speed by taking advantage of common hardware capabilities...."[0].

[0] https://webassembly.org/docs/high-level-goals/

ramses0 60 days ago [-]
WASM is then the new JVM. Birth and Death of Javascript indeed.
thrower123 60 days ago [-]
Everything old is new again, and the Wheel of Time turns, and ages come and pass, leaving memories that become legend. Legends fade to myth, and even myth is long forgotten when the Age that gave it birth comes again. In one Age, called the third age by some, an Age yet to come, an age long past, a virtual machine specification was created in an attempt to achieve the goal of write-once, run everywhere code. The specification was not the beginning. There are neither beginnings or endings to the turning of the Wheel of Time. But it was a beginning.
pjmlp 60 days ago [-]
Just like CPUs.

In the beginning Assembly became bytecode and CPUs included interpreters via microcode, then everything was supposed to be executed directly by hardware gates, now Assembly has become another form of bytecode and all major CPUs have reverted back to microcode.

Same applies to GPUs.

Everything old is new again, indeed.

kowdermeister 60 days ago [-]
Thanks for bringing some poetry to tech land :)
59 days ago [-]
kristofferR 60 days ago [-]
What a weird argument. C is not "better" than Javascript, it is vastly worse for the vast majority of current Javascript uses - where raw performance is a less important consideration than development time.

Javascript is far from perfect, but it has improved by leaps and bounds the last few years. WebAssembly is great, but a variant of Javascript or other high-level languages will continue to dominate web development, not C. People aren't going to "escape" from Javascript to C, except certain niches where performance is vital.

burfog 60 days ago [-]
I disagree about "better", but...

If you like your JavaScript, you can keep your JavaScript. You have no reason to care about WebAssembly. Why would you build a JavaScript imitation on WebAssembly when you can just use JavaScipt?

WebAssembly is for the rest of us.

abuldauskas 60 days ago [-]
That's the thing though. We are all "us" here. We can all compile whatever we want to WebAssembly, that's the point of WebAssembly. One way of doing things doesn't take away from another.
dtf 60 days ago [-]
It's not a JavaScript imitation. This is a JavaScript-like syntax for writing WebAssembly. Other than that, (excepting the closure helper) it's 1-to-1 WebAssembly.

Not everyone enjoys writing verbose S-Expressions [1], even if it makes for a good canonical format.

If you despise JavaScript so much that you can't bear the thought of something that vaguely looks like JavaScript, then don't worry there are other "skins" for writing WebAssembly [2-4] and it should not be too hard to write your own.

Finally, nobody owns WebAssembly. It's for clever people like yourself just as much as it is for dirty JavaScript programmers like me.

[1] https://developer.mozilla.org/en-US/docs/WebAssembly/Text_fo...

[2] https://github.com/tmcw/wah

[3] https://github.com/serprex/luwa

[4] https://medium.com/cirru-project/webassembly-s-expression-an...

danShumway 60 days ago [-]
You might like a JavaScript-like language but want to get rid of the garbage collector, or work closer to the bare metal than Javascript currently allows.

WebAssembly is for everyone.

abuldauskas 60 days ago [-]
Escaping JavaScript is not a perspective shared by all (most?), though.

It's has been a weird and interesting project, but that's not really a bad thing is it.

Touche 60 days ago [-]
You'll have to excuse HN Guy that assumes that every project on GitHub is done to try and take over the world and not because, you know, learning is fun. So keep on doing weird things with your weird and awesome language.
inferiorhuman 60 days ago [-]
I may be in the minority then: one of the big advantages, for me, of WASM is that I can use not-Javascript in the browser. Some of the issues I have with JS are an artifact of being one of the first things to run in the browser (e.g. atrocious standard library) and some are just baked in poor designs (e.g. implicit type casting, == vs ===).

Oh gosh, let's not forget what happens when you try to use map and parseInt together.

mr_toad 60 days ago [-]
[‘1’,’2’,’3’,’4’,’5’,’6’,’7’,’8’,’9’,’10’].map(d => parseInt(d));

Returns

[1,2,3,4,5,6,7,8,9,10]

JimDabell 60 days ago [-]
Sure, but you're putting a workaround in – there really shouldn't be any need for that no-op arrow function. But you do actually need it in order to drop all but the first arguments.

This is simple, straightforward, and wrong:

    ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"].map(parseInt)
This doesn't work because map() stuffs a counter into the second argument of parseInt(), which is expecting a radix for its second argument. So the iterations of the map go like this:

    parseInt("1", 0)
    parseInt("2", 1)
    parseInt("3", 2)
…and so on, which obviously gives garbage results. JavaScript is littered with these kinds of weird edge cases. Even your example with the workaround isn't 100% reliable, it's browser-dependent – when you have leading zeros in your strings, some browsers will interpret them as octal, and some won't.
gear54rus 60 days ago [-]
so what is your problem with all this? that these functions have both provided a flexible interface for use cases that are not this single one?
kybernetikos 58 days ago [-]
> browser-dependent

Language version dependent rather than browser dependent.

It may seem the same (after all, different browsers implement different versions of the language), but it's a bit different, if you say 'browser-dependent' it makes it sound like there is no standard when in fact, the leading zero behaviour hasn't been the case since ecmascript 5. You'll struggle to find a browser in common use that doesn't support at least ecmascript 5. It's as browser-dependent as the array.map function which was added at the same time.

Your example code would never have the leading 0 problem since you're using array.map and array.map didn't exist in the engines that had that leading 0 'feature'.

inferiorhuman 60 days ago [-]
I'd expect your example to return a syntax error as those aren't single or double quotes. Try:

["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"].map(parseInt);

duckerude 60 days ago [-]
Backticks are used for template literals. Try evaluating `2 + 2 = ${2 + 2}`.
inferiorhuman 60 days ago [-]
Those weren't backticks (`) either. They were "smart" quotes (’ -- you may need a different font to view the differences more readily ’ vs ').
rounce 60 days ago [-]
But you understood what they meant right?
RussianCow 60 days ago [-]
From a quick glance, it looks like AssemblyScript compiles TypeScript, whereas Walt uses its own dialect of JS with WebAssembly types.
sramam 60 days ago [-]
A quick look at a sample .assembly file [0], make it look like a very different language from TypeScript.

That said, the familiar tooling, editor support, are wins over other WASM options.

[0] https://github.com/AssemblyScript/assemblyscript/blob/master...

torch2424 60 days ago [-]
I help out every once and a while on the AssemblyScript team with like issues, docs, and things. And made wasmboy, which uses AssemblyScript: https://github.com/torch2424/wasmBoy

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.

saosebastiao 60 days ago [-]
Apart from the explicit number types (`i32` instead of `number`, etc.) it looks like standard typescript. What looks different to you?
sramam 59 days ago [-]
Incredibly, the segment below is valid TypeScript.

    @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]

__s 60 days ago [-]
I've been going with Lua for writing raw webassembly

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

jnbiche 60 days ago [-]
> Resulting code for a gc looks like this: https://github.com/serprex/luwa/blob/master/rt/gc.lua

Nice! That's a compact gc, perfect for browsers.

daurnimator 60 days ago [-]
> 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?

anonytrary 60 days ago [-]
Lua is fantastic.
ArtWomb 60 days ago [-]
Are people really editing .wat files by hand to eek out the last bit of performance? Seems like you would need instruction level profiling to do it justice

Wasabi: A Framework for Dynamically Analyzing WebAssembly

https://arxiv.org/pdf/1808.10652.pdf

scrollaway 60 days ago [-]
Do web assembly files really have a .wat extension? This can't not be an easter egg reference to the famous talk, right? :)
Touche 60 days ago [-]
Should have gone with .wtf. WebAssembly Text Format.
scrollaway 60 days ago [-]
.wtf will always be Warcraft Text Files for me. Nothing like editing that Config.wtf file when playing WoW...
zoggenhoff 60 days ago [-]
Such polite people. WTF has different meaning for the other kids in the playground.
creatonez 60 days ago [-]
Binary size would probably be the main thing you'd want to optimize for. Which, at least a few months ago when I tried the wasm32 target in rustc, is a big issue.
60 days ago [-]
60 days ago [-]
branksy 60 days ago [-]
Fascinating! Serious question: could this turn JavaScript (technically Walt) into a serious language for scientific computation? That now runs in any browser?

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?

mr_toad 60 days ago [-]
You could just port the C libraries that Python uses.

You might want to check that you’re actually gaining any performance, the JIT compilations of JavaScript aren’t often slow.

dralley 60 days ago [-]
Would it not be easier to take a language with existing libraries (e.g. Julia, C++) and make it compilable to WASM?

Or even figure out how to run a Python interpreter + WASM-compiled C extensions together to be able to use Numpy, Scipy, etc.

pjmlp 60 days ago [-]
Not really, you would be better off running that code as GLSL shaders on the GPU.
jeffmcmahan 60 days ago [-]
This looks great. I've been looking for a project like this for a while - a simple language in which I can write hot code and compile it straight to web assembly for use in existing node and web projects.

However, I wonder whether Walt is markedly faster than JIT-compiled javascript? Have you benchmarked the performance gain?

abuldauskas 60 days ago [-]
I have not, this has been requested quite a bit though. My focus is currently on making sure the toolchain is stable and performant itself. It's likely that the performance of the compiled code is on par with other wasm vs JS comparisons though.
kgraves 60 days ago [-]
Superb! I would love to see native programs being ported using traditional JS to the browser, perhaps this is a step closer for a clone of Photoshop in the open web!

I like the progress of where webassembly is heading! :)

60 days ago [-]
nojvek 59 days ago [-]
This is amazing. Yes! I’ve always wanted something like this.

I wonder if we could make a boiled down typescript language server that would give excellent code completion and squiggles for Walt.

AzzieElbab 60 days ago [-]
Full circle?
iddan 60 days ago [-]
Glad I took part of this project early and got the possibility to focus it to great goals
kabacha 60 days ago [-]
Why? webassembly is there to escape from the godawful syntax and design of javascript...
bgirard 60 days ago [-]
Where did you get that idea? It's not a design goal of WebAssembly: https://webassembly.org/

WebAssembly's goal is to provide a simple VM with performance good enough for the web to compete with native programs and to unlock use cases that are not possible to run efficiently in JavaScript.

The syntax that the developer see is totally irrelevant here.

knocte 60 days ago [-]
He not only mentioned syntax but design too. Clearly JavaScript's lack of int (for example, to mention a design decision of JS) is one of the reasons of its poor performance, not to mention its weak typing approach.
TomMarius 60 days ago [-]
There is no lack of int in Walt.
knocte 59 days ago [-]
So it's not really JavaScript??? lol
TomMarius 59 days ago [-]
Exactly.
porphyrogene 60 days ago [-]
Programming languages are tools, not religions. If a project like this can help people use and understand their tools that is a good thing. Reacting as if the infidel language is defiling the sacred is absurd and indefensible from a practical standpoint.
TeMPOraL 60 days ago [-]
Well yes... unless you realize that ours is a fashion-driven industry, where technical choices are not made based on technical merits but via a popularity contest. From a practical standpoint, complaining about propagation of bad choices is absolutely defensible.

Or, to put in another way: today you don't complain about crap tech pushing out good tech, tomorrow half of the jobs in your field require you work with the crap tech.

zoggenhoff 60 days ago [-]
I'd agree with you except that any language that requires the "let" keyword is absurd and indefensible. And this is one of many religious-like language wars out there.
Chloro 60 days ago [-]
Are you seriously hung up on keywords? Also, you are not required to use "let"...
zoggenhoff 60 days ago [-]
No, but you demonstrated the religious zeal of such a comment quite nicely.
nindalf 60 days ago [-]
If you want to troll you should be more subtle about it. Or at least have the courage to use your main account rather than a throwaway
anonytrary 60 days ago [-]
> language that requires the "let" keyword is absurd and indefensible

I would seriously like to see you defend this viewpoint.

pjmlp 60 days ago [-]
Then you will wipeout a big list of programming languages, given how many use let for assignments.
adrianmonk 60 days ago [-]
While I have similar feelings, I also think the mark of success for WebAssembly will be if it succeeds in freeing developers to do web stuff in the language of their choice.

Even if that choice is a familiar JavaScript-like language, it still proves the point that the web is now open to whatever the developer wants. So in that sense, I applaud and welcome things like this.

Please do port all of most-hated languages to run with WebAssembly and create new ones that I also don't like. It more or less means that languages I love can be ported and that new ones I will love can be created.

knocte 60 days ago [-]
Thanks, I thought nobody would say this...
simonveith123 60 days ago [-]
aikah 60 days ago [-]
So congratulations I guess, you re-invented ASM.js on top of web assembly which was meant to replace ASM.js at first place?
sctb 60 days ago [-]
We detached this subthread from https://news.ycombinator.com/item?id=18190075 and marked it off-topic.
slimsag 60 days ago [-]
Dismissive non-constructive feedback about projects like this is stupid and IMHO makes people not want to post their projects here.

Your statement and question could have been conveyed like this:

> From my perspective this looks a lot like ASM.js implemented on top of web assembly, but web assembly was meant to replace ASM.js?

The difference is that "congratulations I guess" makes your entire statement and question blatantly communicate "what you did is worthless" when clearly the author had _some_ valid reason to do it, otherwise they wouldn't have.

aikah 60 days ago [-]
> Dismissive non-constructive feedback about projects like this is stupid and IMHO makes people not want to post their projects here.

Well, you can interpret my comment as "stupid", which is your right, but it wasn't my intent. And your rebuttal wasn't constructive either. It would have been more useful to highlight the differences between that project and ASM.js. Nowhere in my message I described that project at "worthless", it's your interpretation and it's just wrong IMHO.

StefanKarpinski 60 days ago [-]
The response explained why your post was not great and then elaborated on how you could have done it better. That’s pretty much the text book definition of constructive.
aikah 60 days ago [-]
> The response explained why your post was not great and then elaborated on how you could have done it better. That’s pretty much the text book definition of constructive.

Since when personal attacks are deemed constructive? There is nothing constructive in his patronizing comment. How about one of you formulates a technical rebuttal to my initial statement as I asked and you quit being meta?

Bjartr 60 days ago [-]
You both could've done better in constructing your responses. He explained why yours was lacking, you explained why his was lacking. You both made valid points.

As for actually answering your question, probably only Walt's author could answer that. Unfortunately, due to your condescending choice of phrasing, he may choose to not engage in discussion with you, thinking that you're not sincerely interested in his answer.

I hope he looks past that and does answer you, as I'm sure others are wondering similarly.

60 days ago [-]
59 days ago [-]
kolderman 60 days ago [-]
Doesn't JavaScript compile down to WebAss? Isn't that the point?
jniedrauer 60 days ago [-]
WASM is a very new standard. Some JavaScript implementations do compile to machine code at run time, but JavaScript does not "compile down to WebAss".
fnord77 60 days ago [-]
I'd rather use Rust than javascript 8 days a week
thrower123 60 days ago [-]
I wasted too much time trying to look if there was a way javascript date objects would report there being eight days in a week...
andrew_ 60 days ago [-]
Well, good for you.
xaduha 60 days ago [-]
Let a thousand flowers bloom and all that, but come on. That particular flower is a freaking baobab already. I assume it's mostly for use outside of browsers.
artursapek 60 days ago [-]
> Highlights:

> No C/C++ or Rust required, just typed JavaScript.

That's not a flaw...!

fizzbuzzbazz2 60 days ago [-]
It all depends which of all these ugly langages you are the least uncomfortable with. I hear they even use js for servers now. Rise and fall... lol
DoctorOW 60 days ago [-]
Honestly I thought you referring to Rust as an ugly language would send more replies your way.