0: https://developer.mozilla.org/en-US/docs/Web/API/console/log
https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder...
https://developer.mozilla.org/en-US/docs/WebAssembly#browser...
It's worth noting this isn't Node's fault: most Node APIs existed before there were browser equivalents and adding browser compat now is much harder for Node than for Deno which is starting from scratch.
Is this a fact or a personal feeling? Any links to back up this statement?
What's the point of implementing APIs like WebGPU and localstorage in a non-browser environment? I get WHATWG streams, esm, fetch and WebCrypro though.
You could save the state of a discord bot across restarts for example.
> The WebGPU API gives developers a low level, high performance, cross architecture way to program GPU hardware from JavaScript.
> GPUs allow programmers to make some numerical algorithms highly parallel. This is useful beyond rendering graphics and games. Effective use of GPUs in Machine Learning has enabled more complex neural networks
- https://deno.com/blog/v1.8#experimental-support-for-the-webg...
Localstorage is admittedly a bit niche, but works well as a way to bypass the need to get generic read/write permissions for the filesystem for a config file. (Deno implements a permission model similar to the web where you start with nothing and must request / have pre-granted access to resources like files/network/env/subprocess, and this access can be granular to specific files/directories/host+port combos)
fetch: Browser fetch didn't exist when NodeJS introduced its http built-ins. Many NodeJS libs are built on top of http built-ins, so replacing them would be a nightmare. Adding browser fetch on top of the existing http built-ins would similarly just give NodeJS a massive API surface area with cconfusingly duplicated functionality.
ESM + web import semantics: NodeJS was part of the "commonjs" movement that invented Javascript module importing. Module imports are an incredibly complex problem and hard to get right. Browsers took the hard-learned lessons from commonjs & nodejs and redesigned better modern APIs. NodeJS has been slowly trying to add support for the much improved browser web import semantics, but doing so while maintaining backward compatibility with their radically different commonjs APIs is a nightmarish challenge (they're working on it though, progress is good).
WHATWG streams: similar story to the import/commonjs situation. NodeJS basically "invented" streams in JS, and the WHATWG API is a newer design based on NodeJS lessons.
WebCrypto: Sibling comment is incorrect here actually: NodeJS & Deno both support this[0]
- ESM modules are challenging to mock or monkeypatch
- I feel like the ESM implementation is more "magic" than require. I definitely would say I understood require better.
- Many esm features are still behind flags e.g. importing a .json file.
I'd guess that by the time Deno gets really good, Nodejs achieved same level of compatibility.
> I definitely would say I understood require better
ESM modules are in many ways "harder" to use than commonjs, but I think this comes down to something slightly intangible but very similar to the static-typing -vs- duck-typing discussion (duck-typing is more obviously intuitive and quick-to-do-what-you want, but static-typing has more wide-reaching architectural benefits for scaling projects).
CommonJS is a more "intuitive" design: what you might expect someone to design first-time-around. ESM is a more thought-through design: the initial "hurdles" to its use bring long-term benefits.
> ESM modules are challenging to [...] monkeypatch
This seems like a feature though
> I feel like the ESM implementation is more "magic" than require
How so? I'd say I feel the opposite.
> importing a .json file
Is this supported by browsers or is it a NodeJS extension?
This is a node extension. It is coming to browsers in form of import assertions. See https://github.com/tc39/proposal-import-assertions
Just for anyone tracking progress, the actual feature proposal is here: https://github.com/tc39/proposal-json-modules - the assertions proposal is just a security check on top of such modules.
[0] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
[1] https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
Edit: as others have pointed out, APIs that are implemented in Node.js are listed on MDN.