by davedx · 2mo ago · 0 comments
"Code maintainability and good architecture don’t have good measurements that we can apply"
Who has no wisdom? There are dozens of ways to measure code maintainability. Cyclomatic complexity is just one.
Nothing stops you from wiring up something like SonarQube metrics to your agentic coding workflow.
Cyclomatic complexity has been pretty solidly discredited within the maintainability research community for decades.
Sonar's cognitive complexity metric is a bit better, but here's a study that found that it still only has about a 0.5 correlation with how much difficulty programmers actually had reading code as measured by multiple methods.
They found that the most accurate way to measure code complexity that didn't involve something like an eye tracker or EEG is still basically just vibes - asking programmers if they thought it was hard to understand.
https://www.frontiersin.org/journals/neuroscience/articles/1...
Halstead Effort came in second, and scored pretty well, but here's another one where it doesn't do so well, either. And it scores the SonarQube metrics even worse, with only a 0.35 correlation: https://www.sciencedirect.com/science/article/abs/pii/S01641...
I definitely wouldn't want AI to be autonomously using that as a guide without doing some fairly serious internal A/B testing first. Kind of like for cyclomatic complexity, it's just too easy to find ways to maliciously comply. And if that's what you ask AI to do then that's likely what you're going to get.
There's the rub. It requires knowing about and caring about maintainability. And a lot of the people who "haven't written a line of code since 2025" don't care
I’m beginning to believe that if this was a “solvable” problem then the billions of dollars poured into coding agents would have solved it by now.
I like this framing. Humans invented software (and engineering in general) as a means to solve problems with methods that work best for us. There may be entirely different, and parallel, problem-solving methodologies outside of human best-practices.
> There are dozens of ways to measure code maintainability.
There are no good ways. I'm averse to making absolute statements, but here I'll take that chance. I worked in dev producitivy for years with people who spent decades in that domain across multiple companies with very high volumes of code production. Everybody agreed: All metrics are flawed and even a combination of metrics is insufficient.
Just to give one fundamental reason (in addition to a lot of the sibling comments): for any given metric there are an infinite set of counter-examples that don't trigger any thresholds but are clearly bad code. So these metrics typically only help in trivial cases, don't catch a majority of the cases, and so often become more of an annoyance due to low SNR. A lot of dev productivity work ends up being wiring these metrics in and then providing escape hatches when they inevitably get too noisy!
And most relevant to this discussion: these tools do not say anything about higher-level concerns like architecture, over-engineering and design, which IME is where agents tend to mess up most. I've almost never had a complaint about the code itself; the logic, naming, functions, data structures, even a lot of the testing, are all on point. It's always been the higher-level structure and design: over-engineering, duplicate classes, suboptimal abstractions, redundant operations across layers that could be solved by adding a single variable in a class, etc. etc.
I think the problem, like with code written by humans, is lack of sufficient context while doing a task leading to tunnel-vision. This is why we need to oversee and ensure things are good holistically. I suspect models are now good enough to play the role of an architect as well, though, and I've read some indications of that online... I just haven't tried giving them that much control yet.
You say that like adding "Make it maintainable." to your prompts solves the problem. But the reality is we only have weak metrics for measuring maintainability. For example, you can trivially optimize for Cyclomatic complexity by blowing away abstractions and duplicating code everywhere. That doesn't make the code better. Cyclomatic complexity is a tool that has to be applied judiciously.
That doesn't mean you can't or shouldn't use AI to generate code. But it does mean if you want your project to scale, you're still going to need a lot of developer involvement at the code level to ensure the code remains maintainable so that future developers can build on top of it. AI is not like compilers, which allow developers to build complex solutions without being proficient at the next level down (assembly).
Yes. But I think the idea is without "hand written domain driven design development" the result trends to "vibe coded by someone with no technical knowledge or inclination," as developers de-skill.
Somewhat relevant parallel..
Calculators exist, but not all is lost:
- lot of (most?) people can do basic multiplication (I’m too lazy to fetch any stats but I hope you’ll have some observations in your bubble dear reader)
- some people actually compete in mental calculations https://worldmentalcalculation.com/mental-calculations-world...
Same will be with software devs, enthusiasts will continue to exist.
So are you agreeing with me or not? Because it's not black and white. Having a few non-deskilled developers around who do the equivalent of "compete in mental calculations" is the same as having none at all.
It's sort of like the retort "AI won't take all the jobs from humans, some will be left [at the very top and very bottom]." Even if true, fat lot of good it does most people who would be unemployed in that scenario.
Also, if you get widespread deskilling, but massive increases in code production due to AI, you're probably still going to get "organizations falling into the trap" like the OP describes and the remaining skilled people getting burned out trying to hold it all together. Modern American business culture (in aggregate) is incapable of learning to not burn people out until everyone is already burned out, only then will it pay attention to the problem (and then probably forget what they learned and start repeat it in 10 years).
You make it A bit black or white.
Llm will not take jobs, at worst it will shift jobs.
If we will allow current llm to develop code without inspecting it, we will still want to provide direction and expect certain quality level. So in “worst” case you will need at least design/QA people.
If code will be free, and it will increase 1000x, you probably will need 100x design/QA people. (Unit tests written by same llm, if not reviewed are worthless as assurance). I’m absolutely certain that humans will have plenty of software related jobs.
As to programmer deskilling, another parallel: lot of programmers have very little knowledge of how to deal with databases correctly/efficiently, because they are somewhat lazy and good tooling/orms allow to get away with it, but there are also plenty of devs who do know how db works and how to design a db schema for their app access as it improves overall system performance and correctness. Same with LLM case, having knowledge of what happens in code, gives an edge, and competitive/curious/overly-responsible people will continue reading things in depth (llms also make learning somewhat easier). And its definitely not 1%.
Furthermore, llm prices are subsidised a lot now, so it’s yet to be seen if llms are economically viable as vibe coding agents on a large scale.
All will be ok, don’t worry too much.
Somewhere in the middle of that continuum sits - "domain driven specifications, described using high level english concepts(that are well defined) from the domain , combined with a selection of a few standard architectures"
> code maintainability and good architecture don’t have good measurements that we can apply, because it takes months, years even, to notice the effects of bad architecture or of unmaintainable code.
One way of understanding "good" here is "actionable", imho.
Induction fallacy at its best
But that's not actually a change. Humans wouldn't magically make everything maintainable if you don't tell them to (and maybe not even if you do). You have to monitor them and train them, carefully, basically forever.
The trillion dollar question is how you do this, if your employees do not care (they are optimising for salary & time spent not code quality) and you have no way of telling apart AI slop vs. good maintainable code. (If you could you would just train the AI.)
Before AI there was at least some way to tell apart good programmers from bad, because there was some human effort involved in coding. Now with AI and slop generation there is almost now way to do this.
From what I see is it's mainly managers and higher brass who doesn't care about code quality and sustainability, and aims to drive time to market metrics down aggressively with AI.
Any employee who cares about code quality will become a poor performer with a red luddite label because they dare to change what the AI has emitted for them.
I'd love to be wrong, very wrong about this, actually.
Developers, however, are still responsible for the code! We must review the AI....all 80k lines of code it generated yesterday. If we don't then we are at fault. And we must go full throttle of course. So ....not be picky and retrograde about accepting what is generated.....
IOW we know who is going to get screwed and it isn't them.
Trends over time will drive more observable changes. If a whole generation of programmers picks up bad habits that their managers don't care about (think very junior), that will take some time to play out. It's like children's literacy. You don't notice overnight, but a decade of neglect and you have a reading problem in kids.
Go fast and break things has been a mantra for how long?
I think a lot of the laments about "good" code are really about "ownership" - and as someone who spent most of my working career in OTHER peoples code bases I have seen some things. There are a lot of you who think that your code bases are "great" when they are NOT. Personal understanding is not a good measure of quality.
The increased cadence from AI is just speed running to the legacy code base.
The answer: express the concern, and reiterate it after every issue that arises because of increased complexity. Start building a plan on how to "unravel" the mess, how to migrate things in place, how to start drawing boundaries in your systems. The system is designed to reward heroes who fix problems - you want to be super man who stops the bridge from falling apart, not the engineer who pushes the costly fixes it before it does.
Practically since eternity, but just as we learnt to manage current rate of "fast" and "breakage", somebody attached a solid booster behind us. So we're trying to understand what happened and what's happening and what will happen.
> I think a lot of the laments about "good" code are really about "ownership"
People owning what they did, have responsibility and initiative about doing better is always a good thing, yes.
> and as someone who spent most of my working career in OTHER peoples code bases I have seen some things.
I can understand that, I'm sorry you had to go through this.
> There are a lot of you who think that your code bases are "great" when they are NOT. Personal understanding is not a good measure of quality.
My codebases are as great as my knowledge. I love when someone reads my code and points where I f'ed up. I also love to show what I did has achieved something I was aiming for and discuss how to achieve it betterer.
> The system is designed to reward heroes who fix problems...
And this is the problem. Because I work silently and diligently build something looking unimpressive while working like an atomic clock without any problems.
I think that's true but it's a special case. AI is here to stay and with AI coding IS faster and quality is better than ever before. Ideally you want your luddite fired along with the slop generators and keep the ones who are using AI and taking their time to deliver a maintainable code.
Is this claim based on something?
I'm not against or "for" AI (whatever that means), I try to use it as effectively I can, but for me it's not at all obvious that quality is better than ever before.
Speed I can buy, especially in new projects and utilities, but quality? At least I haven't seen this in practice, if anything I'm just seeing more code, issues, PR's and pressure ==> more slop, more bugs, less quality.
You can always say "skill issue" and "process issue", but that's partly my point here, AI doesn't magically solve this.
Maybe it's true that lots of people aren't taking advantage of this and are shipping trash, but that's their own problem, and there have always been people who do the job poorly.
Localised quality is great; whole-program (even small ones) are not usually readable by me.
That's true, but it doesn't have to stay in this form.
> with AI coding IS faster and quality is better than ever before.
Citation needed, because the last study I read about was painting a completely different picture about code quality. Also, just because the AI pulling and remixing code from a known repository with high quality doesn't mean your code will be at the same quality automatically. Passing tests is not enough.
> Ideally you want your luddite fired along with the slop generators.
The thing is it's not possible to see who generates slop and who generates code, and if you fire the only people who knows about the codebase intimately, you'll be on a very exciting, possibly fatal ride. I don't recommend this. AI doesn't know your history and trade-offs. These guys do, and can guide you to clear.
AI can't.
Believing that AI will create bug-free code from start is believing that Rust is the silver bullet.
There are no silver bullets.
Sounds like there is a compensation problem then.
It's not that hard: treat people with dignity and take their contributions seriously, not as a disposable meat mass. In fact, not only will this improve code quality, it's likely to improve employee retention too.
Try using an LLM to rewrite an LLM output without the slop (vs asking for no slop to begin with) or sandboxed subagents that critique a parent's draft.
There is absolutely a step-function improvement in quality but: 1) not everyone wants to explode their cost by adding extra calls 2) this can't just be "trained in" to a system as obviously they have attempted this but the technique still provides an uplift.
There were only bad ways, and the best way was to just find people who were both good programmers and cared about quality to keep an eye on the rest. Nothing much has changed in that respect.
I don't think it's that hard of a question to answer. I've noticed on my team, our thinking has shifted from how do you directly solve a problem, to how you get an agent to effectively solve the problem and not produce slop in the process.
One thing that we have done that's probably made the biggest impact is alot more upfront architecture with the knowledge that pretty soon agents will be running wild all over the code. Having worked with these agents for a while now, you get a very good sense of how they will go about solving a problem and the various footguns they will encounter along the way. Editing an AGENTS.md file or building a skill is not nearly as fun as coding by hand but it will pay dividends over and over if you do it right.
Another big thing is doing refactoring passes. Early on in our projects our agents generated ALOT of slop and we had to go back and fix alot of it. But every time we did one of these passes, a major aspect was improving agent instructions / skills / etc so it doesn't happen again. It can be a painful process at first but I found that over time, the amount of slop the agent produces goes down by orders of magnitude.
I feel like we're still very much programming, but we're now doing it at a "higher level" where we are not writing the code ourselves but instructing the agent to. And IMHO, properly instructing an agent on a production codebase is not a trivial task.
I know how to distinguish good maintainable code from garbage. I have known for quite a few years. But knowing how to train someone, or an AI? I'm a good coder, not necessarily a good teacher. And there are things about code that I _feel_, not that I can rationally explain.
You might write good, maintainable code, but they will prefer the slop generator who delivers quicker.
SonarQube
I guarantee you will pass the gate, and the code will still be dumb, except now you'll spend 10x the tokens.
That's why companies were interviewing people on tasks that had nothing to do with writing maintainable software. /s
I understand the concern and it should be addressed and researched. But, simply saying "humans were writing code themselves" doesn't provide any evidence for better quality.
I for one, have far more rigorous quality checks in my hobby projects (where AI coded), than I ever could justify when I hand-coded them.
I'm not claiming to be everybody, but surely a good portion of the population are using these technologies similarly.
I do think this gets to the heart of the matter. I think many programmers have missed the forest for the trees on why things like data structure and code complexity matter. They do matter, but they don't matter in and of themselves. They matter because they are the best techniques we have for making software that is of high quality (the software, that is, not the code) and which remains so over time, while continuing to be developed and adapted.
I strongly believe that it is now much easier to create software that is of high quality and adaptability, orthogonally to the data structure and code complexity concerns. Those concerns remain relevant, but it's a mistake to think of them as the primary thing rather than things that support the primary thing
Yet.
I'm sure in few years, as new criteria enter benchmarks, AI will be creating the clearest and smartest code people every seen, by default.