DEV Community

Discussion on: Stop Writing JavaScript Like This

 
Sloan, the sloth mascot
Comment deleted
 
peerreynders profile image
peerreynders

In the meantime real-life users have to deal with this.

Thread Thread
 
Sloan, the sloth mascot
Comment deleted
 
peerreynders profile image
peerreynders • Edited

If I had to choose between making my code readable and optimizing for a particular browser's proprietary JS engine, I would always choose the former.

Attitudes like that play right into Apple's hands if you believe that the "state of Safari" reflects a desire to deemphasize the importance and relevance of the web.

Then for a web professional that mindset is equivalent to "sawing off the branch you're sitting on".

There is a difference between "efficient coding idioms" and "premature optimization" and those two should not be confused.

PS: Then again maybe it's Chrome that is the real problem: Breaking the web forward.

Thread Thread
 
Sloan, the sloth mascot
Comment deleted
 
peerreynders profile image
peerreynders • Edited

Saying it works on Chrome is the web equivalent of "it works on my machine" — and fundamentally fails to recognize the nature of the web — there is no web platform, there’s an immensely varied collection of web platforms so lots of common wisdom from the backend doesn't directly apply.

And how is giving Safari users an adequate UX playing into Apple's hands? Apple doesn't benefit if you actually poly- and ponyfill Safari's inadequacies as you help to keep the web working. Most iOS user's don't realize that iOS Chrome is just Safari with a paint job so if the web is doing poorly on their flagship device it must be the web's fault, not Apple's.

Thread Thread
 
Sloan, the sloth mascot
Comment deleted
 
peerreynders profile image
peerreynders • Edited

You've completely lost sight of what matters and have gone off on a tangent.

The issue is the difference between "efficient coding idioms" vs. "premature optimizations".

If your application has to only work over a cooperate intranet with a strictly standardized web browser it's easy to determine what works and what doesn't. Over the public web matters are much more complicated and much less predictable especially when JavaScript is involved. So the blanket

These kinds of performance optimizations don't matter. At all

without consideration of any type of context is entirely inappropriate. For example the iteration mechanism that is consistently performant across the majority of situations is the plain for loop. Does that mean bad things will happen if you prefer array functions? Not likely but context matters. As always — it depends.

The other issue is that current benchmarks don't typically cover memory pressure.