Hacker News new | ask | show | jobs
by simonw 775 days ago
My experience so far with LLM generated code is that it tends to be pretty easy to maintain in the future, because it uses obvious code patterns and includes genuinely relevant comments.

The trick is to know how to program already, and avoid checking in LLM-generated code unless you completely understand every line.

If you don't do that you'll run into the same problems as you would if you hire a contractor to build your codebase without understanding what they did for you.

3 comments

> because it uses obvious code patterns and includes genuinely relevant comments.

I often (simplistically) explain LLMs to people by explaining that it's essentially running a statistical average of language. Next-token-prediction (generally) aims to predict the next-least-surprising word that would occur in a sequence. It aims to "make sense" and be unsurprising.

If you want creative writing and innovative research papers and novel ideas, this isn't going to get you very far.

But if the things you want are "unsurprising" or "predictable" (great attributes of good, maintainable source code), then using this to write code feels like a pretty darn good fit.

> If you don't do that you'll run into the same problems as you would if you hire a contractor to build your codebase without understanding what they did for you.

I guess the difference is now that the contractor is cheap or free (because it’s a LLM), whereas in the old days you’d either hire a person to do the work and not understand or pick up a book and figure it out yourself (or go to school, or whatever). Figuring it out yourself was often cheaper and then you could understand.

(Not that humans can be replaced by LLM devs yet, or that LLM generated code is necessarily unreadable. It’s usually fine as you say.)

I have a feeling that if there was not a healthy amount of competition in the space, the prices would start to trend towards the cost of human work.
And the self-hosted options are better than nothing, I'm currently getting code autocompletions via Starcoder+TabbyML on an M1 MacBook pro.
> If you don't do that you'll run into the same problems as you would if you hire a contractor to build your codebase without understanding what they did for you.

I really like this way of thinking about using LLMs, I think that's a great analogy in many ways.