Live data from Hacker News

AI is forcing us to write good code

bits.logic.inc

141–150 of 229 posts

Re: AI is forcing us to write good code

#141
post #96

Earlier quoted context omitted.

LLMs don't make bad tests any less harmful. Nor they write good tests for the stuff people mostly can't write good tests for.

Okay, but is aiming for 100% coverage really why the bad tests are bad?

In most cases I have seen bad tests, yes.

Re: AI is forcing us to write good code

#142
post #47

I'm sad programmers lacking a lot of experience will read this and think it's a solid run-down of good ideas.

"fast, ephemeral, concurrent dev environments" seems like a superb idea to me. I wish more projects would do it, it lowers the barrier to contributions immensely.

> "fast, ephemeral, concurrent dev environments" seems like a superb idea to me.

I've worked at one (1) place that, whilst not quite fully that, they did have a spare dev environment that you could claim temporarily for deploying changes, doing integration tests, etc. Super handy when people are working on (often wildly) divergent projects and you need at least one stable dev environment + integration testing.

Been trying to push this at $CURRENT without much success but that's largely down to lack of cloudops resources (although we do have a sandbox environment, it's sufficiently different to dev that it's essentially worthless.)

Re: AI is forcing us to write good code

#143
post #134

There's a catch with 100% coverage. If the agent writes both the code and the tests, we risk falling into a tautology trap. The agent can write flawed logic and a test that verifies that flawed logic (which will pass). 100% coverage only makes sense if tests are written before the code or rigorously verified by a human. Otherwise, we're just creating an illusion of reliability by covering hallucinations with tests. A…

Well, we let humans write both business logic code and tests often enough, too.

Btw, you can get a lot further in your tests, if you move away from examples, and towards properties.

Re: AI is forcing us to write good code

#144
post #134

There's a catch with 100% coverage. If the agent writes both the code and the tests, we risk falling into a tautology trap. The agent can write flawed logic and a test that verifies that flawed logic (which will pass). 100% coverage only makes sense if tests are written before the code or rigorously verified by a human. Otherwise, we're just creating an illusion of reliability by covering hallucinations with tests. A…

I think the phase change hypothesis* is a bit wrong.

I think it happens not at 100% coverage but at, say, 100% MC/DC test coverage. This is what SQLite and avionics software aim for.

*has not been confirmed by a peer-reviewed research.

Re: AI is forcing us to write good code

#146
> 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 compiler error messages (in the cases where a language leans on implicit typing) to better predict that next token.

However, that does not seem to be the behaviour i observe. What i see is more akin to tokens in the type signature position in a piece of code often being generated without any seeming relationship to the instructions being written. It's common to generate code that the compiler rejects.

That problem is easily hidden and worked around - just wrap your llm invocation in a loop, feed in the compiler errors each time and you now have an "agent" that can stochastic gradient descent its way to a solution.

Given this, you could say well what does it matter, even if an LLM doesn't meaningfully "understand" the relationship between types and instructions, there's already a feedback loop and therefore a solution available - so why do we even need to care about the fact an llm may or may not treat types as a tool to accurately model the valid solution space.

Well i can't help think this is really the crux of software development. Either you're writing code to solve a defined problem (valuable) or you're doing something else that may mimic that to some degree but is not accurate (bugs).

All that said, pragmatically speaking, software with bugs is often still valuable.

TL;DR i'm currently thinking humans should always define the type signatures and test cases, these are too important to let an LLM "mid" its way through.

Re: AI is forcing us to write good code

#147
post #134

There's a catch with 100% coverage. If the agent writes both the code and the tests, we risk falling into a tautology trap. The agent can write flawed logic and a test that verifies that flawed logic (which will pass). 100% coverage only makes sense if tests are written before the code or rigorously verified by a human. Otherwise, we're just creating an illusion of reliability by covering hallucinations with tests. A…

You’re right. What I like doing in those cases is to review very closely the tests and the assertions. Frequently it’s even faster than looking at the SUT itself.

I heard this “review very closely” thing many times, and rarely means review very closely. Maybe 5% of developers really do this ever, and I probably overestimate it. When people send here AI generated code, it’s quite obvious that they don’t review code properly. There are videos when people recorded how we should use LLMs, and they clearly don’t do this.

Re: AI is forcing us to write good code

#148
post #134

There's a catch with 100% coverage. If the agent writes both the code and the tests, we risk falling into a tautology trap. The agent can write flawed logic and a test that verifies that flawed logic (which will pass). 100% coverage only makes sense if tests are written before the code or rigorously verified by a human. Otherwise, we're just creating an illusion of reliability by covering hallucinations with tests. A…

I think the phase change hypothesis* is a bit wrong. I think it happens not at 100% coverage but at, say, 100% MC/DC test coverage. This is what SQLite and avionics software aim for. *has not been confirmed by a peer-reviewed research.

What's MC/DC?

Re: AI is forcing us to write good code

#149

Earlier quoted context omitted.

I think the phase change hypothesis* is a bit wrong. I think it happens not at 100% coverage but at, say, 100% MC/DC test coverage. This is what SQLite and avionics software aim for. *has not been confirmed by a peer-reviewed research.

What's MC/DC?

https://en.wikipedia.org/wiki/Modified_condition/decision_co...

Re: AI is forcing us to write good code

#150

Earlier quoted context omitted.

I think the phase change hypothesis* is a bit wrong. I think it happens not at 100% coverage but at, say, 100% MC/DC test coverage. This is what SQLite and avionics software aim for. *has not been confirmed by a peer-reviewed research.

What's MC/DC?

Basically branch coverage but also all variations of the predicates, e.g. testing both true || true, and true || false
Post reply on HN