Everybody understands the purpose of libraries and no one is going to reinvent something major from scratch – but the problem is in simple stuff that gets you in trouble.

Because no one is going to rewrite Express and React in JavaScript, or Scikit-learn and Matplotlib in Python.


How about a simple sorting algorithm?

In JS it would look something like this:

[3, 1, 2].sort((a, b) => a - b);
// output: [1, 2, 3]

Or you can just use Lodash:

// output: [1, 2, 3]

Using Libraries For Simple Tasks

These two examples above look very similar. And amateurs could argue that it’s all the same whether you use the library or not.


It’s not the same.


In the example above it is easy to make a mistake and switch the places:

“b – a” vs. “a – b”

On the other hand the function sortBy is very hard to miss and if you misspell something you will get a very obvious error.


It is unlikely the (Lodash) library function sortBy has an error. There are tests written for it, as well as big community that makes sure everything works ok.

A single programmer (especially junior who engages in reinventing the wheel) is more likely to make a mistake when re-implementing the sort algorithm.

And this makes the entire code less readable, more complex, and less reliable.


What if your array didn’t contain plain values but objects instead?

Now you’d have to develop a separate sorting object and suddenly your simple solution is getting more and more complex.

With even higher chance of making an error.

Instead you can just sort array of user objects by their name like this:

_.sortBy(users, ['name']);

Libraries Make You More Productive

In short, libraries make you a better developer.

Also, they make you a more productive developer.

And productive developers have higher salaries.

So remember that the next time you feel the urge to implement some “simple” algorithm yourself.

P.S. -> read this article if you want to double your salary