Live data from Hacker News

How to effectively write quality code with AI

heidenstedt.org

101–110 of 321 posts

Re: How to effectively write quality code with AI

#101

I wonder at the end of this if it's the still worth the risk? A lot of how I form my thoughts is driven by writing code, and seeing it on screen, running into its limitations. Maybe it's the kind of work I'm doing, or maybe I just suck, but the code to me is a forcing mechanism into ironing out the details, and I don't get that when I'm writing a specification.

> A lot of how I form my thoughts is driven by writing code, and seeing it on screen, running into its limitations.

If you need that, don't use AI for it. What is it that you don't enjoy coding or think it's tangential to your thinking process? Maybe while you focus on the code have an agent build a testing pipeline, or deal with other parts of the system that is not very ergonomic or need some cleanup.

Re: How to effectively write quality code with AI

#103
The post touches very briefly on linting in 7. For me, setting up a large number of static code analysis checks has had the highest impact on code quality.

My hierarchy of static analysis looks like this (hierarchy below is Typescript focused but in principle translatable to other languages):

1. Typesafe compiler (tsc)

2. Basic lint rules (eslint)

3. Cyclomatic complexity rules (eslint, sonarjs)

4. Max line length enforcement (via eslint)

5. Max file length enforcement (via eslint)

6. Unused code/export analyser (knip)

7. Code duplication analyser (jscpd)

8. Modularisation enforcement (dependency-cruiser)

9. Custom script to ensure shared/util directories are not over stuffed (built this using dependency-cruiser as a library rather than an exec)

10. Security check (semgrep)

I stitch all the above in a single `pnpm check` command and defined an agent rule to run this before marking task as complete.

Finally, I make sure `pnpm check` is run as part of a pre-commit hook to make sure that the agent has indeed addressed all the issues.

This makes a dramatic improvement in code quality to the point where I'm able to jump in and manually modify the code easily when the LLM slot machine gets stuck every now and then.

(Edit: added mention of pre-commit hook which I missed mention of in initial comment)

Re: How to effectively write quality code with AI

#104

I wonder at the end of this if it's the still worth the risk? A lot of how I form my thoughts is driven by writing code, and seeing it on screen, running into its limitations. Maybe it's the kind of work I'm doing, or maybe I just suck, but the code to me is a forcing mechanism into ironing out the details, and I don't get that when I'm writing a specification.

I sometimes wonder if the economics of AI coding agents only work if you totally ignore all the positive externalities that come with writing code.

Is the entire AI bubble just the result of taking performance metrics like "lines of code written per day" to their logical extreme?

Software quality and productivity have always been notoriously difficult to measure. That problem never really got solved in a way that allowed non technical management to make really good decisions from the spreadsheet level of abstraction... but those are the same people driving adoption of all these AI tools.

Engineers sometimes do their jobs in spite of poor incentives, but we are eliminating that as an economic inefficiency.

Re: How to effectively write quality code with AI

#105
post #47
post #30

Earlier quoted context omitted.

Maybe. But it's also likely that these tools will produce mountains of unmaintainable code and people will get buried by the technical debt. It kind of strikes me as similar to the hubris of calling the Titanic "unsinkable." It's an untested claim with potentially disastrous consequences.

> But it's also likely that these tools will produce mountains of unmaintainable code and people will get buried by the technical debt. It's not just likely, but it's guaranteed to happen if you're not keeping an eye on it. So much so, that it's really reinforced my existing prejudice towards typed and compiled languages to reduce some of the checking you need to do. Using an agent with a dynamic language feels very…

Companies aren't evaluating on "keeping an eye on technical debt", but then ARE directly evaluating on whether you use AI tools.

Meanwhile they are hollowing out work forces based on those metrics.

If we make doing the right thing career limiting this all gets rather messy rather quickly.

Re: How to effectively write quality code with AI

#106
post #85
post #47

Earlier quoted context omitted.

> But it's also likely that these tools will produce mountains of unmaintainable code and people will get buried by the technical debt. It's not just likely, but it's guaranteed to happen if you're not keeping an eye on it. So much so, that it's really reinforced my existing prejudice towards typed and compiled languages to reduce some of the checking you need to do. Using an agent with a dynamic language feels very…

Tests make me faster. Dynamic or not feels irrelevant when I consider how much slower I’d be without the fast feedback loop of tests.

Static type checking is even faster than running the code. It doesn't catch everything, but if finding a type error in a fast test is good, then finding it before running any tests seems like it would be even better.

Re: How to effectively write quality code with AI

#108

Earlier quoted context omitted.

Everything you have said here is completely true, except for "not in that group": the cost-benefit analysis clearly favors letting these tools rip, even despite the drawbacks.

Oh I'm well aware of this. I admitted defeat in a way.. I can't compete. I'm just at loss, and unless LLM stall and break for some reason (ai bubble, enshittification..) I don't see a future for me in "software" in a few years.

I feel the same.

Frankly, I am not sure there is a place in the world at all for me in ten years.

I think the future might just be a big enough garden to keep me fed while I wait for lack of healthcare access to put me out of my misery.

I am glad I am not younger.

Re: How to effectively write quality code with AI

#109
post #96

Earlier quoted context omitted.

> I think you have every right to doubt those telling us that they run 5 agents to generate a new SAAS-product while they are sipping latté in a bar. To work like that I believe you'll have to let go of really digging into the code, which in my experience is needed if want good quality. Also we live in a capitalist society. The boss will soon ask: "Why the fuck am I paying you to sip a latte in a bar? While am machin…

> AI just means more output will be expected of you, and they'll keep pushing you to work as hard as you can. That’s a bit too cynical for me. After all, yes, your boss is not paying you for sipping lattes, but for producing value for the company. If there is a tool that maximises your output, why wouldn’t he want you to use that to great efficiency? Put differently, would a carpenter shop accept employees rejecting…

If the power saw ran itself without any oversight, the carpenter shop wouldn't accept any type of employees.

Re: How to effectively write quality code with AI

#110
post #52

Earlier quoted context omitted.

I think that's the question. Is a programmer expected to ever touch the source code? Or will AI -- and AI alone -- update the code that it generated? Not entirely unlike other code generation mechanisms, such as tools for generating HTML based on a graphical design. A human could edit that, but it may not have been the intent. The intent was that, if you want a change, go back to the GUI editor and regenerate the HTM…

So like we went from assembler to higher level programming languages, we will now move to specifications for LLMs? Interesting thought... Maybe, once the "compilers" get good enough, but for mission critical systems they are not nearly good enough yet.

This is exactly what is happening from a levels of abstraction standpoint.

The difference being that compilers and related tools are deterministic, and we can manage the outputs using mathematical proof of correctness.

The LLM's driving this new abstraction layer are another beast entirely.

Post reply on HN