frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Open in hackernews

"Clean" Code, Horrible Performance (2023)

https://www.computerenhance.com/p/clean-code-horrible-performance
44•FrojoS•5h ago

Comments

MonstraG•5h ago
(2023)
inigyou•2h ago
Still true today.
WesolyKubeczek•33m ago
Nobody argues with that. But it's helpful to know right from the title that it's the original Casey's work and not something newer.
unscaled•17m ago
I don't think it was true even in 2023.

This sounds like tackling the problems of C++ in the early 2000s.

1. Casey Muratori also that DRY shouldn't doesn't have to result in non-performant code.

2. Smaller functions, functions that do one-thing: Modern compiler can inline those. There are some edge cases where inlining may make less efficient use of states and loops but I don't think that's a main problem nowadays. I also wouldn't say the extreme version of this idea (very small functions) is still popular. The strongest proponent of this was Uncle Bob, and the last time I've heard him speak about code, he said he now lets the LLM write everything and he only reviews the module hierarchy and maybe the modules' public interfaces.

3. Polymorphism instead of ifs and switches was a big fad in the late 1990s until the late 2000s and had some holdouts in the 2010s. It was only ever popular in the Enterprise Java and C++ world (and maybe in Enterprise Smalltalk, never hard). Overuse of runtime polymorphism widely considered bad form in newer static languages like Go and Rust and in most dynamic languages there was always a tacit understanding of "use mostly conditions, add polymorphism if you need extensibility".

In functional languages (or languages heavily influenced by functional programming like Rust, Swift and Kotlin[1]), the classic approach for the type of scenario in this example is to use a sum type, and run a safe exhaustive match/switch on all the variants.

4. Hiding internals: The sum type example is telling of modern best-practices. Sum type fields are generally made public. Some languages (e.g. Rust and most pure functional languages) do not support private fields in sum types at all! Other languages (e.g. Kotlin) but immutable, so it's easy to maintain invariants without hiding information. Sometimes we do want to hide the type details and wrap it with public-facing type (this is a common pattern with internal error enums in Rust for example). Even in this case, there is no impact since we do not use runtime polymorphism or indirection (that would be Box<T> in Rust).

Due to compiler optimizations, hiding internals has marginal performance cost (if any) unless you require runtime polymorphism to achieve it. But why should you?

I feel like the performance costs lamented in this article mostly have to do with runtime polymorphism in static languages. And I fully agree here: runtime polymorphism is something that should be avoided when you don't need it[2]. But that's the thing: if you're looking at modern static language codebases, runtime polymorphism is not as hyped as it used to be in the past. Some languages still require heavy use of runtime polymorphism (Go is a good example of this), but other languages more often rely on static polymorphism (Rust) or compile time duck-typing (Zig and you could argue C++ template meta-programming used to do that, albeit quite awkwardly).

Even with all the issues you get with polymorphism, I don't think it's the main cause of slow application performance. It be very much the culprit in tight loops inside games, but if you look at the performance issues plaguing everyday apps, I think the two major culprits are endless layers of abstraction (the most quintessential example is basically every sluggish Electron app out there) and blocking the user on slow actions (like network loads).

---

[1] Even Java had sealed record types for a while now, and I'm sure will see Enterprise frameworks encouraging them in 20 years, when the rest of the world has moved on to spacefaring super-intelligent LLMs. But Enterprise frameworks also don't encourage you to write DRY code or keep your functions short.

[2] But do keep in mind that in Java it could be almost zero-cost in many cases. The JIT will monomorphize or bimorphize your classes if you always use the same class at the same callsite. The pointer indirection is not an extra cost, since every non-primitive that doesn't undergo Scalar Replacement[3] lives on the heap, and has a pointer.

[3] https://shipilev.net/jvm/anatomy-quarks/18-scalar-replacemen...

aw1621107•43m ago
Related:

