Hacker News new | past | comments | ask | show | jobs | submit login

shortcuts for trivial operations is how we got the leftpad disaster.



People need those shortcuts so they don't reimplement them over and over. Not having the leftpad as part of the language or standard library is what caused the problem. This is exactly the problem the article talks about.


>Not having the leftpad as part of the language or standard library is what caused the problem.

There are a few other comments in this tree making the same claim - is this what most people took away from the left-pad incident?

To me, the stdlib lacking left-pad is a fairly distant cause. You could make the same case for any popular library, but that road leads to a bloated stdlib, which forever will haunt us. The more relevant causes, in my book, are:

1. Many builds relied on pulling left-pad directly from NPM

2. NPM allowed left-pad to be unpublished

I like to compare this to the usual practice in the Java world:

1. The primary repository in use is the Maven Central Repository. Nobody can unpublish a library from it. This is specifically to avoid pulling dependencies out from under consumers of those dependencies.

2. Most Java shops run their own repository. This serves both to caches requests to the Maven Central Repository, and to provide a fail-safe in case something were to happen to Maven Central. Backing up dependencies is considered as important as backing up your own code. Sometimes vendoring is used as an alternative approach.


Leftpad was a result of making libraries (comically) small. If you have a bunch of convenience operations, you can put them all together into a single utility library (or even the standard library).


Leftpad was a result of the JS standard library being terrible and not providing built-ins for such simple, common things.

And Go is the same way...


If the leftpad functionality was part of JS by default it wouldn't have happened.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: