Ask HN: Why do people say LLMs create bad code "quality"?
Happy Thanksgiving! For context, the only time I've been exposed to "good quality code" was when I interned at a YC startup. I am creating my own startup at the moment. I keep hearing that LLMs create "bad quality code" and wondered what that meant? I've been trying to use Claude Code in the development of my app. If I am the one architecting the functions and services, making sure they are high cohesion loose coupling, abide by service oriented architecture, etc. and only having LLMs implement the functions themselves and not touch the architecture, will this ensure "better code?" What is "good quality code?" Why do LLMs inherently create bad quality code, and what ways should I AVOID using them?
Thank you kindly. Best Chai
Chaidhat Chaimongkol
When i started using LLMs for code writing the code it wrote was messy and mostly wrong. Recently my experience with relative small apps has been very positive. The code has been very readable and compact. But I can see where the code can get very messy if you don't have a structured plan for code development. It's very easy to create a messy code base that's hard to maintain.But the reality is that human developers do the same thing regularly.
I think that keeping the code that the LLMs write relative small and highly focus will lead to a code base that's easy to maintain over the long term.
I plan to create an app that relies heavily on LLM written code. I'm hoping that if I architect it as if am working with a team of programmers I'll be able to create a code based that I can update over the long term. I'll assign it assingments that I can then merge into the master codebase. You're in the same path. That's 2 of us. I think it will work out. We'll get what we want while saving a ton of time.
- deprecated api use - mixture of styles vs one consistent hand throughout the code. - implicit code vs declarative - convoluted logic when there’s a simpler way. Sometimes complexity just for the sake of it (basically it’s all spaghetti code to me until I edit it myself)
Even thought the code quality is garbage ~90% time (to me), it’s still more fun than before—which is why I still use it.
Woe on to you though if you vibe code and don’t edit and don’t have taste from years of doing it manually before LLMs. You are building a mountain of tech debt (although maybe you can grow and hire fast enough to where that’s not an issue).
Garbage in, garbage out. Beautiful code in, beautiful code out.
Code "quality" is a judgement call. Just like some LLMs, I'll repeat your question: What do you consider quality code?
I treat all code from LLM, search, stackoverflow, etc, as "sample code" that requires review and most likely modification, or writing the code from scratch. Your abilities and laziness may vary.
Also, there are reasons other than code quality not to trust LLMs.
"AI" generated code often has a number of styles in the same functions or modules. In an "AI" generated bash program I recently reviewed, the code had both "if [ testtesttest ]" and "if [[ testtesttest ]]" styles along with different styles of testing lexical equality.
It also had a globbing test I'd never seen before, something like "if [[ $X = *"string"* ]]". It works, but wow, ugly.
The new bash program looked old, like someone with a distinct set of preferences wrote it years ago and 2 or 3 maintainers had hacked on it, being less careful to keep a consistent style.
That sort of thing would be judged low quality legacy code 5 years ago. It's harder for a human to understand, and since it just might depend on a peculiarity of "=" vs "==" vs "-eq", people make minimum changes or maybe no change at all. That's one way "low quality" you seek is exhibited.
The perception is that it's sloppier than what humans write. I wouldn't waste too much time worrying about that if the code is solving your problem. Sounds like you need to focus on getting a MVP to show to potential customers and if LLMs help you get there faster, so be it.
Thank you! That is a good take on things. If it works, it works. If it fails, then a customer complains and we fix it + make sure other code doesn't suffer the same error.
Good luck!