3 ms·
> I shouldn't need external dependencies to have access to underscore.js's "map" or JQuery selectors. Been a while since you did need. document.querySelector a
by throwanem 9y ago
> I shouldn't need external dependencies to have access to underscore.js's "map" or JQuery selectors.
Been a while since you did need. document.querySelector and .querySelectorAll are everything about jQuery that's worth having, and every browser has implemented them for years. Arrays have a map method that does what you expect it should, although do be aware of the odd calling convention. Objects don't map natively, but their keys do, which I very rarely find fails to suffice. (And for those things that really can't be expressed in stdlib without considerable reinvention, Lodash is a strictly better Underscore.)
- always_good 9y agoIt's just a reminder of how incredibly outdated the intel is from HNers weighing in on Javascript in a negative light.
- simias 9y agoI explicitly mentioned that I wasn't a webdev, I never pretended I was some kind of authority about JS. I maintain my point though, so far most sizeable JS projects I've seen depend on JQuery for one reason or an other, so clearly even competent JS coders feel the need to supplement the functionality of the standard library. As for the built in map, the fact that you can't use it on objects is the reason I ended up requiring underscore.js (alongside with the .find and .uniq methods, and probably a few others). I could also have mentioned how hacky and messy it becomes if you decide to split your JS project in multiple files. Or the hack to create "modules", which is at the same time very clever and pretty terrifying.
- always_good 9y agoBut you're also conflating server-side and client-side (jQuery) Javascript. Client-side applications have baggage (infinite deploy targets) that you don't have with server-side applications (one deploy target), so the comparison is disingenuous.
- simias 9y agoI see your point but that's not really what I meant. I wanted to say that server-side JS is a direct consequence of client-side JS. If Javascript had stopped being a thing in browsers do you really think Node.js would've gained significant traction despite the numerous alternatives? As far as I can tell the main selling point of Node is that you can use the same technology on both ends and even share some code. If you remove this from consideration then Node competes against Python, Ruby, Perl, PHP... And it's not clear how it's better than these.
- mbrock 9y agoIs it clear that Python, Ruby, Perl or PHP are better than Node with JavaScript? I don't think so. They're all slightly idiosyncratic dynamically typed scripting languages with their own sets of quirks. BTW, the main selling point of Node over those languages was that the runtime was faster and more capable at multiplexing I/O in server code.