Live data from Hacker News

Can LLMs write better code if you keep asking them to “write better code”?

minimaxir.com

21–30 of 461 posts

Re: Can LLMs write better code if you keep asking them to “write better code”?

#21

its best to tell them how you want the code written.

At that point isn't it starting to become easier to just write the code yourself? If I somehow have to formulate how I want a problem solved, then I've already done all the hard work myself. Having the LLM just do the typing of the code means that now not only did I have to solve the problem, I also get to do a code review.

Re: Can LLMs write better code if you keep asking them to “write better code”?

#22
post #5

Something major missing from the LLM toolkit at the moment is that it can't actually run (and e.g. test or benchmark) its own code. Without that, the LLM is flying blind. I guess there are big security risks involved in making this happen. I wonder if anyone has figured out what kind of sandbox could safely be handed to a LLM.

It'd be great if it could describe the performance of code in detail, but for now just adding a skill to detect if a bit of code has any infinite loops would be a quick and easy hack to be going on with.

Is reliably detecting if code has any infinite loops feasible? Sounds like the halting problem.

Re: Can LLMs write better code if you keep asking them to “write better code”?

#23

Using the tool in this way is a bit like mining: repeatedly hacking away with a blunt instrument (simple prompt) looking for diamonds (100x speedup out of nowhere). Probably a lot of work will be done in this semi-skilled brute-force sort of way.

Well, in this case it's kind of similar to how people write code. A loop consisting of writing something, reviewing/testing, improving until we're happy enough.

Sure, you'll get better results with an LLM when you're more specific, but what's the point then? I don't need AI when I already know what changes to make.

Re: Can LLMs write better code if you keep asking them to “write better code”?

#24

Using the tool in this way is a bit like mining: repeatedly hacking away with a blunt instrument (simple prompt) looking for diamonds (100x speedup out of nowhere). Probably a lot of work will be done in this semi-skilled brute-force sort of way.

It looks to me to be exactly what a typical coding interview looks like; the first shot is correct and works, and then the interviewer keeps asking if you can spot any ways to make it better/faster/more efficient

If I were a CS student cramming for interviews, I might be dismayed to see that my entire value proposition has been completely automated before I even enter the market.

Re: Can LLMs write better code if you keep asking them to “write better code”?

#25

its best to tell them how you want the code written.

What if I want to discover a new better way to write code?

You can ask it for alternative methods and even to document their pros and cons.

Re: Can LLMs write better code if you keep asking them to “write better code”?

#26

Earlier quoted context omitted.

It'd be great if it could describe the performance of code in detail, but for now just adding a skill to detect if a bit of code has any infinite loops would be a quick and easy hack to be going on with.

Is reliably detecting if code has any infinite loops feasible? Sounds like the halting problem.

Not in the general case, but you could detect specific common patterns.

Re: Can LLMs write better code if you keep asking them to “write better code”?

#27

The more interesting question IMO is not how good the code can get. It is what must change for the AI to attain the introspective ability needed to say "sorry, I can't think of any more ideas."

The problem is, they do not think.

Re: Can LLMs write better code if you keep asking them to “write better code”?

#28
post #19

Wow, what a great post. I came in very skeptical but this changed a lot of misconceptions I'm holding. One question: Claude seems very powerful for coding tasks, and now my attempts to use local LLMs seem misguided, at least when coding. Any disagreements from the hive mind on this? I really dislike sending my code into a for profit company if I can avoid it. Second question: I really try to avoid VSCode (M$ concerns…

Still vscode, but cursor has the best implementation by far IMHO

Intellij has a new feature that lets you prompt within your code that is pretty neat too, but I'm missing the Composer/apply feature of cursor still

Re: Can LLMs write better code if you keep asking them to “write better code”?

#29

its best to tell them how you want the code written.

At that point isn't it starting to become easier to just write the code yourself? If I somehow have to formulate how I want a problem solved, then I've already done all the hard work myself. Having the LLM just do the typing of the code means that now not only did I have to solve the problem, I also get to do a code review.

Yes the fallacy here is that AI will replace eingineers any time soon. For the foreseeable future prompts will need to be written and curated by people who already know how to do it, but will just end up describing it in increasingly complex detail and then running tests against it. Doesn't sound like a future that has that many benefits to anyone.

Re: Can LLMs write better code if you keep asking them to “write better code”?

#30
post #5

Something major missing from the LLM toolkit at the moment is that it can't actually run (and e.g. test or benchmark) its own code. Without that, the LLM is flying blind. I guess there are big security risks involved in making this happen. I wonder if anyone has figured out what kind of sandbox could safely be handed to a LLM.

It can't be done in the LLM itself of course, but the wrapper you're taking about already exists in multiple projects fighting in SWEbench. The simplest one is aider with --auto-test https://aider.chat/docs/usage/lint-test.html

There are also large applications like https://devin.ai/ or https://github.com/AI-App/OpenDevin.OpenDevin

Post reply on HN