Left-pad as a service
I&#x27;m ready to get downvoted to hell with this comment but here we go..:<p>I feel like only non-javascript devs are bashing against small modules and NPM. All great javascript devs I know LOVE that mentality.<p>Let me offer some reasons why I (as a current Javascript dev having professionally coded in C&#x2F;C++&#x2F;Java&#x2F;Python&#x2F;PHP&#x2F;Scheme) think this is great:<p>- Unlike most other languages, javascript doesn&#x27;t come with a battery standard library. So you&#x27;re often left on your own to reinvent the wheel. I mean, common, in Python you do &quot;&#x27;hello&#x27;.ljust(10)&quot; but AFAIK there isn&#x27;t such thing in javascript. Javascript is more like the wild west where you need to reinvent everything. So having well tested libraries that does one thing extremely well is really beneficial.<p>- Javascript, unlike most other languages, has some pretty insane gotchas. I.e. &quot;&#x27;0&#x27; == 0&quot; is true in javascript. Most devs have been burned so bad in so many ways in Javascript that it&#x27;s comforting to use a battle-tested library, even for a small feature, rather than reinventing it.<p>- And anyway, where should we put that function? Most big projects I&#x27;ve worked on have some kind of &quot;helper file&quot; that has 1500 lines, and then at some point different projects start depending on it so noone likes to touch it, etc. So, yeah, creating a new module takes a bit more time, but remember that it&#x27;s not about the writing time but more about the maintenance time. I&#x27;d much rather have lots of small modules with clear dependencies than a big &quot;let&#x27;s put everything in there&quot; file.<p>- I feel arguing about whether something should be in a separate module is similar to arguing without something should be in a separate function. For me, it&#x27;s like hearing &quot;Hey, learn how to code, you don&#x27;t need function, just write it when you need it.&quot; And hey, I&#x27;ve worked in projects professionally where they had no function and it was TERRIBLE. I was trying to refactor some code while adding function, and people would copy my function inside their 1500 lines file. Let me tell you I left that company really fast.<p>- It&#x27;s fair to say that UNIX passed the test of time and that the idea of having lots of small programs is extremely beneficial. It forces common interface and great documentation. Similar to how writing test force you to create better design, modularizing your code forces you to think about the bigger picture.<p>- As far as I&#x27;m concerned, I really don&#x27;t care whether a module is very small or very big, as long as what it does is well defined and tested. For instance, how would you test if a variable is a function? I don&#x27;t know about you but my first thought wasn&#x27;t:<p><pre><code>   function isFunction(functionToCheck) {
     var getType = {};
     return functionToCheck &amp;&amp; getType.toString.call(functionToCheck) === &#x27;[object Function]&#x27;;
   }
</code></pre>
Who cares if it&#x27;s a 4 lines module. I don&#x27;t want to deal with that javascript bullshit. Yes, I could copy past that in my big helper file, but I&#x27;d much rather used one that the javascript community use and test.<p>- Finally, it seems like Node&#x2F;javascript hasn&#x27;t started that way. Not so far ago with had Yahoo monolithic javascript libraries and jquery. Even the first versions of most popular node library (such as express) were first written as a monolithic framework. But it&#x27;s been refactored into dozen of small modules with clear functions. And now, other libraries can just import what they need rather than the whole project.<p>OK, so I told you about the good thing. What about the bad thing?<p>- Adding dependencies to a project is REALLY HARD TO MAINTAIN. I&#x27;ve had so many bad experience using node because of that. I.e. I work on a project, it&#x27;s tested and work fine. 2 months later I clone and start the project and everything breaks. Oh, X and Y libraries decided to fuck everything, that other library now depend on a new version of Node, but I can&#x27;t upgrade node because that other library depend on a previous version of Node. It&#x27;s complex. I won&#x27;t go on in explaining my solution to this problem, but enough to say that it&#x27;s a problem and installing random amateur libraries in a professional project can lead to disaster.<p>- It takes longer to code. I&#x27;ve touched that earlier. It&#x27;s a tradeoff about write now vs maintain later. Take a look at segmentio github repo: <a href="https:&#x2F;&#x2F;github.com&#x2F;segmentio" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;segmentio</a>. I&#x27;d personally love to have that as onboarding experience rather than some massive project with everything copy&#x2F;pasted a few time. But yes, it took them more time to create those separate modules.