6 ms·
“Discuss latest changes to master before releasing”
- ggreer 12y agoIf you find yourself annoyed by some aspects of Underscore, you might want to check out Lodash[1]. Lodash's API is a superset of Underscore, though you can create custom builds with only the parts you need. In general, Lodash performs better and has fewer bugs than Underscore. Unlike Underscore, Lodash has 100% test coverage. Also, Lodash has some handy things like _.cloneDeep(), and semantic versioning. That means your package.json can have "lodash": "3.x" in its dependencies without worrying about breakage. For a more in-depth discussion of the differences between Lodash and Underscore, I recommend Ben McCormick's Underscore vs Lo-Dash[2]. 1. https://lodash.com/ https://lodash.com/ 2. http://benmccormick.org/2014/11/12/underscore-vs-lodash/ http://benmccormick.org/2014/11/12/underscore-vs-lodash/
- TheAceOfHearts 12y agoCompletely agree. I always ask people why they're using underscore over lodash. Once they learn about lodash, they'll usually switch over right away. There used to be a compatibility build of lodash, but I think it might've been deprecated by now... In any case, migrating would be fairly straightforward I think.
- maratd 12y agoLodash is also several times larger than Underscore. The point of Underscore is to keep it light. And yes, you can pick and choose what modules you want. But you could do that with Mootools and it was released a decade ago. If you want a heavy framework with lots of modules, there are plenty to choose from. Maybe if it offered a light version on the front page? The file linked from the front page is 372KB. By comparison, the file linked from Underscore's front page is 51KB.
- TheAceOfHearts 12y agoIf you're using CommonJS you can do require('lodash/category/method'), and when it gets built on the frontend it'll only include the method and its dependencies. So if you're using only 5% of lodash, you'll only get that 5%.
- maratd 12y agoRight. If on node, you can also use modules via NPM ( https://www.npmjs.com/browse/keyword/lodash-modularized https://www.npmjs.com/browse/keyword/lodash-modularized ). But as I said, this is common in many frameworks. Hell, you can even do with JQuery ( http://projects.jga.me/jquery-builder/ http://projects.jga.me/jquery-builder/ ). So having this ability doesn't make Lodash special. This is not presented as the preferred method to use the framework on the project page either. You just get a link on the front page to the whole shebang. Probably because most developers just download the whole thing and stick it in. What I was really hinting at was code complexity. Sometimes having something light and small that you can stick in there without worrying about anything is useful. Lodash can address that by having a light version linked off their front page, but they haven't done that. On top of everything, Underscore is ribbing them on this very point. See http://underscorejs.org/ http://underscorejs.org/ and bit down "(3x smaller than Lodash ;)" in bold. Seems like a really easy point to address.
- jiaweihli 12y agoIf you care about filesize, you'll probably optimize as much as possible. You can do this with Lodash using modular imports. There's little upside in hosting a light version, and fragmenting the docs. Min/max'ing on filesize lets you save 15 kB, or 0 kB. Creating a light build that saves 5 kB is a maintenance cost with a poor ratio relative to reward.
- maratd 12y ago> If you care about filesize I don't care about filesize. I care about code complexity. The more crap you add to a page, the slower it will run. You also get a higher probability of conflicts and problems in the long run. If you need something, you need something. But if you don't and you just throw it in there, you're asking for problems down the road.
- thejameskyle 12y agoA couple things: - The actual difference (minified and gzipped) is 17.6 KB vs. 5.7KB. - Lodash is written modularly so you can import only the methods you actually need. - In order to "lose some weight" (as Jeremy Ashkenas called it), underscore dropped several methods that people really wanted (including other contributors). - Also to cut down the size, several major pieces of functionality is not broken in older versions of IE - Lodash provides a lot more functionality than underscore does, there's a lot of additional utilities including the ones that were dropped last minute by underscore. There are a lot of other reasons to use lodash, but that was quickly becoming not a _couple_ of things.
- nmjohn 12y agoThat is not a fair comparison. Gzipped and minified underscore is 5.7kb. Lodash is 17.3kb. For the vast majority of sites that is a trivial difference in size. Both of which are linked from the front page of their respective websites.
- deleted 12y ago[deleted]
- omouse 12y agoWelcome to JavaScript.
- deleted 12y ago[deleted]
- brandoncarl 12y agoVia the Lodash CLI you can "lodash underscore". This results in 6.7kb gzipped. In my experience, jdalton is a very solid coder and the lodash package is excellently maintained.
- javajosh 12y agoI like Ramda[1] better than both underscore or lodash because of it's argument ordering (function first) and auto-currying[2]. It's 7kb minified and gzipped. [1] http://ramdajs.com/ http://ramdajs.com/ [2] https://buzzdecafe.github.io/code/2014/05/16/introducing-ramda/ https://buzzdecafe.github.io/code/2014/05/16/introducing-ram...
- Touche 12y agohttps://www.npmjs.com/package/lodash-fp https://www.npmjs.com/package/lodash-fp Don't know how they compare though.
- jdd 12y agoYap, lodash v3 (https://github.com/lodash/lodash/releases/tag/3.0.0 https://github.com/lodash/lodash/releases/tag/3.0.0) introduced lodash-fp for auto-curried iteratee-first lodash methods.
- davidrusu 12y agoI like Ramda as well, currying was a feature I didn't expect to use as often as I did.
- logicallee 12y agoI don't follow Underscore but whoever wrote this title (currently "Underscore 1.8 makes last minute breaking changes to master without discussion") must really have an axe to grind, and it seems inappropriate for HN. Doesn't really set the tone for any constructive discussion.
- wcummings 12y agoYeah, and linking to a PR risks a bunch of parties w/o a real stake in the project piling on and shitting up the PR. Really poor form, OP.
- sutro 12y agoshitting up the PR Good people of HN, this phrase deserves your upvotes.
- TheHydroImpulse 12y agoThere have been previous events in underscore's history that lead to sudden breaking changes without following semver. That's probably why.
- dang 12y agoThe submitted title ("Underscore 1.8 makes last minute breaking changes to master without discussion") broke the HN guidelines by editorializing the title. We changed it to the article title, such as it is. If any of you wants to suggest an accurate and neutral title that is better, we can change it again.
- untog 12y agoTo be fair: Underscore doesn't follow semver, so breaking changes between versions should be expected. This thread just seems like an excuse to pile on jashkenas and promote lodash.
- abritishguy 12y agoIt is released and consumed via 2 package managers that mandate the use of semver.
- christopherscot 12y agowhat idiot is using Underscore at this point?