Live data from Hacker News

AI is forcing us to write good code

bits.logic.inc

41–50 of 229 posts

Re: AI is forcing us to write good code

#41
post #35

I don't know about all this AI stuff. How are LLMs going to stay on top of new design concepts, new languages, really anything new? Can LLMs be trained to operate "fluently" with regards to a genuinely new concept? I think LLMs are good for writing certain types of "bad code", i.e. if you're learning a new language or trying to quickly create a prototype. However to me it seems like a security risk to try to write "g…

You do realise they can search the web? They can read documentation and api specs?

[deleted]

Re: AI is forcing us to write good code

#42
post #29

Strong agreement with everything in this post. At Qlty, we are going so far as to rewrite hundreds of thousands of lines of code to ensure full test coverage, end-to-end type checking (including database-generated types). I’ll add a few more: 1. Zero thrown errors. These effectively disable the type checker and act as goto statements. We use neverthrow for Rust-like Result types in TypeScript. 2. Fast auto-formatting…

I‘m on the same page as you, I‘m investing into DX and test coverage and quality tooling like crazy. But the weird thing is: those things have always been important to me. And it has always been a good idea to invest in those, for my team and me. Why am doing this 200% now?

If you're like me you're doing it to establish a greater level of trust in generated code. It feels easier to draw out the hard guard-rails and have something fill out the middle -- giving both you, and the models, a reference point or contract as to what's "correct"

Re: AI is forcing us to write good code

#43

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

I’m more afraid that some manager will read this and impose rules on their team. On the surface one might think that having more test coverage is universally good and won’t consider trade offs. I have a gut feeling that Goodhart’s Law accelerated with AI is a dangerous mix.

Re: AI is forcing us to write good code

#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 finding out that it was using some american websites to spec out your electric system and not noticing the problem until you're installing your candadian dishwasher.

Re: AI is forcing us to write good code

#45
post #29

Strong agreement with everything in this post. At Qlty, we are going so far as to rewrite hundreds of thousands of lines of code to ensure full test coverage, end-to-end type checking (including database-generated types). I’ll add a few more: 1. Zero thrown errors. These effectively disable the type checker and act as goto statements. We use neverthrow for Rust-like Result types in TypeScript. 2. Fast auto-formatting…

I‘m on the same page as you, I‘m investing into DX and test coverage and quality tooling like crazy. But the weird thing is: those things have always been important to me. And it has always been a good idea to invest in those, for my team and me. Why am doing this 200% now?

Answering myself: maybe I feel much more urgency and motivation for this in the age of AI because the effects can be felt so much more acute and immediately.

Re: AI is forcing us to write good code

#46
This goes in the right direction. It could go further though. Types are indeed nice. So, why use a language why using those is optional? There are many reasons but many of those have to do with people and their needs/wants rather than tool requirements. AI agents benefit from good tool feedback, so maybe switch to languages and frameworks that provide plenty of that and quickly. Switching used to be expensive. Because you had to do a lot of the work manually. That's no longer true. We can make LLMs do all of the tedious stuff.

Including using more rigidly typed languages, making sure things are covered with tests, using code analysis tools to spot anti patterns and addressing all the warnings, etc. That was always a good idea but we now have even less excuses to skip all that.

Re: AI is forcing us to write good code

#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.

Re: AI is forcing us to write good code

#48
post #11
post #6

Author should ask AI to write a small app with 100% code coverage that breaks in every path except what is covered in the tests.

I never claim that 100% coverage has anything to do with code breaking. The only claim made is that anything less than 100% does guarantee that some piece of code is not automatically exercised, which we don't allow. It's a footnote on the post, but I expand on this with: 100% coverage is actually the minimum bar we set. We encourage writing tests for as many scenarios as is possible, even if it means the same lines…

Brakes in cars here in Germany are integrated with less than 50 % coverage in the final model testing that goes to production.

Seems like even if people could potentially die, industry standards are not really 100% realistic. (Also, redundancy in production is more of a solution than having some failures and recalls, which are solved with money.)

Re: AI is forcing us to write good code

#49
post #22

Earlier quoted context omitted.

Could you be more specific in your feedback please.

100% test coverage, for most projects of modest size, is extremely bad advice.

Pre-agents, 100% agree. Now, it's not a bad idea, the cost to do it isn't terrible, though there's diminishing returns as you get >90-95%.

Re: AI is forcing us to write good code

#50
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…

It's more like you're installing the dishwasher and the dishwasher itself yells at you "I told you so" ;)
Post reply on HN