I have seen a lot of libs out there, but in general I can see two directions: On the one hand, libs which are very small and focused. They do one thing, but they do it well. It's a little bit like adhering to the Unix Philosophy.
On the other hand, there are more and more big libs, which try to do more and more under the hood, basically being like a big black box you use and which does a lot for you, often even auto-magically.
What do you prefer? Why? In which situations? What do you think about prototyping using big libs, but then creating very lean applications with small libs? Would you get the time for that?
Somewhere inbetween. I appreciate large do-everything libraries, but they're too large and include many many things I don't need. Small unopinionated libraries without enough things aren't very helpful either. I need a certain balance between the two.
Small, focused helper functions that can be combined with any number of other functions, in any combination.
The downside to bundling them all together is if you only want to use one part of it, you have to start making decisions about what to do with the code you intend not to use. Tree shaking? Custom build? Import anyway? With ES modules does it make sense to have to download a giant file only to read one function from it? etc.
I think, especially with the nature of JavaScript modules, that single-function helpers are probably the most flexible.
But, you raise a good point as well, sometimes there's a theme that ties a number of helpers together around a common task, a common purpose, or a common functionality. What are ways we can package up and market sets, series, or families of plugins together in a way where they can be used independently from each other too?
I prefer the smaller ones if possible. Rather simple logic ... less code, less possible bugs. :)
Actually you’ll need both for a healthy mix, even in smaller projects. Otherwise the application will tend to reflect to have the same disadvantages as the framework you’re using.
It depends.
Some advantages of small and focused libraries:
Disadvantages:
It's all kind of a spectrum. Is "json encoding for all the most common types" doing one thing well? Is "all of regex" doing one thing well? Is "collection of useful stream operations"?
I considered making lexing, parsing, code generation etc separate packages for my compiler, but in the end I didn't, because they're mostly useless in isolation.
Often users can get the best of both words with packages that give a unified interface using independent components (kind of a Facade pattern).
I think in many cases, the ideal system for open source projects is like:
Ibrahim Tanyalcin
{intrst:"Scnc&Art",msc:"admin@MutaFrame",strive:"Experiment&Learn",loves:"ES5",hates:"bandwagon",lang:"Javascript",twttr:"@ibrhmTanyalcin"}
Focused libraries that does 1 thing, and 1 thing well with 0 pain of setting it up, please. Really tired of dealing with tech stacks that claim to do all with the most modern/cool way with tons of config and gotchas while doing nothing out of the box.