Re:WebContainers: Run Node.js natively in the browser
by oolonthegreat on Thursday May 20, 2021 @02:02PM
(#27224738)
totally lost newbie here: but what is the difference between running javascript on the browser and running node.js on the browser?
[ Parent
| on HN ]
Re:WebContainers: Run Node.js natively in the browser
by Epskampie on Thursday May 20, 2021 @02:14PM
(#27224930)
This is going full inception mode. Nodejs is compiled to wasm (like assembly for your browser), and then loaded inside the browser, which can then run javascript.
So a full JS engine is loaded, completely separate from the built-in one.
Re:WebContainers: Run Node.js natively in the browser
by ridiculous_fish on Thursday May 20, 2021 @05:22PM
(#27227459)
node uses v8. Is the idea that v8 is being compiled to wasm? That seems implausible though it would be amazing if true. Or is there another engine?
My assumption was that the node APIs are simply being exposed to v8.
Re:WebContainers: Run Node.js natively in the browser
by oolonthegreat on Thursday May 20, 2021 @02:41PM
(#27225318)
yeah that's what I gathered: javascript already runs on the browser, then we got node.js because people liked javascript and wanted to run it natively, and then finally we got this which allows us to run node.js on the browser again? it looks to me like we've gone full circle with extra overhead :D but I guess people have reasons to run node.js on the browser and not javascript so idk
Re:WebContainers: Run Node.js natively in the browser
by mindblock on Thursday May 20, 2021 @02:59PM
(#27225562)
I guess the idea is to access some Apis that are not present in the browser, like fs. This was mentioned in a question to StackBlitzs CEO, but he seems to be an AI that just pastes the same text over and over again.
Re:WebContainers: Run Node.js natively in the browser
by kllrnohj on Thursday May 20, 2021 @08:10PM
(#27229045)
> I guess the idea is to access some Apis that are not present in the browser, like fs.
That's why electron exists. But this can't do that, it's still limited by the APIs that are present in the browser. It's seemingly just full-overhead for... some... reason?
Re:WebContainers: Run Node.js natively in the browser
by asmos7 on Thursday May 20, 2021 @02:13PM
(#27224902)
basically node exposes all these other APIs like reading a file from disk. Browser also has APIs like detecting when the page is fully loaded that wouldn't be available on Node. What JavaScript syntax is supported can also vary between Node and browsers.
Re:WebContainers: Run Node.js natively in the browser
by des1nderlase on Thursday May 20, 2021 @02:54PM
(#27225484)
WASM cannot magically load from disk, there is browser protection, right?
Re:WebContainers: Run Node.js natively in the browser
by Ajedi32 on Thursday May 20, 2021 @03:23PM
(#27225828)
It can't access the file system, but it could implement an API that emulates a file system inside the browser sandbox. Presumably that's what they're doing here.
Re:WebContainers: Run Node.js natively in the browser
by kllrnohj on Thursday May 20, 2021 @08:11PM
(#27229049)
But you can do that same API emulation in regular browser JavaScript, too. What's the WASM intermediate buying here?
Re:WebContainers: Run Node.js natively in the browser
by maple3142 on Thursday May 20, 2021 @09:35PM
(#27229580)
I think it is more complicated to emulate those api in normal browser environment compared to emulating some OS api for running node.js.