Latest
What an AI Detector Score on Your Manuscript Is WorthThe One-Hour Call Before I Quote Your BookWhen a Client Thinks the Ghostwriter Used AIMonthly or Milestone: How Ghostwriting Gets BilledWhen Your Memoir Should Be a NovelWhat It Costs to Fix an AI-Written ManuscriptThe Clients Who Pay and VanishThe Quotation Marks That Get Authors SuedThe Work You Would Never Have StartedWhen Your Own Memoir Sounds Like BraggingWhat Belongs on a Copyright PageThe Hugging Face AI Agent Attack: An Operations ReadingBehind the Book: The Mysterious Island, Neb’s SideHow to Organize Decades of Memories Into a MemoirWhy Rotten Tomatoes Sucks: The Score Does Not Mean What You ThinkWhy Amazon KDP Sucks: They Terminated My Account OvernightIngramSpark: How I Publish Now and WhyWhy Fiverr Sucks for Ghostwriting: The Buyer’s SideWhy eBay Sucks Now: A Seller’s Numbers and a Buyer’s WarningThe Ghost Story TraditionThe Gothic TraditionThe Christmas Ghost Story TraditionResurrection as a Narrative StructureBooks to Give a WriterThe Beach Read ArgumentWhy It’s a Wonderful Life Failed on ReleaseWhat to Read in SpringWhat to Read in SummerWhat to Read in OctoberHow Warner Bros. Dismantled a $17 Billion Cartoon EmpireThe Imaginary Scarcity TrapThe Graph That Goes Vertical Is Usually Somebody Else’sSubstack Is Not Collapsing. The Promise Was.The Disasters That Happen to Ordinary PeopleToba: The Winter That Almost Ended UsJay Stifflemire: Nothing Ever Gets Written DownGeorgie-Ann Getton: I Forgot I Had Free WillAI Detection Cannot Be Evidence, and Publishing Is Using It That WayAI Consciousness Left Philosophy and Entered the LaboratoryThe Office Block Where the Bedrooms AreThe Web Got Fenced: What AI Search Costs Small SitesBlack Tuesday: The Web Ring War Nobody Outside It NoticedWhat the AI Visibility Industry Sells, and What the Evidence SaysBlack Tuesday: The Original ring-master.net Page, 2000Behind the Book: Peacekeeper, The Dissolution WarsBehind the Book: Real World SurvivalBehind the Book: Publish Your BookBehind the Book: ReincarnationBehind the Book: Sell Your BooksBehind the Book: Show Don’t Tell
The Writing King Your Ethical Ghostwriter. Your Story, Done Right.

I Spent Weeks Debugging Code That Should Have Been Deleted

This entry is part 2 of 21 in the series The Operations Room
TL;DR: If your team has been stuck on the same problem for more than a few days, the fastest fix is usually to delete the work and start over, and almost nobody does it. I lost weeks to a bug that turned out to be in the compiler rather than in my code. I was right about the cause. Being right did not ship the system. My boss threw my modules away, rewrote them, and the project moved.

Deleting work you already paid for feels like losing. Keeping it’s what costs you.

Developers using AI tools merge far more code than they used to and their organizations ship at about the same rate. One large study found pull requests nearly doubling while review time rose almost as much and delivery metrics stayed flat. A controlled trial found experienced developers working on mature codebases were slower with AI assistance, not faster, while believing they were faster.

Something is absorbing the gains. I think a large share of it is people fixing generated code instead of throwing it out and asking again.

Why do developers keep debugging code they should rewrite?

Because rewriting feels like admitting the last three days were wasted.

They were already wasted. The only question left is whether you spend three more. That’s the sunk cost trap, and knowing the name of it doesn’t stop anyone at hour forty, when you’re close, when the next idea is going to be the one.

The next idea is never the one. If it were, you wouldn’t be at hour forty.

Generating a fresh version now costs almost nothing. The economics that once justified grinding on existing code are gone, and the instinct that grew out of those economics is still here.

What happens when a bug is not in your code?

Early in my career I was the lead developer on a system for a rivet company. Rivets were the entire business. One product, made very well, and they were among the biggest in the country doing it.

We built their accounting and merchandising systems. Payables, receivables, general ledger, all of it, developed from nothing and delivered. I wrote software every night for months and I was good at it by then, which turns out to be part of the story.

Then I hit a bug I couldn’t find.

The program crashed hard and dumped a full screen of garbage. Not diagnostics. Garbage. Nothing on that screen told me anything about what had gone wrong or where.

I spent weeks on it. I read my code, rewrote sections, tested pieces in isolation, and got nowhere. Every day I was sure I was close.

Can a bug be in the compiler instead of your code?

The bug was in the compiler.

I proved it, which took a good part of those weeks. Then I opened a ticket with the vendor, a large computer manufacturer at the time, and that ticket was never resolved. As far as I know it’s still open somewhere.

Every developer is taught that the bug is in your code. The tool is used by thousands of people, your code is used by you, so the odds are overwhelming. That rule is correct almost every time.

