r/programming • • Sep 04 '26

Avoid adding new library to project: 10-year retrospective

https://pvs-studio.com/en/blog/posts/1408/
170 Upvotes

35 comments sorted by

View all comments

Show parent comment

5

u/TOGoS Sep 04 '26 edited Sep 04 '26

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.

Speak for yourself. I've avoided cryptography for the most part, but otherwise there have been times when I absolutely did want to each of those myself (as a new library) rather than use some third-party library.

JSON parsers are trivial enough that rolling your own is often cheaper than pulling in a dependency.

ORMs in Java tend to be a bit of a wrongly-engineered nightmare full of mutable state and spooky action at a distance. So rolling your own of those that fits the needs of your application and not what somebody else thought they wanted is also understandable.

6

u/CharmingComputer3844 Sep 04 '26

It's a fine line between wanting control and ending up reinventing the wheel. Sometimes, the simplicity of a well-established library can be a lifesaver.

8

u/m_adduci Sep 04 '26

Absolutely. There are so.many edge cases lurking out there and many libraries are meanwhile so hard battle tested that inventing something by yourself is much more painful.

Examples: curl, openssl, Jackson, opencv

3

u/-Y0- Sep 05 '26

Forget those, having a decent XML library that handles ALL the edge cases is a godsend.

4

u/b0w3n Sep 04 '26

ORMs in particular can be kludgy to interface with and bloated out the ass in features most people are never going to use.

Also serialization is another one, "just use xml or json" okay that's cool and all but it's slow. Binary can be better! At least I don't have to worry if some russian spybot has snuck some horseshit into this library I'm using for some of those simpler things that might not have a lot of eyes on it.

1

u/-Y0- Sep 05 '26

Binary can be better!

Good luck debugging Binary. And ensuring it works correctly if source and target systems are different Endians.

2

u/-Y0- Sep 05 '26 edited Sep 05 '26

JSON parsers are trivial enough that rolling your own is often cheaper than pulling in a dependency.

HAHAHAHAHAHAHAHHAHAHAHAHAAHA.

No.

Now realize that JSON is the simplest possible of these challenges. And it's a fucking nightmare.


Reminds me how one particularly smort individual managed to implement a "rough" XML parser as output verifier. It even supported namespaces! ... Except it didn't check what XMLNS expanded names, but checked only namespace by prefix.

Took me 12hrs to debug that exceptionally smart piece of NIH-engineering. I didn't have the code, and was convinced for the first 8hrs that there was an error in my XML somehow. Next 2hrs was spent decompiling and cursing the idiot in question.