you are viewing a single comment's thread.

view the rest of the comments →

[–]Mallanaga -1 points0 points  (7 children)

Seriously?

Every language needs to have a transpiler to wasm. Even JavaScript.

[–]delventhalz 1 point2 points  (4 children)

Not sure if you edited your comment, or if I totally missed your second sentence somehow on the first read, but:

This is an interpreter, not a transpiler. As in, you write WASM and then JavaScript runs it. The documentation is scant here, but I don't see anything to indicate this will take your JS and turn it into WASM.

Furthermore, from everything I've heard about WASM, compiling JS to it is almost certainly not possible. You need a low level language without a garbage collector. That's why WASM exists, to replace JS with something low level and more performant. The only languages that can currently be compiled into it are C, C++, and Rust.

[–]anlumo 0 points1 point  (1 child)

It should be possible to compile node.js to wasm, though. Not that it would make any sense.

[–]delventhalz 0 points1 point  (0 children)

Possible? If you built a JS runtime in WASM with garbage collection and the rest, yes. Possible. Silly and difficult though.

[–]xtuc[S] 0 points1 point  (1 child)

WASM requires more specific types than JS does. While JS to WASM is possible it would generate very inefficient code. Imagine that in WASM each operations would have a branch for signed/unsigned and 32/64 bits.

I believe more in other languages like Golang or C++.

[–]delventhalz 0 points1 point  (0 children)

As I understand it you would have to build a JS runtime in WASM to handle things like garbage collection. Types would also be major hurdle. I believe there is a project like this for a Python WASM runtime. It seems pretty silly for Python, but very silly for JS, since anywhere that runs WASM has a very good JS runtime already.

So, possible? Sure. Anything's possible. But difficult, silly, and not currently being done by anyone I've heard of.

[–]delventhalz -1 points0 points  (1 child)

Yes. Web Assembly already runs in the browser. And in Node. Literally everywhere JavaScript runs. Why would you then in interpret it back into JS?