Software, Privacy & Freedom

Dependency-Free Development

· 4 min read

Dependencies have become one of the biggest parts of the whole software toolchain to date. With the 1000+ NPM packages that each project has, there lies a question of whether we should actually use any of them. Using dependencies doesn’t necessarily make your development life easier, and I’m going to explore some reasons why that is.

Before going any further it might be important to clarify what dependency-free development means. It simply means to be free of any and all third-party software dependencies as the name implies. In the purest form you are only allowed to use the standard library that comes with your language and any system libraries out of necessity.

Debugging others code

One of the things that you might come across is bugs in other peoples code. Now bugs are a necessary evil in any non-trivial software project, but you can reduce them by doing things yourself. It might sound counter-intuitive because popular libraries have had many hundreds or even thousands of developers making them over the years, so how could I make anything remotely as good as that? The answer is you can’t, but you also don’t have to.

When you are using a library you most likely only use 1% of its functionality. Because of that you can make that 1% better and more polished than a hundred people can make a general purpose library. You know the intricacies of your software and have full control over the code. Relying on other peoples code can and most likely will lead to more bugs.

KISS

Keeping things simple is one of the most appealing aspects of dependency-free development. You don’t have to worry about breaking changes in libraries or how to manage dependencies. This becomes painfully obvious when using something like C as you don’t have any good idiomatic way of managing dependencies (especially on Windows).

Other thing about keeping things simple is the build process. This becomes apparent when comparing TypeScript to JavaScript. It is such a joy to just write pure JavaScript without any compilation step or any build system around it. Just write the code and run it, that’s it.

Free from documentation

Let’s face it, some documentation is great and some… less so. When you have no dependencies you also have no documentation to worry about. The only thing you care about is the language (and standard library) of your choice and your own code. No need to know the edge-cases of some obscure library with no documentation.

On the other hand it will become more important to document your code well as you are not going to use any standard dependencies that everyone knows about. Keeping your code free of dependencies will certainly make it harder for others to reason about, mainly because they aren’t used to it, so try to keep your documentation up-to-date.

Code reuse

The argument for libraries is code reuse and in a way it makes sense. The problem is that it assumes code needs to be reused at all. Each application is different and have different requirements. It becomes exceedingly difficult trying to create a general purpose library to fit each and every scenario.

When you create things from scratch you don’t have to worry about some missing feature as you are going to implement everything by yourself. You will have to reinvent the wheel to some extent but in the end it will be worth it, I promise.

Conclusion

As an advocate for dependency-free development, I’m not saying you should go and throw all of your dependencies to the trash. What you should do instead is to reconsider very carefully which libraries you actually need and which you don’t. When you need to pad strings to the left your gut reaction shouldn’t be to look for a library to do the job for you.

To be free of dependencies is to be free of sin. You will experience enlightenment through freeing yourself from each and every software dependency you have. Resist the urge to npm install and rid yourself of the bugs that haunt you!


Have something to add? Don't hesitate to email me.

Written by Human, Not by AI