News for hackers. Stuff that matters.
Re:A WebAssembly interpreter written in JavaScript by kodablah on Wednesday December 13, 2017 @03:18PM (#15917282)
I saw some tests, but WASM edge cases can get pretty complicated (especially around post-unreachable stack validation logic). I suggest "git-submoduling" the stuff from "core" at https://github.com/WebAssembly/spec/tree/master/test. This is a pretty good test suite for both your parser and your interpreter and doesn't require too much work on the part of a harness to support.
Re:A WebAssembly interpreter written in JavaScript by xtuc on Thursday December 14, 2017 @02:53AM (#15920639)
Yes I planned to support the spec core tests (that's why I implemented WAST in the first place).
Re:A WebAssembly interpreter written in JavaScript by kodablah on Thursday December 14, 2017 @03:39AM (#15920796)
Cool. I ran into lots of gotchas when I was doing it. Granted there is a much better written spec now. If you hit any snags, feel free to hit me up (email is on github profile which is on HN profile).
Re:A WebAssembly interpreter written in JavaScript by xtuc on Thursday December 14, 2017 @03:49AM (#15920831)
Ok thanks, can we connect on twitter? https://twitter.com/svensauleau/.

I can see on your GitHub page that you made the famous WebAssembly to JVM, nice job!

Re:A WebAssembly interpreter written in JavaScript by kodablah on Thursday December 14, 2017 @04:08AM (#15920903)
Sorry, I don't do Twitter or FB, though if you want to keep it public, feel free to start a gitter or just open a github issue/discussion and @-mention me.

(Thanks!)

Re:A WebAssembly interpreter written in JavaScript by xtuc on Thursday December 14, 2017 @04:33AM (#15921008)
Ok
Re:A WebAssembly interpreter written in JavaScript by shurcooL on Wednesday December 13, 2017 @03:02PM (#15917132)
Now you just need to compile a JavaScript interpreter from C++ to WebAssembly... Makes me think of “The Birth & Death of JavaScript” talk [1].

[1] https://www.destroyallsoftware.com/talks/the-birth-and-death...

Re:A WebAssembly interpreter written in JavaScript by philplckthun on Wednesday December 13, 2017 @07:46PM (#15919072)
I have bad news for you ;) https://github.com/mbbill/JSC.js

Or good depending on the perspective of course.

Re:A WebAssembly interpreter written in JavaScript by proc0 on Wednesday December 13, 2017 @06:46PM (#15918773)
We need brainfuck in this pipeline somewhere
Re:A WebAssembly interpreter written in JavaScript by flavio81 on Wednesday December 13, 2017 @09:45PM (#15919568)
I'd prefer C-INTERCAL or LOLCODE
Re:A WebAssembly interpreter written in JavaScript by lazyman75 on Thursday December 14, 2017 @04:22AM (#15920965)
Upvote for INTERCAL. Keywords like "please" and "maybe" should be part of every language :)
Re:A WebAssembly interpreter written in JavaScript by egnehots on Wednesday December 13, 2017 @05:04PM (#15918097)
That could be really useful to deploy on browsers without native WASM support. Can you give us an idea of the perfs though?

Since WASM is used for some performance intensive applications it would be useful to know how does this polyfill compare to native WASM /asm.js or regular js.

Re:A WebAssembly interpreter written in JavaScript by xtuc on Thursday December 14, 2017 @02:57AM (#15920653)
I have done a few benchmark but it's still too early to be relevant.

I want to take advantage of the optimization done by the JavaScript VM and asm.js in the future.

Re:A WebAssembly interpreter written in JavaScript by CoryG89 on Wednesday December 13, 2017 @05:26PM (#15918278)
Am I the only one wondering whether or not this was created only because of the irony of a WebAssembly interpreter being written in JavaScript?
Re:A WebAssembly interpreter written in JavaScript by steveklabnik on Wednesday December 13, 2017 @05:43PM (#15918408)
Maybe not, but I wouldn't be sure that that's it; the stated version on the top of the page is an important one, or at least is as long as IE 11 is a thing.
Re:A WebAssembly interpreter written in JavaScript by DiThi on Wednesday December 13, 2017 @07:20PM (#15918959)
Wouldn't it be better to just deploy asm.js alongside wasm? Emscripten can easily generate both, and a simple check can select which script to load.

    if(window.WebAssembly != null){
        loadScript('script.wasm.js');
    }else{
        loadScript('script.asm.js');
    }
Re:A WebAssembly interpreter written in JavaScript by steveklabnik on Wednesday December 13, 2017 @09:04PM (#15919432)
Quite possibly! Only one way to find out.
Re:A WebAssembly interpreter written in JavaScript by xtuc on Thursday December 14, 2017 @02:55AM (#15920646)
Actually polyfilling is only one of my goals. I think that it could work as a good playground for the spec since you can easily try out new things.
Re:A WebAssembly interpreter written in JavaScript by johnhenry on Wednesday December 13, 2017 @03:23PM (#15917329)
Considering that all major [evergreen] browsers support it, what are the use cases for something like this? Adding support to IE? A starting point for polyfilling future versions of WASM?
Re:A WebAssembly interpreter written in JavaScript by MaxBarraclough on Wednesday December 13, 2017 @03:53PM (#15917562)
Fair question. WebAssembly's browser support is indeed already pretty good, as I understand it.

Might be useful for old versions of IE, I suppose.

Re:A WebAssembly interpreter written in JavaScript by xtuc on Thursday December 14, 2017 @02:57AM (#15920658)
Re:A WebAssembly interpreter written in JavaScript by mr_toad on Thursday December 14, 2017 @12:04AM (#15920064)
Lots of corporate desktops are still running IE11 on Windows 7, and they won't upgrade until they absolutely have to.
Re:A WebAssembly interpreter written in JavaScript by TekMol on Wednesday December 13, 2017 @03:25PM (#15917343)
Do browsers that support WASM support reading the text format?

If not, this could be useful to write WASM directly.

In the article, the links under "The parsing is available for the following formats:" are broken. Does anybody know where they should point to?

As soon as it is possible to write WASM directly and have it execute it by the browser, I would start trying it out. I hope somebody will come up with a better textual representation then the currently proposed one with all the parenthesis.

Re:A WebAssembly interpreter written in JavaScript by pjmlp on Wednesday December 13, 2017 @04:14PM (#15917725)
You can already play with WASM directly in the browser.

https://wasdk.github.io/WasmFiddle/

https://mbebenita.github.io/WasmExplorer/

I prefer the explorer one.

The s-exp representation is great for doing compiler development, hence why it was chosen.

Re:A WebAssembly interpreter written in JavaScript by krapp on Wednesday December 13, 2017 @07:13PM (#15918925)
WASM is bytecode and a spec - writing it by hand would make as much sense as writing an executable binary in assembly. You could do it that way, but it kind of defeats the point, and writing anything nontrivial becomes impractical.

Write something in a language that targets WASM and compile to it - it's an easier way of accomplishing the same end result, and that's what it's for.

Re:A WebAssembly interpreter written in JavaScript by xtuc on Thursday December 14, 2017 @02:59AM (#15920660)
Browsers won't support it, that's a good point. Note that WAST (text) is much more bigger than WASM (binary).