r/javascript • • Jan 26 '16

You-Dont-Need-Lodash-Underscore

https://github.com/cht8687/You-Dont-Need-Lodash-Underscore
0 Upvotes

30 comments sorted by

View all comments

5

u/arcanin 🧶 Yarn maintainer Jan 26 '16

I don't understand why so many devs use the Lodash versions of native functions instead of adding a shim. You can't both complain about a lack of native tools and not use the ones we have, folks.

To be clear, I have absolutely no issue with Lodash in itself - I use it a lot for the new tools it brings to the language. My remark only applies on those who are natively available.

4

u/teapoted Jan 26 '16

Lodash performs better than Native for a lot of it's implementations.

The primary reason is for consistency though, especially if you're using a more functional style with a lot of currying and composing.

3

u/arcanin 🧶 Yarn maintainer Jan 26 '16

See, I don't really see performances as a valid reason to use these functions. I have yet to see an application where Array#forEach was the real bottleneck, and if you're writing a library, I'd very much prefer the library author to avoid dependencies, even if it means they have to implement a basic forEach that solves their particular use case, than requiring me to use Underscore or Lodash or whatever. I love taking libraries for a date, but I hate it when they require me to bring their friends along.

As for the consistency, it might make sense when making use of the functional style (since Lodash brings new features in this regard), but not quite as much when writing imperative code - one might argue that using the standard library is the actual best way to achieve consistency.

3

u/teapoted Jan 26 '16

As I said, the primary reason isn't really about performance.

Getting more consistency from using the standard library is arguable. Consistency comes down to programming style and the overall composition of your program. It's not consistent if in your code you are using some of the native array methods but then have to constantly break out to write some for loop to do something those methods won't do. Or if you have to operate on objects similarly.