4 ms·
totally lost newbie here: but what is the difference between running javascript on the browser and running node.js on the browser?
by oolonthegreat 5y ago
totally lost newbie here: but what is the difference between running javascript on the browser and running node.js on the browser?
- asmos7 5y agobasically 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.
- des1nderlase 5y agoWASM cannot magically load from disk, there is browser protection, right?
- Ajedi32 5y agoIt 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.
- Epskampie 5y agoThis 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.
- oolonthegreat 5y agoyeah 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
- mindblock 5y agoI 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.
- kllrnohj 5y ago> 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?
- deleted 5y ago[deleted]
- ridiculous_fish 5y agonode 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.