HN post for original article on 2023-02-28 (https://news.ycombinator.com/item?id=34966137), 739 points, 914 comments

Discussion between Casey (author of this article) and Uncle Bob (author of _Clean Code_, whose programming patterns Casey is critiquing), posted on HN on 2023-03-11 (https://news.ycombinator.com/item?id=35105528), 223 points, 213 comments

"Horrible Code, Clean Performance", a "homage" to Casey's original article, posted on HN on 2023-04-19 (https://news.ycombinator.com/item?id=35596069), 121 points, 114 comments

flossly•42m ago
I'd say Clean Code is teaching many bad-practices. Too many to be recommended.
pixlmint•19m ago
eh, when I read it as a newbie it was really helpful. still had to make my own experiences and judgments, but overall I think reading it made me a better programmer
flossly•6m ago
at bast it makes to better at "Clean(TM) OOP code".

programming in general is waaaaaay bigger than what the book covers.

jgwil2•28m ago
See also the more in-depth followup "Simple Code, High Performance (https://www.youtube.com/watch?v=Ge3aKEmZcqY)
Aurornis•2m ago
I consider Clean Code to be in the category of books/styles that is helpful for early developers who need some structure, but harmful to late-stage developers who adopt it as dogma.

On a long enough career path, eventually you will run into one Clean Code zealot who carries an air of superiority and nit picks every PR over things like a function having more than an arbitrary number of lines in it instead of reviewing the actual code. This is the point where most people come to hate Clean Code.

Ray Bradbury's "There Will Come Soft Rains" is set today (2026-08-04)

https://short-stories.co/@raybradbury/there-will-come-soft-rains-6k8vr4xxlnmj
299•askvictor•5h ago•111 comments

DeepSeek V4 Flash on a Single AMD MI300X

https://github.com/ryanzhou/deepseek-v4-flash-mi300x
223•zhoutong•5h ago•52 comments

Agent skills that bring team coding standards to Claude Code and Codex

https://github.com/tikalk/adlc-team-skills
23•kanfilior•36m ago•5 comments

Xbox goes down. You can't play games you own on disc

https://birchtree.me/blog/xbox-goes-down-you-cant-play-games-you-own-on-disc/
293•surprisetalk•3h ago•297 comments

Dates That Don't Exist (2015)

https://blog.yossarian.net/2015/06/09/Dates-That-Dont-Exist
29•EndXA•2d ago•13 comments

LLMs reward expertise

https://www.seangoedecke.com/llms-reward-expertise/
1180•MaxMussio•18h ago•490 comments

Keyv and friends compromised in active Shai-Hulud supply chain attack

https://www.aikido.dev/blog/keyv-and-friends-compromised-in-npm-supply-chain-attack
88•cimi_•4h ago•27 comments

FFmpeg 9.0

https://jbkempf.com/blog/2026/ffmpeg-9.0/
7•enz•25m ago•1 comments

Buckminster Fuller: everything I know

https://www.bfi.org/about-fuller/everything-i-know/
64•simonebrunozzi•3h ago•20 comments

Harness Engineering for Self-Improvement

https://lilianweng.github.io/posts/2026-07-04-harness/
176•tosh•8h ago•32 comments

Show HN: Fine-tune an 8B model on a 4 GB laptop GPU

https://github.com/MakazhanAlpamys/Soup
63•MakazhanAlpamys•3h ago•8 comments

Roame (YC S23) Is Hiring Lead Engineer

https://www.ycombinator.com/companies/roame/jobs/mqqfa38-lead-full-stack-engineer
1•zman0225•3h ago

Why Large Language Models Fail at Tabular Prediction

https://arxiv.org/abs/2608.02412
51•sbulaev•5h ago•11 comments

Rebuilding and analysing 4 years of Wordle stats from WhatsApp chat logs

https://blog.omgmog.net/post/rebuilding-wordle-stats-from-whatsapp/
7•surprisetalk•23h ago•1 comments

Why etymologies matter: How tracing words can illuminate history (2024)

https://resobscura.substack.com/p/why-i-love-etymologies
45•benbreen•3d ago•9 comments

"Clean" Code, Horrible Performance (2023)

https://www.computerenhance.com/p/clean-code-horrible-performance
44•FrojoS•5h ago•10 comments

Show HN: Run an 80B Qwen in 4.3 GB of RAM on a Mac, and a 35B on an iPhone

https://github.com/leonickson1/Swiftlet
260•leonickson•22h ago•116 comments

Amazonian civilization had estimated 3M people in 3% of forest area

https://www.science.org/content/article/odd-shapes-hidden-dense-amazon-rainforest-reveal-sprawlin...
224•marojejian•5d ago•158 comments

AI-Generated Images Discourage Me from Reading Your Blog

https://nelson.cloud/ai-generated-images-discourage-me-from-reading-your-blog/
530•meysamazad•3h ago•307 comments

Ten advances in mathematics and theoretical computer science

https://openai.com/index/ten-advances-in-mathematics/
592•milkshakes•22h ago•876 comments

Devtools must be open source

https://blog.exe.dev/devtools-must-be-open-source
671•bryanmikaelian•1d ago•219 comments

Mosh in a Lift (2012)

https://mosh.org/elevator.txt
24•gavide•1d ago•6 comments

Homebench – Benchmark local LLMs for speed, memory, and quality

https://github.com/david-g-3654/homebench
25•davai-g•5h ago•1 comments

There Will Come Soft Rains (1950) [pdf]

https://users.wpi.edu/~zrbutzke/Docs/BradburyStories(1).pdf
263•pmg101•15h ago•96 comments

Learning-Rust.Github.io: Rust Programming Language Tutorials for Everyone

https://learning-rust.github.io
24•dumindunuwan•5h ago•2 comments

Archaeologists Find Ancient Glyphs in the Amazon

https://www.nytimes.com/2026/07/31/world/americas/amazon-archaeology-geoglyphs.html
26•wglb•3d ago•9 comments

Twenty Years of Pandoc

https://pandoc.org/twenty-years-of-pandoc.html
353•fiddlosopher•1d ago•43 comments

That time when I failed the Microsoft interview

https://ochagavia.nl/blog/that-time-when-i-failed-the-microsoft-interview/
106•wofo•6d ago•222 comments

FFmpeg 9.0

https://github.com/FFmpeg/FFmpeg/blob/n9.0/RELEASE_NOTES
346•gyan•5h ago•72 comments

Ask HN: Who is hiring? (August 2026)

211•whoishiring•1d ago•196 comments