DEV Community

Discussion on: Lodash and Underscore, is there still a case?

Collapse
 
ahferroin7 profile image
Austin S. Hemmelgarn • Edited

I se two big advantages to Lodash/Underscore other than providing slightly stricter FP semantics:

  • They make your code more concise, usually in a good way. ECMA and W3C seem to love long super descriptive names for functions. Using Lodash or Underscore lets you avoid such needless verbosity without compromising on readability. _.has(x, y) is a whole lot easier to read than x.hasOwnProperty(y), especially if you're not using syntax hilighting, but doesn't reduce the amount of relevant information being conveyed to anyone reading the code. This is also, coincidentally, one of the arguments for continuing to use jQuery ($('foo') is a whole lot more concise than document.querySelector('foo')).
  • It helps you avoid having to write boilerplate code. Yeah, you could write your own symmetric difference algorithm for arrays, but it's a whole lot easier to just use _.xor(x, y) and worry about coding the actual application, especially when you've got a deadline approaching. The less generic code you have to write, the more time you can focus on actually getting the application itself written.

I honestly feel both points are far stronger arguments than making FP in JS nicer, especially considering the fact that most of making FP nicer in JS at this point is just enforcing FP patterns (the language itself is already very FP friendly).

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

Your first point reminds me of the awquard case of the JavaScript Map, although vastly superior with an API just like you describe, nobody seems to use them despite the ease of use and performance improvement.

I don't really disagree with anything you say. Thanks for chipping in.

Collapse
 
ahferroin7 profile image
Austin S. Hemmelgarn

nobody seems to use them despite the ease of use and performance improvement.

There are a lot of sites that transpile down to earlier versions of ECMAScript revisions. In such a case, there's no performance benefit to using new features, and quite often they actually make performance worse. I suspect that's a large part of it, and we'll probably see usage of some of these features pick up more as Internet Explorer and Opera Mini finally die off.

Thread Thread
 
adam_cyclones profile image
Adam Crockett 🌀

That's fair. I do wish that the web would move a little faster in some areas. Browsers being one of them. And an approximation of a thing is not a real thing. I gues I'm just talking in an ideal world scenario.

Thread Thread
 
ahferroin7 profile image
Austin S. Hemmelgarn

I mean, Opera Mini really is dead already for most purposes if you aren't dealing with some really big site. IE is still hanging on, but mostly corporate usage and not 'normal' users.

It's well within reason to just refuse to support either if you're doing something small. The issue is that people don't choose to do that, or they just kind of decide to use Babel without thinking (and thus make the site slow for all their actual users who aren't using browsers that need old JS).