Hacker News new | ask | show | jobs
by pjungwir 1186 days ago
In my experience programmers hate to read each other's code. That's why rewrites are so popular. Do they really want to read an AI's? I bet the AI writes even worse comments your predecessor.

One of the more toilsome bits of coding I do personally is rebasing. I have a patch to add application-time temporal tables to the Postgres project, and I've been rebasing it for several years now. It's a pretty big patch (actually a series of four patches), so there are almost always non-trival conflicts to deal with. If ChatGPT could do that for me it would be awesome.

But it's probably the hardest thing for an LLM to do. It's not a routine program that has been written thousands of times across Github projects and StackOverflow posts. Every rebase is completely new.

OTOH it would be awesome if git had just a bit more intelligence around merge conflicts. . . .

5 comments

What I would like to see is an AI which actively or passively assists you, like an improved Intellisense. Something which looks over your shoulder, figures out what you're trying to achieve and points at errors in your reasoning or stuff you did not consider.

It can summarize the thing you're looking at, tell you how to improve it regarding readability and performance.

On a press of a button you can zoom out of the code into an UML like overview and it will tell you what's going on and how it is connected. If you don't get it, it knows how to make you understand.

Then you can tell it in a few words what you want to achieve and it will assist you in finding a solid solution which matches the coding style of the rest of your project. And while you're coding and lose sight, it will help you achieve the goal.

The current state is sub-par in my opinion. I can write good code and don't need an AI to write it for me. But what I want is something which assists me with understanding code, improving code or extend code without taking the steering wheel away from me.

Your first point I agree with, I've already encountered chunks of AI generated code and I don't want to read them.

Second point about the comments, actually I'm seeing the AI write much better comments (i.e. some) than most devs (none).

> actually I'm seeing the AI write much better comments (i.e. some) than most devs (none).

Some comments are far worse than no comments at all. I would agree that even semi-decent comments are far better than nothing. However, "no-new-information" comments are just noise, and misleading comments have a huge negative effect. I would not be surprised if an AI produced a large number of the former, and perhaps some of the latter.

In my experience, people hate to read each other’s unnecessarily complex code. Nobody complained about a well written (ie easily understandable) codebase ever. This is why reviews exist among others. Comments are only useful if there is some magic because of performance reasons. In any other case, if comment seems to be necessary, then code should rather be refactored. It’s a code smell. Abstract classes, indirect loops in runtime call stack without IoC, and templates are also dangerous animals. Nobody complained so far for codebase where these were minimised, especially if microservice architecture was introduced which also inherently tames DRY on some level.
> comments are code smell [paraphrasing]

Good news: there are kinds of extremely useful comments that do not repeat the code (your comments should not repeat the code). Comments are to express context/intent behind the code: the "why", the high level "what", and almost never the exact "how" (read code for that).

It looks like you only ever encountered the "how" comments. No amount of code refactoring would get you the "why" (context) comments.

GIT tells the why.
Yes, commit message is also a good place to provide the context for the commit.
I am working on some JS that needs to be obfuscated. After mangling the whole thing, suddenly I was gripped with horror: I remembered that GPT is pretty good at deobfuscation.

I put my mangled and minified code in.

What it emits is not only perfectly readable and 95% accurate (the 5% was due to missing context, max input limit)—it was significantly better than my code.

Of course the structure was the same, but ChatGPT chose much more sensible variable names in almost every case. I found it much easier to understand its version of my code than my own.

I guess I accidentally discovered a refactoring technique?

At least the AI won't complain about the refactor haha
It was trained on human data about the same subject so we have every reason to expect it'd complain