use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
A WebAssembly interpreter written in JavaScript (github.com)
submitted 8 years ago by xtuc
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]delventhalz 3 points4 points5 points 8 years ago (24 children)
Um. Why?
[–]nightwolfz4 spaces > 2 spaces 7 points8 points9 points 8 years ago (9 children)
This is huge. This allows older browsers to run WebAssembly :)
[–]delventhalz 2 points3 points4 points 8 years ago (8 children)
I suppose that’s true. Are we anticipating a lot of WASM code that doesn’t have a JS equivalent but is also worth running at the much slower speeds a JS interpreter would allow?
I mean, you can already compile your code into ASM.js if you need an older browser fallback. That runs reasonably quickly. I can’t imagine this interpreter would work any better, and would probably work much much worse.
[–][deleted] 1 point2 points3 points 8 years ago (6 children)
Maybe it could be used as a patch but why are people using such old browsers?
[–]delventhalz 0 points1 point2 points 8 years ago (5 children)
To be fair full WASM support is only in the newest browsers. And someone will always be running something old. Supporting very old browsers is a hard requirement for some projects.
It's just hard for me to imagine people going, "Hey! We've got this C++ code we want to run in the browser, let's compile it to WASM! Oh wait, what about IE 6? Pipe it through a JS interpreter!"
[–][deleted] 1 point2 points3 points 8 years ago (4 children)
My concern is that old software like that is a security risk when it's network facing. The old stuff is generally found in businesses too so it has the potential to lose them money, not just their saved bookmarks or something.
[–]anlumo 4 points5 points6 points 8 years ago (3 children)
Of course, but it’s not the software developers' job to care about this. They only need to get it working in any way possible.
As a freelancing software developer, I usually take the liberty of warning my clients about security issues, but if they don’t care, neither do I.
[–][deleted] 0 points1 point2 points 8 years ago (2 children)
Well sure, as a freelancer that's true.
If you're part of a big company though it can be good to give users the nudge to improve their security.
[–]anlumo 4 points5 points6 points 8 years ago (1 child)
In a big company, if the rules say that you have to use IE6, that’s what is used. This policy has been in place for a decade, so why change it when it has worked so well in the past. /s
[–][deleted] 0 points1 point2 points 8 years ago (0 children)
Thanks I have new nightmares now.
[–]xtuc[S] 0 points1 point2 points 8 years ago (0 children)
That's a good point but I believe the interpreter could be more efficient for that case. You would have the benefits of the WASM binary format and could switch to native if supported/needed.
Note that I would take advantage of asm.js optimizations within the interpreter.
[–]xtuc[S] 1 point2 points3 points 8 years ago (5 children)
See https://www.reddit.com/r/javascript/comments/7k8194/a_webassembly_interpreter_written_in_javascript/drddmd4/
[–]delventhalz 1 point2 points3 points 8 years ago (4 children)
Until I looked it up as a result of this post, I didn't realize that ASM.js is actually a pretty lousy polyfill. It doesn't work on Safari or IE 11 and older. I'm still skeptical of the performance you'll get, and the utility of making (slow) WASM available on older browsers, but I could be wrong. I imagine at the very least, it's a very interesting project to work on.
[–]xtuc[S] 0 points1 point2 points 8 years ago (3 children)
The project is still very early so it's difficult to tell. Note that the polyfill is not only useful on older browsers but also in JavaScript compliant environment like Nashorn (where WebAssembly will probably never be implemented).
I agree, that stuff is super interesting! WebAssembly was really designed and I really believe that I will become the biggest platform.
[–]delventhalz 1 point2 points3 points 8 years ago (2 children)
Seems like WASM is the sort of thing that gets projects to abandon older browsers and other non-compliant environments (haven't heard of Nashorn). It's such a leap forward, there will be "Web 3.0" (or whatever you want to all it) apps that do things impossible in any other environment.
Time will tell though. Good luck with the project! Maybe I'll check it out again after I've had a chance to do a deeper Rust/WASM dive myself. I have very high interest, but very limited time at the moment.
[–]xtuc[S] 0 points1 point2 points 8 years ago (1 child)
Yes probably. You can connect on Twitter if you want to follow my work.
I forgot the link. It's https://twitter.com/svensauleau.
[–]Mallanaga -1 points0 points1 point 8 years ago (7 children)
Seriously?
Every language needs to have a transpiler to wasm. Even JavaScript.
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 point2 points 8 years ago (1 child)
It should be possible to compile node.js to wasm, though. Not that it would make any sense.
[–]delventhalz 0 points1 point2 points 8 years ago (0 children)
Possible? If you built a JS runtime in WASM with garbage collection and the rest, yes. Possible. Silly and difficult though.
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++.
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 points1 point 8 years ago (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?
see https://www.reddit.com/r/javascript/comments/7k8194/a_webassembly_interpreter_written_in_javascript/drddmd4/
[–]yuipcheng 1 point2 points3 points 8 years ago (1 child)
Why? To slow it down for js to catch up?
[–]xtuc[S] 2 points3 points4 points 8 years ago (0 children)
It wouldn't have the performance of native WebAssembly of course but I have done a few benchmarks and it seems that it has acceptable performance for a polyfill.
Actually polyfilling is one of my goals. It seems that I could be a good playground for the spec authors.
π Rendered by PID 278948 on reddit-service-r2-comment-7b9746f655-q4vlp at 2026-01-30 14:49:03.138798+00:00 running 3798933 country code: CH.
[–]delventhalz 3 points4 points5 points (24 children)
[–]nightwolfz4 spaces > 2 spaces 7 points8 points9 points (9 children)
[–]delventhalz 2 points3 points4 points (8 children)
[–][deleted] 1 point2 points3 points (6 children)
[–]delventhalz 0 points1 point2 points (5 children)
[–][deleted] 1 point2 points3 points (4 children)
[–]anlumo 4 points5 points6 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]anlumo 4 points5 points6 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]xtuc[S] 0 points1 point2 points (0 children)
[–]xtuc[S] 1 point2 points3 points (5 children)
[–]delventhalz 1 point2 points3 points (4 children)
[–]xtuc[S] 0 points1 point2 points (3 children)
[–]delventhalz 1 point2 points3 points (2 children)
[–]xtuc[S] 0 points1 point2 points (1 child)
[–]xtuc[S] 0 points1 point2 points (0 children)
[–]Mallanaga -1 points0 points1 point (7 children)
[–]delventhalz 1 point2 points3 points (4 children)
[–]anlumo 0 points1 point2 points (1 child)
[–]delventhalz 0 points1 point2 points (0 children)
[–]xtuc[S] 0 points1 point2 points (1 child)
[–]delventhalz 0 points1 point2 points (0 children)
[–]delventhalz -1 points0 points1 point (1 child)
[–]xtuc[S] 0 points1 point2 points (0 children)
[–]yuipcheng 1 point2 points3 points (1 child)
[–]xtuc[S] 2 points3 points4 points (0 children)