5 ms·
Agreed - and this applies in nearly every language: start simple, trust your compiler, and optimize only when performance becomes untenable.
by daviddever23box 4y ago
Agreed - and this applies in nearly every language: start simple, trust your compiler, and optimize only when performance becomes untenable.
- osigurdson 4y agoThe assumption behind such arguments is when a performance problem does arise, a profiler will point to a single, easy to fix, smoking gun. Unfortunately this is not always the case. Performance problems can be hard to diagnose and hard to fix. A lot of damage has been done by unexamined / dogmatic "root of all evil" mantra.
- throw10920 4y agoIn the vast majority of situations (1) you'll prematurely optimize in the wrong place and (2) yes the profiler will point to a single, easy-to-fix smoking gun. Situations otherwise are the exception, rather than the rule, and it takes an expert to (1) recognize those situations and (2) know exactly how to write optimized code in that situation. That's why "don't prematurely optimize" is a good rule of thumb - because it works the majority of the time, and it takes experience to know when not to apply it.
- kllrnohj 4y ago> In the vast majority of situations [..] yes the profiler will point to a single, easy-to-fix smoking gun. [citation needed] This claim depends hugely on the industry you're actually working in and the problem space. Things like UIs & games basically never have a single, easy-to-fix smoking gun. The entire app is more or less a hotspot - be it interactive performance, startup performance, RAM usage, or general responsiveness. And once you're gone down the route of "build it first, optimize it later" you're pretty much fucked when you get to the "optimize" step because now your performance mistakes are basically unfixable without a rewrite - every layer of your architecture has issues that you can't fix without drastic overhauls. It would have been much easier to do some up-front measurements, get some guidelines in place (even if they aren't perfect), and then build the app.
- osigurdson 4y agoSuggest acquiring the needed knowledge instead of applying dogma. The true root of all evil is unexamined dogma.
- throw10920 4y agoThis is ridiculous. If you had the knowledge, you'd apply it, and you can't acquire it without practice, which is going to involve heuristics (which you falsely call "dogma" in order to ad-hominem my argument) like this one, which exists precisely because you need something for when you don't have the specialized domain expertise. > The true root of all evil is unexamined dogma. This is so absurd that it doesn't deserve a reply.
- mattgreenrocks 4y agoThe misapplication of that mantra doesn’t justify the design damage done by dogmatically passing everything by ref. There’s no hard and fast rule here. Even if there was, optimizers still occasionally surprise seasoned native devs in both positive and negative ways. Glad the author’s first instinct was to pull out profiling tools.
- mlindner 4y agoI agree in general, but the side-effect of doing this is that no matter how fast your hardware gets, your software will always end up optimized to the new hardware. So over time your software gets slower and slower but performance stays consistent as hardware gets faster.
- kllrnohj 4y agoThis advice hinges hugely on what "start simple" really means. There's a ton of counter-examples here where that just isn't true at all depending on what you're calling "simple". In particular JIT'd languages can be especially problematic here. An example would be using Java's Streams interfaces to do something that could be done without much difficulty with a regular boring ol' for loop. At the end of the day you're hoping the JIT will eventually convert the streams version into the same bytecode the for loop version would have started with. But it won't do that consistently, and you've still wasted time before it did so. Trusting the compiler also means knowing what the compiler actually understands & handles vs. what's a library-provided abstraction that's maybe too bloated for its own good and that quickly becomes "not simple" depending on your language of choice.
- int_19h 4y ago> you're hoping the JIT will eventually convert the streams version into the same bytecode Not really. I'm just hoping that it will be "fast enough", which in the vast majority of cases it is.