Live data from Hacker News

AI is forcing us to write good code

bits.logic.inc

191–200 of 229 posts

Re: AI is forcing us to write good code

#191

This is hallucination. Or maybe a sales pitch. If production bugs and the requirement to retain a workable code base don’t get us to write “good” code, then nothing will. And at the current state of the art, “AI” will tend to make it worse.

The first sentence is problematic: > For decades, we’ve all known what “good code” looks like. When relatively trivial concerns such as the ideal length of methods haven't achieved consensus, I doubt there can be any broadly accepted standard for software quality. There are plenty of metrics such as test coverage, but anyone with experience could tell you how easy it is to game those and that enforcing arbitrary stan…

> When relatively trivial concerns such as the ideal length of methods haven't achieved consensus

Is the consensus not that there isn't one? Surely that's the only consensus to reach? I don't see how there could possibly be an "ideal length", whatever you pick it'd be much too dogmatic.

Re: AI is forcing us to write good code

#192

Wouldn't a better title be "How we're forcing AI to write good code (because it's normally not that good in general, which is crazy, given how many resources it's sucking, that we need to add an extra layer on top of it and use it to get anything decent)"

> which is crazy, given how many resources it's sucking Gentleman, the dog writes poetry and music, but it is boring, mediocre quality. Overhyped dog.

That is a great description of current AI, actually. Love it.

Some people are amazed the dog can write poetry. Some people complain that the poetry isn't good enough.

Re: AI is forcing us to write good code

#193
I spent so much time getting the mocks right with AI tests and the tests could not be one shotted or done by an inexperienced intern. Certainly don't have the budget to through Claude Opus on it, I'll give it some time though maybe things change.

Re: AI is forcing us to write good code

#194
post #60

I thought that the article would be about if we want AI to be effective, we should write good code. What I notice is that Claude stumbles more on code that is illogical, unclear or has bad variable names. For example if a variable is name "iteration_count" but actually contains a sum that will "fool" AI. So keeping the code tidy gives the AI clearer hints on what's going on which gives better results. But I guess tha…

Humans can work with these cases better though because they have access to better memory. Next time you see "iteration_count", you'll know that it actually has a sum, while a new AI session will have to re-discover it from scratch. I think this will only get better as time goes on, though.

Unfortunately, so far coding models seem to perform worse and break in other ways as context grows, so it's still best practice to start a new conversation even when iterating. Luckily, high-end reasoning models are now catching when var names don't match what they actually do (as long as the declaration is provided in context).

Re: AI is forcing us to write good code

#195
post #44

This is sort of why I think software development might be the only real application of LLMs outside of entertainment. We can build ourselves tight little feedback loops that other domains can't. I somewhat frequently agree on a plan with an LLM and a few minutes or hours later find out it doesn't work and then the LLM is like "that's why we shouldn't have done it like that!". Imagine building a house from scratch and…

You can install a Canadian one just fine; authorities might not like it in some jurisdictions though but it's safe and might even be code.

I literally just had this exact argument; biggest issue is they can be tested for smaller amperages but you just downside the breaker.

Re: AI is forcing us to write good code

#196
I'd be interested to hear how they reconcile ‘100% code coverage’ with ‘QA needs to run fast’ on a large codebase.

I'd also really love to see a study around how much of the effort it takes, on average, to write (by carefully shepherding an agent or otherwise) bullet-proof tests and other guardrails for the LLM-generated code divided by the effort of writing the code by hand.

Re: AI is forcing us to write good code

#197

Earlier quoted context omitted.

Self-teaching pretty much doesn't work. For many decades now, the barrier has not been access to information, it's been the "self" part. Turns out most people need regimen, accountablity, strictness, which AI just doesn't solve because it's yes-men.

> Self-teaching pretty much doesn't work. For many decades now, the barrier has not been access to information, it's been the "self" part. That’s a complete bogus. And LLMs are yes men by default, nothing stops you from overriding initial setting.

They're fundamentally trained to agree and don't do well when they require challenging ideas they're not "confident" about

Re: AI is forcing us to write good code

#198

> Entire categories of illegal states and transitions can be eliminated. I have an over-developed, unhealthy interest in the utility of types for LLM generated code. When an llm is predicting the next token to generate, my current level of understanding tells me that it makes sense that the llm's attention mechanism will be using the surrounding type signatures (in the case of an explicitly typed language) or the com…

Completely agree with your on the types. Will be interesting to see what new post-AI programming languages look like and I suspect they will all be strongly typed.

Re: AI is forcing us to write good code

#199

Earlier quoted context omitted.

Self-teaching pretty much doesn't work. For many decades now, the barrier has not been access to information, it's been the "self" part. Turns out most people need regimen, accountablity, strictness, which AI just doesn't solve because it's yes-men.

> Self-teaching pretty much doesn't work. For many decades now, the barrier has not been access to information, it's been the "self" part. That’s a complete bogus. And LLMs are yes men by default, nothing stops you from overriding initial setting.

It's not bogus at all. We've had access to 100,000x more information than we know what to do with for a while now. Right now, you can go online and learn disciplines you've never even heard of before.

So why arent you a master of, I don't know, reupholstery? Because the barrier isn't information, it's you. You're the bottle neck, we all are, because we're humans.

And AI really just does not help here. It's the same problem with professor Google, I can just turn off the computer, and I will. This is how it is for the vast majority of people.

Most people who claim to be self taught aren't even self taught. They did a course or multiple courses. Sure, it's not traditional college, but thats not self taught.

Re: AI is forcing us to write good code

#200
I agree with the sentiment but I find this definition of 'good code' is a bit superficial for my liking.

Especially the part about TypeScript. My experience is that LLMs such as Claude Code work really well with vanilla JavaScript. Once you switch to TypeScript, you're tapping into a different language training set which is much smaller than the JS training set and which adheres to different conventions and principles.

The part about good test coverage makes sense though I don't know if 100% coverage is the specific goal to aim for. You can have 100% coverage in terms of lines of code but don't test the relevant parameters which cause issues.

My definition of good code is more about architecture; modularity, separation of concerns, minimal interfaces, choosing good abstractions and layering them appropriately, clearly separating trust boundaries with appropriate validation... Once the LLM sees certain things, it lets you tap into a "world class software engineer" training set.

A lot of the points mentioned in the article differentiate junior developer from mid-level developer... If you want the LLM to output 10x software engineer quality, the patterns are different and more nuanced... Goes beyond just having good test coverage.

Post reply on HN