Live data from Hacker News

Using AI to write better code more slowly

nolanlawson.com

471–480 of 511 posts

Re: Using AI to write better code more slowly

#471

Earlier quoted context omitted.

I follow the same process. I have a design in mind for the problem at hand, but I don't reveal it to Codex. I go back and forth a bit to see if its proposals are better than mine. I go back and forth on tradeoffs of various approaches. And then I ask it to compare its proposals with mine. I "win" most of the time but there are many times where it shows a me a better, or simpler approach, or makes me rethink the solut…

I really like this pattern and use it often, this 'not showing my cards'. The second I hint towards the LLM what I prefer it will become sycophantic and invent nonsense why my preferred solution is better. I'm sure there's an interesting study on how users 'leak' their preference unintentionally to the LLM; perhaps when users list their options, they often put their prefered option first; but not showing the cards on…

[flagged]

Re: Using AI to write better code more slowly

#472

As a junior, i do actually enjoy going back and forth with the AI discussing different ways to implement something and exploring alternatives. More often than not, I'd have an architectural idea that I'm not that confident in. The process of talking with the LLM takes a long time but it helps me sharpen the initial approach or even come up with a new one depending on the requirements.

When doing this, I particularly like that the LLM sometimes gets things wrong.

It forces me to really understand each thing deeply so that I evaluate it properly.

It is like taking an exam where the exam writer is hostile and sneaks in trick questions. You only spot that the question is wrong when you fully reason through the answer.

Re: Using AI to write better code more slowly

#473

Earlier quoted context omitted.

I think you need a skill to review those code by agent itself, but in a different role, not the one who wrote them. I did some research on this and developed a skill to get things done. By now it works well though I decide to prove and improve it with more tests. Dog food is not always delicious but not too bad either.

The problem is that I manually review the code before/after the review, as well as review the items to review themselves. You could easily put AI into a review infinite loop if you let it, and you also risk the code base going off the rails if you let AI go wild. It's actually happened a few times where I need to back out entire features because AI went too far and I lost control/understanding of what the code is doi…

I understand what you concern. I encountered the same issues before so I did some work on this. So far so good. The LLM does not go wild when they do review work now. I open sourced my skill on GitHub and you can check if you are interested in it.

Re: Using AI to write better code more slowly

#474

Earlier quoted context omitted.

I really like this pattern and use it often, this 'not showing my cards'. The second I hint towards the LLM what I prefer it will become sycophantic and invent nonsense why my preferred solution is better. I'm sure there's an interesting study on how users 'leak' their preference unintentionally to the LLM; perhaps when users list their options, they often put their prefered option first; but not showing the cards on…

LLMs flip positions when users push back ~70% of the time even when they were right. RLHF optimizes for approval, not correctness

It's actually a reasonable way to think about alignment. Sometimes you want the agent to just listen to you and sometimes you want the agent to think critically.

I think about this line a lot. For example, as it happens sometimes you'll have a typo in something you want the agent to do. Llms typically will correct that typo silently and implement the actually intended thing. But if you said, "no, I want the thing I typed," I think everyone's expectation is that is says, "ok done."

I've found that leaving clues in the system prompt / exchange that are open to critique largely mitigate sycophancy with most recent models.

As engineers were trained to represent our positions strongly. Strong opinions loosely held, etc. when you speak authoritatively to a person, "I think we should do x...", the person understand that that's just you're opinion and have the autonomy to push back.

An llm imo _shouldnt_ have that same kind of autonomy by default and it should be rlhf'ed out.

Re: Using AI to write better code more slowly

#475

Earlier quoted context omitted.

Quite the opposite. It’ll most likely “outgrow” us.

Can't, it ain't nothing BUT us. You can wait and see, but that's what'll happen. If we stop it stops.

Sure, not "us". But it could possibly outgrow the vast majority of individual "yous".

Re: Using AI to write better code more slowly

#476
post #226

Earlier quoted context omitted.

You are definitely going to have to. I see these massive skills as soon-to-be artefacts of the past, they will be unwieldy in the non-subsidised world. I won't pretend to know what replaces them.

We have lots of open-weight models like DeepSeek V4 Pro that are very close to SOTA and we know the cost of running them. This helps keeps the other players honests: there's a limit to which they can raise prices when there are already alternatives today and when there's zero lock in. That those companies can make revenues but only at the cost of burning investors money: that's not my problem. My take on it is simple…

AI tools have started to kill software as a service by ... selling software as a service.

I don't know how this will settle out, but from what NVidia and the DRAM people are saying, it's not going to get cheaper until at least 2030.

Re: Using AI to write better code more slowly

#477
I do something similar. Design reviews are an extremely valuable part of the process but they take a long time and people are busy and who really has enough expertise to provide meaningful feedback? Well, the AI is always available and it can rip through my entire codebase in just a few minutes and it has seen more code than I could in a thousand lifetimes. Asking it to review my ideas, my proposals, my implementation, my documentation - anything I can think of - generates a wealth of good insights.

That's not to say that I follow every suggestion it gives any more than I accept every line of code it generates. I'm still the engineer and I still have my reasons for some decisions that may not make sense to an outsider. But as a rubber duck or a second set of eyes or a sober second thought, it can offer a lot of good feedback that I can consider, and most of it is quite good.

