Live data from Hacker News

There's No Limit to How Bad Code Can Get

zachkehs.com

71–80 of 87 posts

Re: There's No Limit to How Bad Code Can Get

#71
post #15

One of my first jobs, was as a maintenance engineer, on a 100KLoC+ codebase of 1979s-era FORTRAN IV. No comments. No subroutines (what we now call “functions”). No variable name longer than 4 characters. Fun. The most effective debug tool, was a Ouija board. It made me an expert WAGger. It was the main reason that I am so anal about code Quality, these days. I never want to subject anyone else to that. BTW: with toda…

I've seen "clean" codebases that conform to "best practices" which are even less decipherable than what you describe. 100KLoC sounds like paradise compared to the latest codebase I touched. Having the signal to noise ratio fluctuate wildly at every member & file is highly distracting. When the information is dense and consistent, you can drop into a flow state more easily. Four character variable names might sound aw…

Eh. I've found a "happy medium." I generally restrict comments to headerdocs at the function and property level. I use descriptive names, and keep the functions relatively small and task-oriented, so they do a fairly decent job of documenting themselves.

Every now and then, I'll insert a "why" comment, if I feel it's necessary.

I wrote about my technique (and reasons), here: https://littlegreenviper.com/leaving-a-legacy/

Re: There's No Limit to How Bad Code Can Get

#72
As I read this article, as a non-coder (for a living) I noticed that what is being assumed is that the code produces a desired result. To that I will agree. You can really produce some bad code that has a positive outcome.

But as a counter proposal, I will submit that code can get so bad, that the product no longer produces a desirable result, no longer produces it in a manner that people want, or doesn't produce it at all.

Code that produces no desirable result or no result at all. Is as bad as it's going to get. It's a worthless pile of ASCII characters.

Re: There's No Limit to How Bad Code Can Get

#73

As I read this article, as a non-coder (for a living) I noticed that what is being assumed is that the code produces a desired result. To that I will agree. You can really produce some bad code that has a positive outcome. But as a counter proposal, I will submit that code can get so bad, that the product no longer produces a desirable result, no longer produces it in a manner that people want, or doesn't produce it…

Oh and by the way, I will also submit that there is a form of bankruptcy for technical debt.

The company folds, or the software is no longer maintained or in use.

When was the last time you used word Perfect? Or MS-DOS?

Re: There's No Limit to How Bad Code Can Get

#74

Earlier quoted context omitted.

There is a lot of noise out there from anti-AI types who never seriously tried to clean up messes with AI. If you just ask for new features and never look at the code, coding agents will make a mess. If you often ask questions about how to clean up messy code, coding agents are great help for that, too. But you have to ask.

asking to clean up is not enough, it is needed to understand the code and fix the things the agents are getting wrong.

It's true that you need to ask good questions to get good results. If you try to understand the code yourself, you will ask better questions.

Re: There's No Limit to How Bad Code Can Get

#75

2 things 1. LLM can fix this in my experience. an LLM, especially the more modern ones, have way more short term memory than most humans (or at least way more than me). They can dig through this kind of code and figure out all the edge cases, write test, suggest various paths to make things better and then execute on those paths. On request they will happily setup dev systems, staging systems, whatever it takes to ma…

For 1, effectiveness still depends on the size and complexity of the codebase. From my experience, as complexity and size grow, each prompt takes longer, does less, and is prone to more mistakes and disruptions to other parts of the codebase.

The code base I work on is > 30 million lines (excluding comments and blank lines) and most (but not all) of the people on the team are finding it pretty effective. That doesn't mean it wouldn't be more effective on a smaller code base.

Re: There's No Limit to How Bad Code Can Get

#76
Insightful article. The author makes some great points about the dynamics of technical debt in organizations.

I think a sinking ship is a reasonably good metaphor though. A sunken ship is a horrible, terrible outcome.

In the metaphor, a codebase is sunken when it’s unviable to continue using it. The organization stops working on it and no longer runs it. At this point, the code is completely worthless to the business, like a ship at the bottom of the ocean. True, you could imagine the code getting worse theoretically. But in reality, it will just sit there and rot.[0] The business might attempt a rewrite or just discontinue the product.

It’s possible, but not a given, that a business sinks with one of its codebases. This can happen with a ship too, if a business relies heavily on it.

[0] https://en.wikipedia.org/wiki/Software_rot

Re: There's No Limit to How Bad Code Can Get

#77
post #52

Earlier quoted context omitted.

> You can write a thousand lines of commercial-grade spaghetti, and tell the LLM to format and document it. Yes, you can tell the LLM to format and document it. You can also tell an effigy of Richard Nixon, or write it on a piece of paper and burn it. Of course you can do such things, but the important question is what that gains you. Yesterday I vibe slop coded something, being very lazy about it, it being a throwaw…

The problem with using LLMs to write Javascript is that they’re trained on Javascript written by humans. Which is not the training corpus I’d choose to teach a neural net to write code.

I laughed. Point noted. And yet, what do you have that's better?

We could train it on a carefully-curated best-practices corpus, but that's likely to be considerably smaller. It might not have the breadth of coverage that one would wish for a training corpus.

Re: There's No Limit to How Bad Code Can Get

#78
post #52

Earlier quoted context omitted.

> You can write a thousand lines of commercial-grade spaghetti, and tell the LLM to format and document it. Yes, you can tell the LLM to format and document it. You can also tell an effigy of Richard Nixon, or write it on a piece of paper and burn it. Of course you can do such things, but the important question is what that gains you. Yesterday I vibe slop coded something, being very lazy about it, it being a throwaw…

The problem with using LLMs to write Javascript is that they’re trained on Javascript written by humans. Which is not the training corpus I’d choose to teach a neural net to write code.

Well then you'd have somewhat of a chicken-and-egg problem. But humans came first so at least there's that.

Re: There's No Limit to How Bad Code Can Get

#79
post #65

Earlier quoted context omitted.

Yeah that's why step 0 is to tell the LLM to write a test suite for the thing you want to rewrite. It'll do that, but it does require adult supervision. Once you have that test suite, you can send the LLM into an inner dev loop. Like human programmers, LLMs are great when they have a fast inner loop. The fact that LLMs exist doesn't mean you can just stop thinking. It mean the things you have to think about will be d…

There’s a trap here though: the LLMs if you let them will spend all their time maintaining that test suite, they can become quite rigid in the way they design them. So it’ll write some code, break a test, which breaks a contract so then it updates the test and the contract but updating the test also broke another contract… soon enough you’re spending all your tokens fixing contracts instead of writing code. In a sens…

Sounds like one of the teams I left before project completion 13 years ago.

Re: There's No Limit to How Bad Code Can Get

#80
post #46

The worst experience I had was with a telecom company. They had an internal web app that allowed them to upload a gigantic CSV file with millions of records from new phone activations. The web app took 59 minutes to process it! The culprit: a single 30K .js file with one function, more and more recursive functions, and deeply nested if/else statements, up to 10 levels. We spent one month undoing that Gordian knot and…

If it only took 59 minutes to process millions of records, it was nowhere near as bad as it could have been. At around one millisecond per record, it sounds like you probably don’t even have any accidental quadratic time complexity on the number of records! What are you complaining about?

I know a phone company where just the cronjob that sends bills took over 3 days to run. I guess it's not a problem until it takes more than a month.
Post reply on HN