4 ms·
The need for Lodash and Underscore is diminishing, but not because of JS getting native support for a subset of utilities, but because there are already better
by klibertp 10y ago
The need for Lodash and Underscore is diminishing, but not because of JS getting native support for a subset of utilities, but because there are already better alternatives. Utility libraries like Ramda[1] or pointfree-fantasy[2] with related modules which offer a better support for FP idioms and more useful higher-order functions are what made me drop Underscore.
I think that, with a language with such tiny stdlib, there always be a need for some kind of utility belt-style library ("if only for convenience", as another commenter write, which is actually the main point of such libraries). It's just a matter of choosing the best library for your coding style and project at hand. It may be a hassle, but an alternative is an stdlib the size of Python's - and I'm not sure if it's a good direction.
[1] http://ramdajs.com/0.21.0/index.html http://ramdajs.com/0.21.0/index.html
[2] https://github.com/DrBoolean/pointfree-fantasy https://github.com/DrBoolean/pointfree-fantasy
- skrebbel 10y agoThe Ramda API changes with every version. If you don't pay attention for a few months and accidentally upgrade (Ramda doesn't seem to want to do Semver, I'm not sure why), then suddenly half your code is broken. We depend heavily on Ramda and I like its API better than Lodash and friends (it's more guessable, more consistent), but with the changes it keeps having I regret choosing it. Our core product is currently on a Ramda version that's so old that there's no online documentation published for it, so we just look in the source. We ought to upgrade but I'm not convinced all code paths that use R are sufficiently covered by automated tests.
- ascagnel_ 10y agoTechnically, Ramda is using semver; 0.x releases are used for when the API is still changing substantially[0]. [0] http://semver.org/#spec-item-4 http://semver.org/#spec-item-4
- skrebbel 10y agoAhyes, good point. In the Ramda authors' defense, they never claimed it to be good for anything production level.
- klibertp 10y agoI mentioned Ramda without having used it very much and I didn't know about the frequent API changes. From my personal experience, I got very good results using LiveScript with its default Prelude.ls lib. LS supports nearly all FP-related constructs and syntax known from many other languages, and Prelude.ls, while smaller than Ramda, is quite complete, too. That's not for every project, though: introducing another language is a bigger risk than introducing a single library.
- shados 10y agoLodash does a good job with version number, but upgrades are pretty damn dangerous (unless you feel with sticking to the same version forever). The worse example was when they changed clone to be shallow from deep. Most code worked (shallow clone is a common case), but not quite all of it. Good luck finding which part of your code depended on deep cloning, even with tests. So don't think you'd be able to upgrade much more often.
- noir_lord 10y agothe "if only for convenience" point is an interesting one. I really care about convenience in programming tools, I'm the end user they should be convenient for me. It's programming not masochism.
- jdd 10y agoLodash v4 has support for FP syntax/modules – https://github.com/lodash/lodash/wiki/FP-Guide https://github.com/lodash/lodash/wiki/FP-Guide
- WickyNilliams 10y agoI find lodash infinitely useful to this day. It even provides a build with auto-curried, iteratee-first, data-last functions if FP is your jam. Just require it like this: var _ = require("lodash/fp");