Almost every time isn’t every time. When you land on the exception, following the correct rule costs you weeks, and there’s no way to know in advance which case you’re in.

The part under your control is how long anyone stays in the hole before getting help.

How do you know when to stop debugging and start over?

Steve Davis came in and fixed the project. He didn’t find the bug.

He took the modules I had been fighting with, threw them away, and rewrote them. That was the entire intervention. The rewritten code didn’t hit the compiler defect, the system worked, and the project moved.

I was right about the cause. Steve shipped the system. Only the second one mattered to the client.

I’d confused winning the argument with the vendor for delivering the work. Those are separate projects. The first one is satisfying and the second one is the job.

The rule I took out of it: when something has resisted you for a while, stop asking what’s wrong with it and start asking what it would cost to delete it. Usually the answer is less than you think, because you understand the problem far better now than you did when you first wrote the thing.

Is it faster to rewrite AI-generated code than to fix it?

Often, and the reason is the same reason as forty years ago.

When you debug code you wrote, you’re working with a model of it in your head. When you debug code a machine wrote, that model doesn’t exist. You’re reverse engineering a stranger’s work to repair it, and reverse engineering is slower than writing.

The research supports this. Independent analysis of code quality has found rising churn, meaning more lines written and then quickly changed again. One review reported a substantial increase in security defects in AI-assisted code. That’s the shape of work that was accepted before it was understood.

The alternative takes a minute. Throw it out, change what you asked for, generate again. The cost of the second attempt is close to zero and the cost of the third hour of debugging is an hour.

Almost nobody does it, because it feels like giving up.

How long should a developer work alone before asking for help?

Less time than they do, and the reason isn’t stubbornness.

Competent people don’t ask for help because they’re competent. I’d become a good programmer, so I believed I should be able to solve a programming problem. That belief is what kept me in the hole.

The weaker developer asks on day two. The strong one is still there on day twelve, making excellent progress on the wrong question.

A rule fixes this and it doesn’t require anyone to admit anything. Set a limit before the work starts. Half a day, one day, whatever fits. When the limit is reached, somebody else looks at it. Not because you failed, because that’s the rule.

What should a manager do when someone is stuck?

Steve Davis never chewed me out. That’s the part I still think about.

He explained what had gone wrong and how to fix it, and then we moved on. No lecture about how I should have come to him sooner. No comment on the weeks. He treated it as a technical situation with a technical answer.

I was a young developer who had just burned real time on a client project. He could have made a lesson out of it and I would have remembered the lesson. Instead I remember him.

Forty years later I’m writing about it, which tells you which approach lasts.

A manager who blames gets a team that hides problems until the problems are large. A manager who explains gets told about problems while they’re still small. Every operations leader knows this and a good number of them do the other thing anyway, because blame is faster in the moment.

What did the rivet project teach about shipping?

The systems went in and they worked. Payables, receivables, general ledger, merchandising. That company ran on them.

What I carried forward wasn’t a debugging technique. Nobody needs my method for isolating a compiler defect on hardware that no longer exists.

I carried forward two habits. Set a limit on how long anyone works alone on something that’s not moving. And when work has resisted you long enough, delete it and build it again with what you now know.

Both habits cost nothing. Both feel like retreat. Neither one is.

Frequently Asked Questions

How much time is too much to spend on one bug?
Set the limit in advance rather than judging it in the moment, because judgment in the moment is what fails. Half a day for routine work and a full day for something complex are reasonable starting points. When the limit hits, somebody else looks at it.
Should a small team let developers rewrite working code?
Rewriting code that works is usually a poor use of time. Rewriting code that doesn’t work, after a real attempt to repair it, is often the fastest path available. The distinction is whether the thing currently does its job.
Do AI coding tools make teams faster?
At the level of a single task, usually yes. At the level of delivery, the evidence is mixed, because review, testing, and integration absorb the gains. Teams that measure only speed of writing tend to overestimate what they got.
What is code churn and why does it matter?
Churn measures how much code gets changed again shortly after it was written. Rising churn suggests work is being accepted before it is understood, which moves the cost from writing into maintenance, where it’s harder to see and more expensive to fix.
How do you tell a developer their work should be thrown away?
Frame it as a decision about the code rather than about the person, and make the call yourself so the developer doesn’t have to. Explain what will be different in the second version. The second version is almost always better, because the problem is understood by then.
Is it worth reporting a defect to a vendor?
Report it, and don’t wait on it. Vendor tickets can sit unresolved for years, and the project still has a deadline. Work around the defect first and file the report afterward.

📝 Disclaimer

The views and opinions expressed in this blog post are solely those of Richard Lowe and are based on personal experience and research. This content is for informational purposes only and should not be construed as professional legal, financial, accounting, or business advice. Always consult with qualified professionals before making important business or legal decisions. Richard Lowe is not a lawyer, accountant, or licensed professional advisor, and this content does not establish any professional relationship.

0 comments

No comments yet. Yours can be the first.

Was this useful?

Leave a comment