News for hackers. Stuff that matters.
Re:“Clean” Code, Horrible Performance by mquander on Tuesday February 28, 2023 @06:13PM (#34976280)
The subfields of programming I know the most about are game development, networking, and web development, and in all of those, it's not the case that only 1% of the code is in the "edge case" where performance matters at all.

For example, in the case of web development, if you build a medium-sized website with React (i.e. pretty normal behavior nowadays), then if you make default decisions that don't consider performance at all, your website will end up noticeably slow, because you will:

1. Write code that re-renders components all the time during loading and UI interactions,

2. Which depend on tons of third-party dependencies that perform poorly,

3. So you end up spending a ton of time in re-renders while the site loads and while someone is using it.

Dealing with this isn't literally the same performance work that Casey put in his article, because it's at a slightly higher level of abstraction, but it requires the same mindset. It requires writing most of your code (and taking on dependencies) with performance in mind, not just 1% of it. You can't avoid it without your notion of "clean code" including some amount of mechanical sympathy, rather than just being about abstract extensibility and generalization concerns.

Re:“Clean” Code, Horrible Performance by whstl on Tuesday February 28, 2023 @07:14PM (#34976890)
It's also very easy to mess up the performance due to architecture when using modern frameworks. For example: as much as SPAs are reviled, if you have a complex enough web application with heavy components, having it being an SPA might be better in terms of perceived speed than having it do a full reload on every navigation.

This is a mistake that I see far too many government and utility sites making.

Re:“Clean” Code, Horrible Performance by Aeolun on Tuesday February 28, 2023 @07:50PM (#34977249)
Except that in React writing clean code will actually make your application faster.
Re:“Clean” Code, Horrible Performance by engineeringwoke on Tuesday February 28, 2023 @08:16PM (#34977469)
Re-renders are incredibly cheap in the big picture. They are not a source of performance bottlenecks in 99% of real world applications
Re:“Clean” Code, Horrible Performance by xtian on Tuesday February 28, 2023 @09:12PM (#34977892)
So why do 99% of real world applications run like garbage? What’s the culprit?
Re:“Clean” Code, Horrible Performance by simplotek on Wednesday March 01, 2023 @02:30AM (#34979708)
> So why do 99% of real world applications run like garbage?

If you're really interested in the impact of performance issues on everyday life, you need to provide concrete examples instead of putting up unverifiable strawmen.

The truth of the matter is that 99% of real world applications run just fine, and it doesn't pay off to invest in shaving milliseconds here or there. Would it be desirable to have a magic wand to improve some edge cases? Yeah, why not? Is it worth to pay people to spend time with a stopwatch at hand to shave off these milliseconds? Not really. It's all about tradeoffs, and there is no real world payoff in wasting developers' time to shave off that millisecond here or there.

Re:“Clean” Code, Horrible Performance by wruza on Wednesday March 01, 2023 @03:30AM (#34980042)
The promise of frameworks like React is that you write code in their way and they take care of performance, because functional, declarative and all that. You just use primitives and don’t control how it all works under the hood. Coping may be a good strategy here, but isn’t a good argument.
Re:“Clean” Code, Horrible Performance by nottorp on Wednesday March 01, 2023 @03:31AM (#34980047)
You basically waste millions of seconds of users' lifetime instead :)

Not to mention that web apps redrawing everything whenever they feel like it can almost give motion sickness, lead to clicks on the wrong things etc.

Yeah, but users' time is worthless.

Re:“Clean” Code, Horrible Performance by mtrower on Wednesday March 01, 2023 @04:00AM (#34980251)
You know, I started on some concrete examples for you, but I had to stop and back up. Really? You can't think of any examples yourself? The modern web is absolute hell to use if you aren't on modern hardware. Try it sometime; use a 10 year old phone, or an old computer that wasn't built top-of-the-line.

There's so much hardware out there that can run native applications just fine, that can play back HD video, that can run complex 3D real time video games, but crawl like molasses when loading your average webpage. Facebook and YouTube are terrible offenders, but so are your average blogs. Many banking websites are terrible (yet they don't have to be; my local credit union has a zippy website that looks attractive to boot, has modern design elements, etc.).

Maybe the hardware you're running is eye-wateringly fast, or maybe it's just barely fast enough and you don't need the cycles for anything else. But we're not talking milliseconds. We're talking order(s) of magnitude. I can't bring myself to believe you don't see at least some of it, if you just open your eyes and look around.

Re:“Clean” Code, Horrible Performance by albedoa on Wednesday March 01, 2023 @08:08AM (#34981951)
> Really? You can't think of any examples yourself?

"Unverifiable!", he wrote from within a web browser.

Re:“Clean” Code, Horrible Performance by whstl on Wednesday March 01, 2023 @04:02AM (#34980263)
Since we're talking about React, Facebook's web app is incredibly slow to me, and typing text in some fields is slower than me. As in, it sometimes takes a second for the letters to start showing. And no, it's not a browser rendering issue (even if it were it would be terrible), as disabling JS in Safari brings back the performance.

Another app that I'm not sure if it's React or not is New Reddit. It is significantly slower on my computer and on a lot of people's computer and sometimes you have to refresh the page because it consumes too much memory.

I can come up with other local examples, from Germany. Vatenfall's website seems to "traditional" page navigation, but the content is loaded via a framework. Due to having to reinitialize everything, text takes up to 5 seconds to appear when using the back button or when navigating for page to page. Similar things happen in the German Agentür fur Arbeit.

Re:“Clean” Code, Horrible Performance by cnity on Wednesday March 01, 2023 @04:22AM (#34980353)
My hot take is that React doesn't directly _cause_ slow performance, but that React is so well marketed as a first place to start for new programmers that the bar for quality is much lower than other industries (like game programming, or even "vanilla JS" which is increasingly seen as an advanced approach).
Re:“Clean” Code, Horrible Performance by sanitycheck on Wednesday March 01, 2023 @05:24AM (#34980765)
The trouble with this attitude, is that it misses the fact that the _range_ of computing power of devices which ordinary people use is probably greater now than it's ever been.

Let's not even get into low end phones in developing countries or bargain basement android tablets, let's stick with something straightforward - an ordinary PC.

I took a quick look online, sorting by cheapest first I found something with an AMD 3015e in. Based on cpubenchmark.net that gets a benchmark of 2691. Taking a look at the big list of CPUs I see that's equivalent to a powerful desktop CPU from 2008, or a decent laptop from 2012. (The Apple M2 in the current Macbook Air gets a score of 15369, just for comparison.)

So, if you're writing PC software or making a fancy web app and you want everyone to have a good experience with it then you should see how it runs on a terrible new laptop, or a 12 year old good laptop, or a 15 year old powerful desktop.

(And yeah we all have SSDs now which is much better than in the old days, and JS is generally single thread, and single threaded CPU performance has not improved so much - but I think my point still stands.)

Re:“Clean” Code, Horrible Performance by xtian on Wednesday March 01, 2023 @12:22PM (#34985111)
> The truth of the matter is that 99% of real world applications run just fine, and it doesn't pay off to invest in shaving milliseconds here or there.

You're taking deep quaffs of the Kool-Aid and so are most of the people commenting on this story. General software responsiveness and reliability (i.e., usefulness) has been in decline for decades. This is an objective fact.

Writing objective reality off as mere "milliseconds", "edge-cases", or only relevant for "toy problems" exemplifies the arrogance and severe incompetence of most programmers. People are seriously trying to talk down to Casey Muratori when in all likelihood they haven't accomplished even 1% as much as him as programmers.

I get it—no one wants to leave fantasy-land as long as the easy money is flowing. But sooner or later the glittering carriage turns back into a pumpkin.

Re:“Clean” Code, Horrible Performance by gitgud on Wednesday March 01, 2023 @01:13PM (#34986058)
Go to a slow website on Chrome. Open dev tools and turn on "enable paint flashing", you'll see a seizure inducing light show of re-rendering...

It's certainly a huge problem for real world applications