It’s a bit humbling to admit it, but I may have been wrong about my fierce resistance to third-party modules in Node.js.
I started working with Node.js before NPM, and before there were any third- party modules (that I was aware of). Much of my excitement about the platform was based on the fact that you were starting from scratch, all the way down to the webserver itself. This was exciting to me because most of my work on server-side code was, and still is, writing fast, stateless API’s.
My predisposition to avoid modules goes all the way back to my experience with C. C was my first experience with a compiled language (I don’t think an assembler counts) and the thing that stood out to me was it’s simplicity. The language was so small that you could memorize the whole thing (there are something like ~30 built-in functions?), but with that small set of tools you could build anything.
However this was less exciting to the majority of developers who were used to working in environments like Java or Ruby on Rails which had a rich ecosystem of modules (“gems”) that could be drawn upon for almost any need that could arise. So these developers quickly set about creating modules for Node.js that re-created the structures they were familiar with, notably the web framework Express, which made Node.js work like a typical MVC-style web application.
It’s in this area where I’m learning I may have made a mistake. In particular, there are two modules that I now believe are worth the added complexity of including them in a server project.
The difference may be subtle, but that change in perspective made it a lot easier for me to accept Underscore’s claim of being a standard, or otherwise necessary.
After years of fighting with this I’ve come to accept Moment.js as a solution to this problem. Like Underscore.js, this is less about Moment.js’s ability to do things you can’t already do, or it’s performance, etc. and more about establishing a consensus between programmers on the way to handle these things.
I’m still extremely cautious about including third-party modules in my projects, and every day there are more and more poorly-implemented, unnecessary modules uploaded to NPM, but I’m working on getting comfortable with making exceptions for modules which are proven to reduce errors and increase developer productivity (specifically when collaborating) so long as they can be proven to have minimal impact on performance, reliability and security.