Hacker News new | ask | show | jobs
by stavros 429 days ago
So there's a wrong way and a right way to code with LLMs. The wrong way is to ask the LLM to write a bunch of code you don't understand, and to keep asking it to write more and more code to fix the problems each iteration has. That will lead to a massive tower built on sand, where everything is brittle and collapses at the slightest gust of wind.

The right way is to have it autocomplete a few lines at a time for you. You avoid writing all the boilerplate, you don't need to look up APIs, you get to write lines in a tenth of the time it would normally take, but you still have all the context of what's happening where. If there's a bug, you don't need to ask the LLM to fix it, you just go and look, you spot it, and you fix it yourself, because it's usually something dumb.

The second way wins because you don't let the LLM make grand architectural choices, and all the bugs are contained in low-level code, which is generally easy to fix if the functions, their inputs, and their outputs are sane.

I like programming as much as the next person, but I'm really not lamenting the fact that I don't have to be looking up parameters or exact function names any more. Especially something like Cursor makes this much easier, because it can autocomplete as you type, rather than in a disconnected "here's a diff you won't even read" way.

2 comments

The best completion are those that let you avoiding mistyping variable names or figure out some dependency (automatically import the modules, restrict to the current scope/structure). Those has been solved for decades now. And you can get a dumb ones by doing a list of all symbols in the project directory, removing common keyword and punctuation, and do some kind of matching for filtering. The other side of the spectrum is the kind of code indexing IDEA and LSP server do.

Then you got into code boilerplate, and if you find yourself doing this a lot, that's a signal to start refactoring, add some snippets to your editor (error handling in go), write some code generators, or lament the fact that your language can't do metaprogramming.

> but I'm really not lamenting the fact that I don't have to be looking up parameters or exact function names any more.

That's a reckless attitude to have, especially if the function have drastic behavior switch like mutating argument or returning a fresh copy. All you do is assume that it behaves in certain way while the docs you haven't read will have the related warning label.

That level of autocomplete has been around for many years before LLM for pretty much any used language
Well, I guess I must have missed it in my thirty years of development.
Use IDEA for a java project and your TAB key will wear itself out.