philipbohun.com/blog
philipbohun.com
gitlab |
github |
youtube |
blog<br>dark mode
Zerodep
2023-12-25
Zerodep is the idea that third party dependencies should be minimized, and ideally be zero.
In general, given the choice between writing a few dozen or so lines of code and importing a multi-thousand line library, it's better to write a few dozen lines of code.<br>Less lines of code means less bugs.<br>Less lines of code means the codebase is auditable.<br>Less lines of code means the codebase is more maintainable.<br>Have you ever tried to audit a codebase that had 500,000 lines of code and 5 MILLION lines of dependencies?
It has become cliche for people to complain about code bloat.<br>And yet, people still use multi-hundred-thousand line frameworks.<br>The only way to return to sanity is to dump the frameworks and actually learn how to code.<br>If we do not, code will collapse under its own weight, and AI will not be able to fix it! (That should probably be a subject of another blog).
There is one other thing missing from the software ecosystem, and that is replacement.<br>Once a codebase gets above a certain size, it only accretes code.<br>Sure, some code may be deleted, but on net the size of the codebase only increases.<br>Do operating systems really need to be 150+ million lines of code?<br>Do web browsers need to be 50+ million lines of code?<br>No, but there is no mechanism to keep them a reasonable size.
What is the solution bring these enormous codebases under control?<br>Personally, I believe it would be less work to start from scratch than to try to reduce existing codebases.<br>We should also do studies (actual computer science!) to find when a codebase reaches "black hole" status (becomes so big that it only ever gets bigger).<br>When we have an approximate number, we can create new projects where we say "We cannot go over X lines of code. If you really need to add more you must remove some from somewhere else".<br>I think this discipline and skill must be deliberate.<br>Without this discipline we risk a Parkinson's Law for code except that there is no limit to expansion.
(c) 2023 philip bohun