3 ms·
I've always felt the "one language" sell was fake news. The amount of difference between JS in the browser and Node.js is much larger than the similarity. The D
by pull_my_finger 5y ago
I've always felt the "one language" sell was fake news. The amount of difference between JS in the browser and Node.js is much larger than the similarity. The DOM and Node.js APIs are big and vastly different in scope and what they accomplish. Add to this all the weird incompatibilities like Node not having fetch, or the multiple accepted module patterns etc it's such a mess. Then you get people telling you JSX is "just JS" also, which is also not true. You have to make all kinds of goofy adjustments to even make it function as HTML.
I do agree that you can pump out sites quickly with a modern JS stack, but I definitely think there is room for improvement and it should be idolized as "good" or the way it _should_ be.
- bern4444 5y agoIt’s very possible and easy to get everything working the same way on the client and server but I agree the whole import vs require support is frustrating. I set my stuff up to always use import syntax over require now which is what typescript works best with. Of course the APIs in node vs DOM are very different. They do very different things but the benefit comes from having the same language support, syntax, type system, and methods. Types can be shared across the client and server so changes on one side are immediately detected on the other. It is annoying there’s no native fetch in Node but there’s a east npm package to support isomorphic fetch (node-fetch) JSX is “just js” in that they are compiled down to simple function calls (React.createElement), there’s just a nicer syntax but there are systems (hyperscript I think) that just export functions like h1(), div() etc that do the same thing.