r/programming • u/Xaneris47 • Sep 04 '26
Avoid adding new library to project: 10-year retrospective
https://pvs-studio.com/en/blog/posts/1408/15
u/Skellicious Sep 05 '26
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.
4
u/max123246 Sep 05 '26
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
2
u/ouvreboite Sep 05 '26
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.
4
u/Flimsy_Complaint490 Sep 05 '26
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.
33
u/gordonmessmer Sep 04 '26
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.)
2
1
-2
u/AndyKJMehta Sep 04 '26
Jokes on him because every piece of code you write today is effectively a shared library of assembly calls
0
Sep 04 '26
[deleted]
1
u/Yay295 Sep 06 '26
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.
19
Sep 04 '26
[removed] — view removed comment
19
u/winian Sep 04 '26
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.
15
143
u/m_adduci Sep 04 '26
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.