Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

By iterating it 5 times the author is using ~5x the compute. It’s kinda a strange chain of thought.

Also: premature optimization is evil. I like the first iteration most. It’s not “beginner code”, it’s simple. Tell sonnet to optimize it IF benchmarks show it’s a pref problem. But a codebase full of code like this, even when unnecessary, would be a nightmare.



This is not what premature optimization is the root of all evil means. It’s a tautological indictment of doing unnecessary things. It’s not in support of making obviously naive algorithms. And if it were it wouldn’t be a statement worth focusing on.

As the point of the article is to see if Claude can write better code from further prompting so it is completely appropriate to “optimize” a single implementation.


I have to disagree. Naive algorithms are absolutely fine if they aren’t performance issues.

The comment you are replying to is making the point that “better” is context dependent. Simple is often better.

> There is no doubt that the grail of efficiency leads to abuse. Programmers waste enormous amounts of time thinking about, or worrying about, the speed of noncritical parts of their programs, and these attempts at efficiency actually have a strong negative impact when debugging and maintenance are considered. We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%. - Donald Knuth


Having a human-visible delay to calculate a single statistic about a small block of numbers is a bad thing.

Do not use such a naive algorithm on arrays this big. If this code is going to actually be used in something, it's a performance issue.

In general these optimizations don't involve much time thinking them out, and a bunch of them are fine as far as debugging and maintenance. The first prompt-engineered version is fast and simple.

(Though the issue isn't really algorithm, it's that you don't want to be doing much number and string crunching in pure python.)


> Writing naive algorithms

Depends on the circumstance, and how difficult an appropriate algorithm is to write, but in my experience, if code performance is important, this tends to yield large, painful rewrites down the road.


I had the same thought when reading the article too. I assumed (and hoped) it was for the sake of the article because there’s a stark difference between idiomatic code and performance focused code.

Living and working in a large code base that only focuses on “performance code” by default sounds very frustrating and time consuming.


So in this article "better" means "faster". This demonstrates that "better" is an ambiguous measure and LLMs will definitely trip up on that.

Also, the article starts out talking about images and the "make it more X" prompt and says how the results are all "very samey and uninteresting" and converge on the same vague cosmic-y visuals. What does the author expect will happen to code given the "make it more X" treatment?


I'm glad I'm not the only one who felt that way. The first option is the one you should put into production, unless you have evidence that performance is going to be an issue. By that measure, the first response was the "best."


> I like the first iteration most. It’s not “beginner code”, it’s simple.

Yes, thank you. And honestly, I work with a wide range of experience levels, the first solution is what I expect from the most experienced: it readably and precisely solves the stated problem with a minimum of fuss.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: