|
|
|
|
|
by gruez
1654 days ago
|
|
>The responsibility of making code efficient (dare I say "green") lies in those writing the browser engines/compilers. I don't get it. Are they not doing that? Performance and battery life is a major selling point for browsers. If anything the biggest failure is at the individual developer/site level, not that firefox causes your fan to spin into overdrive when it tries to load a SPA monstrosity. |
|
The problem is telling individuals to focus on optimization.
Let's use javascript as an example. Say you need to transform an array. You can use `.map` or a `for` loop in javascript.
You see a lot of articles like this https://dev.to/henryjw/array-map-much-slower-than-for-loop-5... that say a `for` loop is faster. And sometimes it's true.
By the logic of the original article, you should hyperoptimize your code. The problem is. If everyone writes `for` loops instead of using `map`. When map eventually becomes more efficient there's all that garbage code out there that has to be refactored.
Ignoring the problems associated with benchmarking - this for example claims map now being faster than for loops. https://leanylabs.com/blog/js-forEach-map-reduce-vs-for-for_...
It comes down to return on effort. We only have so much effort to put at solving this problem. You maximize your return on effort by having a clear separation of responsibility. In this case the individual's responsibility is to write code to the latest spec. The institution's responsibility is to make the code written as efficient as possible.
A single website saving .000000001 ppm of carbon (exaggerating) is just never going to be worth the effort. But a compiler improvement on all websites running javascript. Now that's totally worth it.
Further reading behind this logic: https://www.goodreads.com/book/show/3828902-thinking-in-syst...
https://stackify.com/premature-optimization-evil/
Code Complete (chapter 25.2) https://www.oreilly.com/library/view/code-complete-second/07...