3 ms·
Ultimately, it's because it's easily approachable and it mostly works. You can learn JS and do stuff on both node and the browser. That's incredibly powerful.
by TheAceOfHearts 10y ago
Ultimately, it's because it's easily approachable and it mostly works. You can learn JS and do stuff on both node and the browser. That's incredibly powerful.
Debugging node has gotten much better as of the last year. [0] You can use Chrome Dev Tools to debug node! I'll admit I've had limited experiences in this area, but so far Chrome Dev Tools has provided one of the best debugging experiences I've had. The killer feature is that it's easy to get started and gradually pick more stuff up as you go along.
JS syntax sucks? That's subjective. After learning functional languages like Elixir and Haskell, I agree that JavaScript is lacking many nice features. I don't hate or dislike JavaScript, though. To help solve this, have you tried out macros? [1] I'll admit I've only looked lightly into the feature and I haven't given it a very serious try, but it looks quite promising.
NPM is filled with a lot of junk. That's pretty accurate. You need to be incredibly diligent when pulling in dependencies. Make sure your dependencies are well tested and not bloated and overly complicated. Have you had a better experience with other languages? I can't say I've had any more luck with other languages. From an outsider's perspective, I think Go and Rust seem to be maturing quickly, but I haven't used either seriously enough to answer with confidence. If I'm hacking something together, I think using node is an amazing choice; if I'm looking for incredibly long-term support, I'd probably use Java (as much as I dislike it).
[0] https://nodejs.org/api/debugger.html#debugger_v8_inspector_integration_for_node_js https://nodejs.org/api/debugger.html#debugger_v8_inspector_i...
[1] http://sweetjs.org/ http://sweetjs.org/
- throwayedidqo 10y agoI'm partial to Java for a lot of reasons. That aside I still think my criticisms of JS syntax, NPM, and debugging are valid. Let me explain a bit more though. The biggest problem with JS syntax is not dynamic typing, it's a startling lack of consistency. For example .ForEach vs "for in" vs "for as" vs manually looping over properties. That's at least 4 loop types made for looping over object lists/properties. Checking for undefined is convoluted, the crockerford privacy pattern is convoluted, Iffy syntax is convoluted, function scoped variables are convoluted, using Arrays.prototype and similar are convoluted because you cant trust built in functions to work properly. Even arrays are convoluted because there's a marked distinction between an array vs "array like" objects and certain things work on one but not the other. And don't get me started with double equals. I could probably go on for maybe 5-10 pages given some time, but I think that's enough of a point. I have read several JavaScript books cover to cover multiple times , and honestly half the books are "patterns" aka workarounds for things that usually "just work" in other languages. Yeah I understand they're working to fix this stuff but some of the cruft will remain with us for a long time. I haven't used a single other language with as many gotchas as Javascript, not even Perl. NPM is a mess and we seem to agree on that. I happen to have published packages on both C# and Java, and I'll say that especially for Java, the bar for "acceptable" is much higher. This is kicking a hornets nest but... I think a lot of the reason the quality of NPM packages is so low is because the average JS developer has a lot less experience. Still, some of the problem is the design of NPM itself. They need to ditch their module system for the new standard yesterday and they need to make it less trivial to publish a package. Both C# and Java scan your manifest to make sure you meet some minimum standards, such as a sane namespace. As for debugging, it might be a lot better now, but Chrome is still seriously underpowered as a debugger compared to a real IDE. It's main purpose is a web browser so this isn't too surprising. Java or C#(my two mainstays) have full debuggers built into the runtime plus tons of extras like profilers and processing/comparing process dumps and memory leak finding systems and all sorts of crap that becomes useful when you've got nasty bugs. JavaScript is still maybe half a decade behind on tooling, debugging, and IDE support. You're probably right that Node is great for hacking stuff together quicker than Java, but I don't think the language and tools around it are mature enough to support large applications expected to last a decade or more. To me Node feels like Python but with a much better performing runtime, and IMO should be treated as such. Good for quick stuff and "glue" applications. My angst with the JS community comes from their collective immaturity(or maybe it's just the hype train, or maybe both). Everything new in JS is the best thing ever and makes front page HN, even if it's existed forever. I remember a post about the Closure compiler in JS making the front page a few months back. The Closure compiler has existed for what... Ten years? Is it really that big a deal that google ran a JS codegen from the native Closure source? The JS community thinks so apparently. That and the JS community pooping on C#/Java because they have a big runtime when the runtime for JS is also huge. You need an entire web browser just to debug it! Anyways yeah JS is really approachable because you don't need to install anything to use it and it's being taught everywhere as a first language. But its badly designed and the ecosystem around it is busy but of largely low quality.