logoalt Hacker News

fransje26today at 11:54 AM2 repliesview on HN

> I’ve found utility in removing code.

> I feel that doing the job with the fewest lines of code, is best.

And that is one of my gripes with AI models and code. They are so, so verbose. It's a nightmare.

"Why don't you let AI implement that small feature, it will be faster.", they would ask.

Well, because if do, it will completely pollute my carefully crafted interface that I kept small, simple and understandable for easier maintenance and extension.

And yes, I might spare a few hours by having _it_ work for me. But then I need to spend a more hours to clean-up the code noise and complexification.

Sorry for having polluted the conversation by bringing AI in, when for once, ironically, it was not about AI.. I needed to vent, while fully approving of your take.


Replies

ChrisMarshallNYtoday at 12:47 PM

I just had to rewrite a screen written by an LLM.

It started, by giving me a 2,500-line (about 50% documentation) viewcontroller that ate so much memory that the app would jetsam after the user just did a couple of things.

I then, spent about a week, tracking down memory issues, until we narrowed it down to the MapKit cache. All this time, the LLM was making the code scarier and scarier. It was exactly what I would expect from an inexperienced (but smart) engineer, panicking, and adding more and more cruft.

The LLM ended up suggesting fixes that didn’t work that well, and made the UI janky. Also, it was terrifyingly delicate. I don't think it would have survived one feature request.

By now, the viewcontroller was over 4,000 lines.

I asked the LLM to refactor for redundancy, quality, and size.

It removed all the documentation and logging, reducing the size back to about 2,500 lines (about 1% documentation).

Yay.

Except all of the bush-league threading and awful workaround shit was still in there, but now impossible to understand.

At this point, I gave up, threw out the LLM code, and rewrote the viewcontroller from scratch. Took a day and a half. I figured out how to force MapKit to flush its cache (2 lines of code). It's a well-known issue, and the solution was the first StackOverflow answer that showed up in the search.

It’s currently about 1,400 lines (about 50% is documentation), and works great.

Lesson learned.

show 2 replies
trollbridgetoday at 12:37 PM

I evaluate how good models are now by how good they are at removing code.

It’s fairly simple (assuming the test harness and agents.md are well written): do iterations of trying to remove code, ensure it passes, then have a human review it. Less code to review that way.