9 ms·
Underscore and Lodash Merge Thread
- fokinsean 11y ago> Lodash is currently > 12k lines of code, and Underscore is 1.5k. Never knew that before. Does Lodash have more features than Underscore? I never got too heavy into using either but I always thought of them as essentially being interchangeable libraries.
- Derander 11y agoLodash has many features that underscore does not have. Also, I am told that Lodash has been implemented in such a way that functions are largely independent of each other so that you can build a custom lodash package that only includes the subset that you use.
- tracker1 11y agoIn practice, I'm not sure how truly valuable this is... it's far easier to just accept it as a whole, and with min/merge versions in the browser it's not so big at all. It's not a macro framework like jQuery... the kitchen sink isn't in there... though, I do think that probably the string templating could/should become a sub-module... the rest belong together more.
- betenoire 11y agoThe comments mentions this a few times: the codebases are different styles and the size difference apparently has a lot to do with documentation.
- mmgutz 11y agoIn addition to other comments, optimization sometimes means inlining code. Lodash has always been performance first.
- jdd 11y agolodash is consistency and compatibility first.
- ben336 11y agoHeres a breakdown of the differences between the two : http://benmccormick.org/2014/11/12/underscore-vs-lodash/ http://benmccormick.org/2014/11/12/underscore-vs-lodash/ A few months old but should still be reasonably accurate
- Cthulhu_ 11y agoOne of the core differences between Lodash - iirc - is that Underscore will just use a browser's built-in version of functions like .map and such, while Lodash often implements them themselves - circumventing JS spec compliance, often with significantly better performance than native implementations.
- Vekz 11y ago> circumventing JS spec compliance, often with significantly better performance than native implementations. Yes Lodash has some interesting 'better than native' optimizations that utilize JIT compilation
- mfkp 11y agoFor visibility (people aren't reading this) From the author: "Folks. Please STOP +1 and :+1: -ing GitHub tickets. We get it, but it makes tickets hard to have conversations on. Contribute with something substantive instead." This is a very common problem for github issues posted on HN/any social media. Would be great if github had a voting mechanism.
- crazysim 11y agoIt originally did have a voting mechanism.
- fmorel 11y agoI don't get why people don't just subscribe to the issue instead of +1. Google's issue trackers have the same issue: they support starring but people insist on doing "me too" posts.
- masklinn 11y ago> I don't get why people don't just subscribe to the issue instead of +1 Because subscribing does not show interest/support: the repository owner does not see how many people have subscribed to the issue. Furthermore, supporting the resolution of an issue does not mean you want to be spammed with updates to said issue. > Google's issue trackers have the same issue: they support starring but people insist on doing "me too" posts. Google's issue tracker has the same issue to a lower extent: while everybody can see the number of stars on an issue (which is good), starring an issue requires following it and being spammed by it (which is bad). Then again, people are by and large idiots, even on e.g. youtrack (which has non-subscripting voting) +1 comments abound: http://blog.jetbrains.com/youtrack/2013/01/making-1-mean-what-it-really-means/ http://blog.jetbrains.com/youtrack/2013/01/making-1-mean-wha... Only way I see to mitigate that is assuming the tracker has orthogonal subscription and voting ruthless moderation and removal of worthless "+1" comments.
- hk__2 11y ago> Furthermore, supporting the resolution of an issue does not mean you want to be spammed with updates to said issue. Commenting on the issue automatically subscribes you to it. You have to manually unsubscribe if you don’t want to be spammed.
- deleted 11y ago[deleted]
- jakejake 11y ago+1
- yellowapple 11y ago:+1:
- deleted 11y ago[deleted]
- basicallydan 11y agoWhat a great exchange so far, I love it when people in charge of important software work together cooperatively and without lots of arguments.
- pavlov 11y agoIs Underscore.js "important software"? I guess I never thought of it that way. To me it's more like a nice-to-have -- a helper library of functions you could write yourself (but probably shouldn't bother to).
- robertfw 11y agoI started using underscore, moved to lodash. I find them indispensable.
- basicallydan 11y agoWell, it's important in the sense that it is widely used and depended upon by the JavaScript community :)
- acjohnson55 11y agoI'd say Underscore largely made writing JS tolerable, given how crappy the standard library is and the number of gotchas the language has. So yes, very important!
- blueside 11y agobig kudos to both these incredibly smart and talented guys for putting their differences aside (there has been some ugly exchanges between them in the past) and getting this done, the JS community will greatly benefit from this.
- arcosdev 11y agoboth eclipsed by ramda.js >> http://functionaltalks.org/2013/05/27/brian-lonsdorf-hey-underscore-youre-doing-it-wrong/ http://functionaltalks.org/2013/05/27/brian-lonsdorf-hey-und...
- tracker1 11y agoI really like Ramda myself as well... Though there are a few bits that I prefer how lodash/underscore work... in terms of methods that will work against an object or an array. In Ramda it's more expressly separated, and not always a good ratio. I very much appreciate being able to use Ramda for composition of methods, which can mean much more concise code[1]. [1] https://github.com/tracker1/azure-config-util/blob/master/src/get-config/parse-raw.js https://github.com/tracker1/azure-config-util/blob/master/sr...
- kin 11y agohadn't heard of ramda.js until this comment. thanks! love what it provides w/o forcing anything on you.
- chamakits 11y agoIs it going really? If so in what way? At least mind share wise I've heard of lodash/underscore much more often than ramda. Only recently has it come up with some level of frequency.
- arcosdev 11y ago
- macspoofing 11y agoHow does that work? You have two fairly mature code-bases, is one just being dumped (i.e. lodash)?
- idbehold 11y agoIf anything was to be dumped it had better be underscore.
- smrtinsert 11y agoI really don't get why its going from lodash -> underscore. This is a clear case where lodash has won imo and if anything it obviates underscore.
- omouse 11y agoThe issue is backwards compatibility and ensuring API compatibility. I don't care if I can switch from underscore to lodash if I have to change X lines of code and then test them many times over to make sure that it all works.
- camenk 11y agoIt's cute that let's do merge and keep underscore because lodash is just cute.
- Igglyboo 11y agoThis comment looks like it was written by a bot.
- csense 11y agoSo basically these libraries are like Python's itertools for JS? Except they made a silly/arrogant choice of using a single character for the library name.
- robertfw 11y agoThe reason for the single character library name is that by convention, the library is imported into a variable named "_". This reduces code noise and amount of typing if you are using these functions frequently I'm not sure how that is silly or arrogant
- dopamean 11y agoJust someone who doesn't write much JS.
- csense 11y agoImagine if every library you used named itself with a single character. Does your language have more than 27 libraries available? Then sorry, some of their choices of letter will overlap and those libraries will conflict, perhaps requiring you to manually edit the distribution source or build scripts. Do you ever want to create a project that has more than 27 transitive dependencies? Yeah, good luck with that. Found a code snippet online and want to figure out what library it's invoking? Hint: Google is probably going to be useless when searching for a single-letter name. The problems with using single-character names for libraries are so self-evident, I'm not quite sure how to respond to someone who doesn't see it.
- Macha 11y agoIt's like Python's itertools if: * list and dict were lacking vital methods like list.remove() and dict.__len__() * dicts weren't really a real thing (real ones coming in ES6 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... ), but it was easy to add random properties to arbitrary objects while accessing a missing one simply returned None, and so these were used instead * Which leads to for x in dct being subtly broken in certain use cases unless you understand the above and how it interacts with prototypes * So loads of utility functions were added to deal with the above facts, plus the kind of useful tools you would find in Python's functools and itertools and a large number of other utility functions while they're at it. (EDIT: One of these days I will remember HN doesn't use Markdown, but not today)
- halis 11y agoYou know they're going to have some disagreement about " vs ' and it's all gonna fall apart...
- octref 11y agoAs someone who once contributed some bits to lodash, I don't see how this will work out. Other than perf, modularity, etc, I like lodash's doc better. The doc is written as inline jsdoc in lodash.js, with each parameters documented and behaviors explained through examples. But here is @jashkenas's take: > Documentation style. Ideally I'd like the Underscore docs to be written even more conversationally than they are at the moment. Personally I also trust @jdalton more. Other than technical skills he's very hard-working and responsive. He seems to be following a zero-issue-and-PR policy and get all issues/PRs sorted out in 2-3 days.