r/programming • u/Xaneris47 • 3d ago
Avoid adding new library to project: 10-year retrospective
https://pvs-studio.com/en/blog/posts/1408/•
u/CoVegGirl 3d ago
I think it’s difficult to write even a moderately complex front-end project without taking on a copious amount of dependencies, or at least paying a lot of engineers a lot of money to reinvent the wheel.
•
u/Skellicious 3d ago
I've noticed LLM vibe coding agents love to poop out their own implementation of stuff that would be very valid to use a library for. Admittedly I've only seen it for small file parsers and similar, but I've seen others notice this tendency too.
•
u/max123246 3d ago
There's a clear reason for this. LLMs are trained to implement it themselves because it decreases the risk of hallucinating. Can't hallucinate in a call to JQuery if you've been trained to only use the standard library of the language
•
u/ouvreboite 3d ago
I don’t think that’s the reason.
I think that because "I built my own custom implementation" is by essence more verbose than "I added ta lib and solved it in 2 lines".
Even if the examples in the dataset were 50/50 for "custom implementation" vs "using a lib", the custom implementation examples would represent more lines in the total, so more emphasis during training.
•
u/Flimsy_Complaint490 2d ago
Agree. And they dont seem to be trained to do any trade-off reasoning during the implementation either. There is never "is this or this better", but "do that" and if that doesnt work, immediatly move to plan b and stay within original constraints. Like, if you are doing a CLI app, it will never do research, pick a flag parsing library and such, it will poop out 1000 LoC file from its training data.
But ask it to do exactly that and it will do a very admirable job picking a flag parsing library, hook up the machinery and remove those 1000 LoC.
•
u/gordonmessmer 3d ago
A shared library is a part of your application that's maintained by someone else.
Pro: Someone else maintains part of your application so you don't have to!
Con: You've given someone else commit access to your application, but in a way that gives you little to no insight or oversight of their changes.
Remember: Once your application becomes a process, there are no security boundaries. Every part of your application has full control of the application and can change the application any way it wants to. (Someone will surely point out that code pages are read-only, but remember that references to code pages usually aren't. It is usually possible to hijack/monkey patch functions.)
•
u/ExtremePermit3242 3d ago
I don’t know who the target of this article is.
All the points read like “this is obvious and software development 101”.
They grow project size, repo size, build time, you don’t use 100% of the library, a non-multiplatform library makes your project non-multiplatform?
In other news: water is wet
•
u/winian 3d ago
I once had to fix an incompatibility issue between two versions of a library after updating an in-house module, because some other guy had decided that he needed a third-party library for throwing an IllegalArgumentException in a slightly more convenient way. Some people need the obvious spelled out for them.
•
•
•
u/rechaptca 3d ago
is not about librariea that helps you print coloured text output, but please tell your manager you prefer to biild from scratch scheduling system like celery or cron rather to use solid maintained library. good luck. also 10years time frame is quite some time in software development that mayne wven your programming language or interpeter will be outdated (vide python 2.7 vs 3.6 vs current line). so yeah - if you have time and team to write everything from scratch and ok to tell your client you deliver in 6months instead of 1 then go for it.
•
u/Yay295 2d ago
The current project I'm working on is more than 20 years old, and the main issue I'm working on is that the libraries haven't been updated in 10 years and they have security vulnerabilities. So I need to figure out how to either remove the dependencies, or integrate 10 years worth of updates to the dependencies.
•
u/AndyKJMehta 3d ago
Jokes on him because every piece of code you write today is effectively a shared library of assembly calls
•
u/m_adduci 3d ago
Interesting, but isn't the usage of already made bricks one of the rules of Engineering?
Keeping a project Dependency-free spawns another class of problems and leads to the "not invented here" syndrome. You don't want to do your own cryptography, you don't want to create a new XML or Json Parser, you don't want to implement Database ORM yourself.
In an era where business is what at the end of the day matters, sinking too much time in getting things correctly and safely done might be counterproductive, especially in a time where AI-fans and enthusiasts (mostly from management levels) bring the argument that "AI is faster", because AI uses exactly those already made blocks.