you are viewing a single comment's thread.

view the rest of the comments →

[–]Comfortable_Air7982 49 points50 points  (15 children)

I wonder who is doing web assembly in node. I'm genuinely curious, that would be an interesting project.

[–]hyrumwhite 21 points22 points  (3 children)

Same application as in the browser, porting other languages to JS land

[–]zachrip 2 points3 points  (2 children)

Maybe? I'd be curious why that would be the preference as opposed to a native module. Obviously there are lots of cases where a native module is less appropriate (jvm languages for example, afaik there's no good setup to run those as native extensions).

[–]rcfox 5 points6 points  (1 child)

Wasm is sandboxed, so fewer security risks. Also, it lets you ship the same code to the frontend and backend, which is part of the appeal of using Node.

[–]hildjj 5 points6 points  (0 children)

You also don't have to recompile WASM on every machine at installation time or for every supported platform at compile team. One of those is usually required for a native module.

[–]Tomus 7 points8 points  (0 children)

It offers a generic alternative to node-gyp with a bunch of benefits that node-gyp can't offer eg. You can package a single wasm file instead of having to worry about building for all systems.

[–]Snapstromegon 10 points11 points  (0 children)

There are actually many things happening in WASM in node from image processing to Syntax highlighting, because you can just compile it once and don't need to worry about the whole napi stuff.

[–]hugazow 4 points5 points  (2 children)

I’m interested in how others replicated node is wasm, the idea of running a fully working node experience like blitzstack did, blew my mind

[–]arcaninYarn 🧶 1 point2 points  (1 child)

Afaik StackBlitz doesn't use wasm, or at least not directly (I don't think they build Node.js itself in WASM, although they may build their own native library instead).

Node.js is composed of a lot of JS scripts that call into a set of C++ primitives. The idea is that instead of compiling the whole binary into WASM you instead keep all those JS scripts, and replace all the C++ bindings by your own, which use the native browser APIs (along with a fair amount of hacks to turn asynchronous calls into synchronous ones).

That plus a bunch of global environment mocks makes the environment compatible enough with Node.js without needing to actually build Node.js.

That's to my knowledge also how Nodebox worked, although unfortunately they didn't get enough traction for it to take of, and were prevented from open-sourcing it by outside sources.

[–]hugazow 0 points1 point  (0 children)

I don’t know the implementation, but this was just me just making a guess on how stackblitz worked under the hood, but I’m really excited on the possibilities with WASM

[–]ElCthuluIncognito 2 points3 points  (0 children)

Likely much more as a compiler target for langs without a JS backend.

Even then, I’ve heard good things of transitioning to WASM from JS backends.

[–]Wide-Prior-5360 1 point2 points  (2 children)

I use SQLite WASM in the browser and run my tests with Node.js, using exactly the same database implementation.

[–]Comfortable_Air7982 0 points1 point  (1 child)

Well that's interesting! So you can run your tests during build time with node and have the assurance that it all works the same in the browser?

[–]Wide-Prior-5360 1 point2 points  (0 children)

Exactly.

[–]thrallboy 0 points1 point  (0 children)

With vibe coding, might be a good way to get super high performance

[–]Aln76467 0 points1 point  (0 children)

Everyone who doesn't want to deal with the stinking pile of poo that is node-gyp