r/cpp • u/Xaneris47 • Aug 20 '26
More fuel to AI discussion. An article on code bloat and duplication
https://pvs-studio.com/en/blog/posts/cpp/1402/I think code duplication is honestly the only reason LLMs manage any of this. Idea, architecture, implementation -- that's basically the chain, and LLMs are fine at the first and last, it's the middle that falls apart. Get it to actually structure things, kill the duplication and something you changed in one spot breaks another spot that has nothing to do with it. Duplicated code just sidesteps the whole issue, because then it only needs a tiny bit of local context to make a local edit
35
Upvotes
•
u/STL MSVC STL Dev Aug 20 '26
Ironically, I think your description (not the post) is AI-generated. If so, please don't do that here, read the sidebar rules.
18
u/LiliumAtratum Aug 20 '26
After reading it and using some AI in my own coding, I am realizing that there are different approaches to how AI is used.
I conceptualize tasks myself, and send smaller tasks to AI, confirming that I like what I see. If I see a chance for an abstraction, I discuss if this would make code shorter/simpler to understand (sometimes it doesn't due to some minor details). Sometimes even AI is perfectly capable to recognize and abstract something out for me, without me prompting it.
I never just ask for a big task and ignore the results that happen in my code.
So, when I see a situation as the one presented here, I am a bit surprised (maybe I shouldn't be). I guess AI is just a tool and how you use it can have a big impact on what you get. It's just easy to go either way.
16
u/Total-Box-5169 Aug 21 '26
The end game of AI corporations is to maximize their profits. Customers unable to maintain the code generated become fully dependent on AI. That is why Felon Musk wants AI to output a binary instead code that can be maintained without AI.
8
u/SyntheticDuckFlavour Aug 20 '26
LLMs are steroids for the experienced programmer. If you have a clear vision what needs to be done, it can be a massive productivity boost. I used it successfully for refactoring, doing menial and repetitive tasks, implement boiler plate work. Like I ask it to dependency inject one thing into another, the LLM does a good job. It is also good at modernising code. One most impressive feat I saw is when I wrote stubs and APIs for a curve fitting algorithm. I simply asked Claude to read a PDF academic paper describing the algorithm then told it to implement that and fill the gaps for the stubs. It did it on first try and worked. Had to optimise it afterward, but was fairly close to being usable on first go.
1
u/thisismyfavoritename Aug 20 '26
totally agreed!
-14
u/eyes-are-fading-blue Aug 20 '26
The idea of full agentic development people is that you don’t need to read the code. If that’s the case, duplication is generally (almost exclusively) irrelevant.