News for hackers. Stuff that matters.
Re:“Clean” Code, Horrible Performance by TeMPOraL on Tuesday February 28, 2023 @05:40PM (#34975956)
Casey's implied point is that clean code is already sacrificing performance from the start. And of course real life tells us that those "performance tweaks" will never happen.

There is this popular wisdom that security must be designed for from the start, and cannot be just added after the fact. Performance is like that too, except worse, because you actually can add security after the fact - worst-case, you treat the entire system as untrustworthy and wrap a layer of security around it. You can't do that with performance - there is no way to sandbox your app so it goes faster. You can only profile things then rip out the slow parts and replace them with fast ones - how easy that is depends on the architecture and approach you adopt early in the project.

Re:“Clean” Code, Horrible Performance by loup-vaillant on Tuesday February 28, 2023 @06:03PM (#34976170)
> there is no way to sandbox your app so it goes faster.

In a number of cases you actually can. Casey demonstrated it in his Refterm lectures, it's caching. You still call the slow thing, but at least you don't call it as often because you have that layer of caching to partially insulate you from its poor performance. Good luck if you have to deal with cache invalidation, though.

Re:“Clean” Code, Horrible Performance by TeMPOraL on Tuesday February 28, 2023 @07:03PM (#34976767)
Fair enough.

I'll concede on saying that performance and security are alike - you can add some of either after the fact, but you're better off thinking about both from the start.

> Good luck if you have to deal with cache invalidation, though.

Ain't it the truth. Adding a cache is easy. Understanding the implications of doing it is harder.

Re:“Clean” Code, Horrible Performance by Turskarama on Tuesday February 28, 2023 @06:04PM (#34976183)
This is not my experience at all, at my org we always write it the simple way first, and if it needs more performance after the fact then we always add the performance. User friendliness always comes first. This includes not waiting 20 seconds for a db query that could be rewritten to happen in 1 second, but it also means not waiting a month for a bugfix which could happen in a day with maintainable code.
Re:“Clean” Code, Horrible Performance by TeMPOraL on Tuesday February 28, 2023 @07:13PM (#34976878)
That's a nice approach, and I envy you the environment you work in.

In my experience so far, it's typically the case that the 20 second DB query will annoy people for months or years - it won't get solved until enough people raise enough of a stink that someone finally prioritizes it. A large customer suddenly starting to make vague hints about bad performance is sometimes (but not always) helpful.

Some may say that "annoying, but not enough to make a stink about it" means it's fine to not optimize it. But I found that people can suffer a lot, and it doesn't mean it's harmless. People will adjust their workflows to minimize the frustration. When some of your "victims" are in-house users, the "not important enough" performance issue may be silently but continuously losing company money.

Re:“Clean” Code, Horrible Performance by eyelidlessness on Tuesday February 28, 2023 @07:37PM (#34977139)
> In my experience so far, it's typically the case that the 20 second DB query will annoy people for months or years - it won't get solved until enough people raise enough of a stink that someone finally prioritizes it.

Among the many things I’ve learned as a self taught dev: you can be the person who raises enough of a stink if you care a lot. It’s not a thing you want to invoke frequently, but it’s a thing you very probably have power to invoke where it matters most. If you can make a good business case (or any case for user success that impairs your org), you have very good odds of being able to pursue it in any but the most toxic situations. If you can link $thing-you-want-to-pursue to other probably shinier biz/org goals, you’re 99% of the way there.

Re:“Clean” Code, Horrible Performance by saagarjha on Tuesday February 28, 2023 @06:21PM (#34976376)
Adding performance to software after the fact is typically far easier than securing it. Layers of security have to be watertight, and generally they are not if you don't design them from the start to be. A good performance engineer works in the constraints of their project to balance minimal code changes with performance wins.
Re:“Clean” Code, Horrible Performance by peterashford on Tuesday February 28, 2023 @07:16PM (#34976928)
This isn't true in my experience. Even in the context of games development. It pays to be simple at the outset because you often need to iterate code to get it right and writing and iterating optimised code is harder and slower than just doing something simple first. And YES, we ALWAYS went back and optimised the slow bits.
Re:“Clean” Code, Horrible Performance by whstl on Tuesday February 28, 2023 @11:06PM (#34978649)
But "being simple from the outset" is exactly what Casey is advocating here. Start with the simple code, that he ends up with, rather than optimizing for a "Cleanliness" metric.

His final code is definitely simpler than the alternative, which would probably involve several files in another environment.

Sure, he does reach for a benchmark, but that's merely to demonstrate the end result.

Re:“Clean” Code, Horrible Performance by eyelidlessness on Tuesday February 28, 2023 @07:27PM (#34977038)
> And of course real life tells us that those "performance tweaks" will never happen.

I seldom wish I could post images on here, but I really would love to share a photo of the surprise coffee mug my work sent me, with a screen cap of a completely obliterated Y axis on a performance monitoring graph. Granted I don’t get to spend all my time hunting optimizations, but some teams/orgs/companies do very much value performance very explicitly.

Edit: and I’m definitely not a game dev. Though I’ve been itching to borrow some game dev techniques that are quite applicable for my domain (particularly ECS, entity component systems, which I suspect have far broader applicability than their adoption outside of game dev).

Re:“Clean” Code, Horrible Performance by Aeolun on Tuesday February 28, 2023 @07:46PM (#34977208)
> Casey's implied point is that clean code is already sacrificing performance from the start.

Where our opinion seems to diverge is where I accept that as being fine, for the sake of being clean/legible/understandable.

Re:“Clean” Code, Horrible Performance by curtainsforus on Friday March 10, 2023 @07:53AM (#35093735)
The argument continues to say that the 'clean code' version isn't actually cleaner/more legible/more understandable. I, for one, am royally sick of spending 5 minutes trying to figure out which virtual function implementation was actually called!