11 ms·
Walt: JavaScript-like syntax for WebAssembly
- kgraves 8y agoSuperb! 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! :)
- PaulBGD_ 8y agoWhat's the difference between this and something like AssemblyScript?: https://github.com/AssemblyScript/assemblyscript https://github.com/AssemblyScript/assemblyscript EDIT: I see that this project actually existed slightly before AssemblyScript. Still seems like two very similar projects.
- RussianCow 8y agoFrom a quick glance, it looks like AssemblyScript compiles TypeScript, whereas Walt uses its own dialect of JS with WebAssembly types.
- sramam 8y agoA 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/examples/game-of-life/assembly/index.ts https://github.com/AssemblyScript/assemblyscript/blob/master...
- torch2424 8y agoI 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 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/examples/n-body/assembly/index.ts 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 8y agoApart from the explicit number types (`i32` instead of `number`, etc.) it looks like standard typescript. What looks different to you?
- sramam 8y agoIncredibly, 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]
- abuldauskas 8y agoI 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.
- burfog 8y agoYour 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.
- abuldauskas 8y agoEscaping 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 8y agoYou'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.
- deleted 8y ago[deleted]
- ArtWomb 8y agoAre 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 https://arxiv.org/pdf/1808.10652.pdf
- deleted 8y ago[deleted]
- scrollaway 8y agoDo web assembly files really have a .wat extension? This can't not be an easter egg reference to the famous talk, right? :)
- Touche 8y agoShould have gone with .wtf. WebAssembly Text Format.
- scrollaway 8y ago.wtf will always be Warcraft Text Files for me. Nothing like editing that Config.wtf file when playing WoW...
- zoggenhoff 8y agoSuch polite people. WTF has different meaning for the other kids in the playground.
- creatonez 8y agoBinary 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.
- deleted 8y ago[deleted]
- artursapek 8y ago> Highlights: > No C/C++ or Rust required, just typed JavaScript. That's not a flaw...!
- fizzbuzzbazz2 8y agoIt 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 8y agoHonestly I thought you referring to Rust as an ugly language would send more replies your way.
- fnord77 8y agoI'd rather use Rust than javascript 8 days a week
- thrower123 8y agoI 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_ 8y agoWell, good for you.
- xaduha 8y agoLet 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.
- __s 8y agoI've been going with Lua for writing raw webassembly Assembler setup: https://github.com/serprex/luwa/blob/master/rt/make.lua 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 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
- daurnimator 8y 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/ https://fengari.io/) to run your lua assembler?
- anonytrary 8y agoLua is fantastic.
- jnbiche 8y ago> Resulting code for a gc looks like this: https://github.com/serprex/luwa/blob/master/rt/gc.lua https://github.com/serprex/luwa/blob/master/rt/gc.lua Nice! That's a compact gc, perfect for browsers.
- iddan 8y agoGlad I took part of this project early and got the possibility to focus it to great goals
- AzzieElbab 8y agoFull circle?
- aikah 8y agoSo congratulations I guess, you re-invented ASM.js on top of web assembly which was meant to replace ASM.js at first place?
- slimsag 8y agoDismissive 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 8y 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 8y agoThe 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 8y 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?
- kolderman 8y agoDoesn't JavaScript compile down to WebAss? Isn't that the point?
- jniedrauer 8y agoWASM is a very new standard. Some JavaScript implementations do compile to machine code at run time, but JavaScript does not "compile down to WebAss".
- branksy 8y agoFascinating! 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?
- dralley 8y agoWould 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.
- mr_toad 8y agoYou 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.
- pjmlp 8y agoNot really, you would be better off running that code as GLSL shaders on the GPU.
- kabacha 8y agoWhy? webassembly is there to escape from the godawful syntax and design of javascript...
- porphyrogene 8y agoProgramming 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.
- zoggenhoff 8y agoI'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 8y agoAre you seriously hung up on keywords? Also, you are not required to use "let"...
- zoggenhoff 8y agoNo, but you demonstrated the religious zeal of such a comment quite nicely.
- nindalf 8y agoIf 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 8y ago> language that requires the "let" keyword is absurd and indefensible I would seriously like to see you defend this viewpoint.
- simonveith123 8y agohttps://ds24.io/ETVZIq6X https://ds24.io/ETVZIq6X
- TekMol 8y agoI 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 8y agoYes, that's the compiler: https://github.com/ballercat/walt/tree/master/packages/walt-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/ https://ballercat.github.io/walt/
- TekMol 8y agoIt'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?
- codetrotter 8y 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/ https://ballercat.github.io/walt/ in your browser.
- manigandham 8y agoBecause 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.
- jeffmcmahan 8y agoThis 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 8y agoI 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.
- nojvek 8y agoThis 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.