I'd say about 8/10 suggestions it makes I agree with and accept, maybe with some small tweaks. I don't think I've ever seen it suggest anything stupid. The last 2/10 are generally either things that would make sense if not for the rest of the context in my head that says it is that way for a reason, or because it's too minor to worry about changing.

All of this extra review takes more time and it usually results in me making a bunch of extra changes I wouldn't have otherwise made, but that's all I'm the make of much better quality and reliability and that pays off in multiples in the future.

Re: Using AI to write better code more slowly

#478

Earlier quoted context omitted.

It happens in poorly factored codebases. If you find it happening that's a sign you need to refactor. If you find it happening repeatedly in the same codebase that means you failed to refactor properly the first time.

Not many industries can afford refactoring of the code is not supposed to be changed - additional (unexpected) regression testing costs, risk of downtime, etc. You learn that if it works and is in production - don't touch it.

Which is greater? The cost of refactoring or the cost of not refactoring? If the consequence of not refactoring is having to deploy twice as many services and libraries every time you add a feature... that sounds pretty risky to me over time.

Re: Using AI to write better code more slowly

#479
post #30

This article doesn't address writing code with AI, just code review. My issue with agentic coding is that I make numerous micro-architectural decisions while programming. I almost never have a full spec up front and develop one as I consider what I am writing. When using Claude Code or Codex, that is all gone. Claude Code is extremely eager to reach the end goal to the point that it feels like a fever dream to write…

This is why I don't use agent-first platforms like Claude Code. I want to write software with an AI to assist me, not an AI to write my software for me. I don't want an environment whose main mode of operation is instructing an AI to write code - I want a typical IDE where I can continue writing code myself but with an assistant there to consult whenever I want it.

Even then, it's easy to fall into a trap of giving the AI a simple description and letting it fill in the blanks, but I've learned the discipline not to do that, in the same way I learned to think before I speak and design before I write code.

Planning mode is my entry point for almost all code I would have the AI write. I already have in mind what I think I want. I get it to create a detailed plan, which inevitably fills in things I didn't specify and even ask questions I hadn't considered. I iterate on this first revision spec until I think it's ready. This results in a task list. But just like waterfall doesn't mean make a plan and execute it all without looking back, executing this plan is also a stepwise iterative process. I let the AI execute the first step. I check its work. I run some tests and see if it behaves like I thought it would - the same stuff I would do during normal development. If I find issues, I go back to the plan and change it, then continue implementing the revised plan. If the previous step lead me into a dead end, I revert that one step and try again with my revised plan.

The key thing is this: this was my development methodology before AI entered the picture. Nothing has fundamentally changed. What has changed is that the AI provides input at one or more stages of the flow - offering alternatives, asking questions, running tests, researching and debugging - but in every single step the AI does not decide on the final outcome. Even if the AI wrote all of the code, I still review it and test it. Even if it suggested a design, I compare the options and review the referenced documents and decided for myself. Even if it reviews my code and says it would do a hundred things differently, I decide what suggestions I will act on and how. It's no different than I would do with having a coworker giving me ideas, reviewing my work, or making their own attempt at generating a solution. It's all helpful input and if I'm happy with it I will use it as is, but I'm still responsible for every line of code and I still make all of the decisions about what stays and what goes.

I'm sure this sounds wasteful - why use an AI if you have to review it and correct it anyway? For the same reason I delegate tickets to a team of 20 junior developers and don't do them all myself as a principal engineer - I am but one person and they are an army. Even if I have to discuss plans and options with them and review their work, they can spend the same hours I would brainstorming and researching and prototyping and debugging, and I can go over the results with them to make key decisions and make sure we are on the right track. I make the important decisions, but the leg work of getting everything in place is done by someone else who doesn't need as much knowledge or insight or experience. It is a force multiplier. It is the equivalent of a lawyer with a team of paralegals or a professor with a team of researchers and grad students. I can let the AI do the things it does well so that I don't have to, and instead I can spend my time on the things I do well that it can't do.

This is where I think we are going wrong with AI in many areas, but particularly in software development. An AI is not a replacement for an engineer - it's an engineer's assistant. It isn't a source of truth - it's a source of ideas. It's not responsible for the outcome - I am. A team of helpers can make an expert more productive, but that team isn't a substitute for the expert. Likewise, juniors still need to gain the same experiences and learn the same practices and make the same mistakes, because they still need to become experts, but they can use the AI as a guide along that journey rather than having to rely solely on another expert for mentorship.

Re: Using AI to write better code more slowly

#480

As a junior, i do actually enjoy going back and forth with the AI discussing different ways to implement something and exploring alternatives. More often than not, I'd have an architectural idea that I'm not that confident in. The process of talking with the LLM takes a long time but it helps me sharpen the initial approach or even come up with a new one depending on the requirements.

I do the same thing as an expert with 20 years of experience. You can always benefit from a second set of eyes and a second opinion. What's important is that you consider that input and then make your own decisions, rather than deferring to the AI to make the decisions for you.
Post reply on HN