Underscore vs Lodash vs Sugar?


#1

I know Underscore and Lodash, but I miss Sugar.
What do you think: Underscore vs Lodash vs Sugar?


#2

You need to put link to those so people can go have a look in case they don’t know all three. Also, it depends, what use case do you have in mind you compare them against?


#3

I used to like Sugar too… in fact I almost released a library called “Dunderscore” which implemented all underscore methods as [1,2,3].__contains(2);.

However after I started learning about functional programming and saw how it made my codebase simpler, I really appreciate having separate functions.

You can clean them up a bit by doing this:

import {map} from 'underscore';
// or
var map = _.map;


users = [{name: 'Bob', age: 21, name: 'Leah', age: 32}];

names = map(users, (user) => user.name);

I also prefer Ramda over underscore because it doesn’t mutate and allows for currying: http://ramdajs.com


#4

Interestingly we went through this adventure when building Discourse and ended up picking lodash.

https://meta.discourse.org/t/getting-rid-of-sugar-js/7146


#5

Please add link for Dunderscore.


#6

It’s gone… I burnt it up before anyone could see it :smile: . It had the same prototype issues that Sugar had (see Sam’s post)

I would pick lo-dash over underscore but if you’re using Blaze I would use underscore since it’s included with Blaze. Lo-dash has a slightly better API in my opinion.