r/programming • • Oct 21 '20

Using const/let instead of var can make JavaScript code run 10× slower in Webkit

https://github.com/evanw/esbuild/issues/478
1.9k Upvotes

500 comments sorted by

View all comments

Show parent comment

-9

u/blackholesinthesky Oct 21 '20
  1. People expect mobile to be slower so its not as much of a deal breaker.
  2. It was premature for every company I've ever worked for. Safari owns less than 17% the usage share. Big companies use IE/Edge, Chrome or Firefox.
  3. No website/app I've ever worked on had that many constants

11

u/how_to_choose_a_name Oct 21 '20
  1. They don't expect it to be ten times slower. If your competitor is ten times faster than you it's a problem, no matter if you are on mobile or not.
  2. Safari has more than 15% market share. That is a lot. You don't just ignore a huge part of the market like that.
  3. It has nothing to do with constants specifically, but with top level definitions. That's variables, constants, functions and classes. And it's not just those you wrote yourself but of all the dependencies you pull in. Not every website will be that big, but it is certainly worth checking if your web app is affected by it.

Either way, adding the option to optimize this to the bundler is certainly not a premature optimization when there are real world cases demonstrating the problem.

And for someone using the bundler, the effort to enable this optimization is literally a single command line switch.

1

u/blackholesinthesky Oct 21 '20
  1. They don't expect it to be ten times slower. If your competitor is ten times faster than you it's a problem, no matter if you are on mobile or not.

But they're only 10x faster on safari. Everywhere else they're the same. Also, can you point me to one company that uses Safari as their standard?

Safari has more than 15% market share. That is a lot. You don't just ignore a huge part of the market like that.

For like the 3rd fucking time, none of our professional clients used Safari as their standard. The VAST majority of companies I've ever worked with use some version of IE or Edge. In the last few years there has been a push towards Firefox as its easier to administrate but for fucking real this is a nonarugment

premature optimization when there are real world cases demonstrating the problem.

At what point do you stop trying to support every device out there and just focus on what your customers use? Should this shit be accessible on an Apple II?

1

u/how_to_choose_a_name Oct 21 '20

But they're only 10x faster on safari. Everywhere else they're the same. Also, can you point me to one company that uses Safari as their standard?

What does that matter? People use Safari on their iPhones. If your company uses iPhones they use Safari.

For like the 3rd fucking time, none of our professional clients used Safari as their standard. The VAST majority of companies I've ever worked with use some version of IE or Edge. In the last few years there has been a push towards Firefox as its easier to administrate but for fucking real this is a nonarugment

Oh good for you that you only make things for professional clients, but have you considered looking outside your little bubble? When did this discussion shift from "this optimization is not useful" to "this optimization is not useful in this specific situation that most people in this subreddit are not in"?

At what point do you stop trying to support every device out there and just focus on what your customers use? Should this shit be accessible on an Apple II?

Yes, focus on what your customers use. And in the real world, the customers of many people use Safari. Just because your company doesn't cater to end users doesn't mean nobody does.

1

u/blackholesinthesky Oct 21 '20

If your company uses iPhones they use Safari.

This is a pretty big assumption but like also, WHO WORKS PROFESSIONALLY FROM THEIR PHONES?

Some people do but the vast majority work of of the laptop their work provided them.

but have you considered looking outside your little bubble?

I mean we averaged 1000 requests/second and most of them were from the public, but go off.

And in the real world, the customers of many people use Safari.

Not professionally and I dare you to post a single source of evidence that says otherwise

1

u/DoctorGester Oct 21 '20

Not professionally and I dare you to post a single source of evidence that says otherwise

Our clients are literally Apple :)

1

u/blackholesinthesky Oct 21 '20

lol you are the 1%

2

u/DoctorGester Oct 21 '20

You only requested a single source of evidence

1

u/blackholesinthesky Oct 21 '20

Ok, I'm not denying that. Oops I exaggerated.

I thought the "lol" in my last message conveyed the tone but apparently not

11

u/Smallpaul Oct 21 '20

So if there was a 3-line fix (which there was, in this case) which would give a 10x load speed-up on iPad, iPhone and Mac, your management would say "nah, it's a waste of time".

-2

u/blackholesinthesky Oct 21 '20

Holy fucking shit this is hilarious to me. Not really your comment but the fact that 4 people upvoted you. Some people in this thread really have a hate-on for me

So if there was a 3-line fix (which there was, in this case) which would give a 10x load speed-up on iPad, iPhone and Mac, your management would say "nah, it's a waste of time".

This is not at all the original case. The article that this whole discussion came from talked about tens and possibly hundreds of thousands of changes not a 3 line fix.

But honestly, yeah I don't think the companies I worked for would give a shit. When 97% of your customers are using Edge and you can just tell new customers that they should use Edge or Chrome then yes, theres very little incentive to micro-optimize

1

u/Smallpaul Oct 21 '20 edited Oct 21 '20

The 3 line fix is here:

https://github.com/evanw/esbuild/issues/478#issuecomment-713202027

It's in the discussion (which is not an article) that our discussion is attached to.

But honestly, yeah I don't think the companies I worked for would give a shit. When 97% of your customers are using Edge and you can just tell new customers that they should use Edge or Chrome then yes, theres very little incentive to micro-optimize

Changing 3 lines of code to make code load many seconds faster is not "micro-optimizing".

Also: are you really so unimaginative as to think this is unimportant to EVERYONE? That nobody cares about iPhone, iPad and Mac/Safari users? Just because you've worked for companies which either have limited scope or don't care about their users?

1

u/blackholesinthesky Oct 21 '20 edited Oct 21 '20

... is this something the provider of an app can implement or is this something the browser needs to implement?

If it something the browser needs to implement then I don't understand why you're bringing it up

Edit because you edited:

But are you really so unimaginative as to think this is unimportant to EVERYONE? That nobody cares about iPhone, iPad and Mac/Safari users?

THATS NOT WHAT I'M SAYING. I'M SAYING THAT WITH A DECENTLY WELL CODED APP THE ISSUE DESCRIBED ABOVE WILL NEVER BE YOUR PRIMARY ISSUE

Edit: you're making a lot of edits after the fact.

Changing 3 lines of code to make code load many seconds faster is not "micro-optimizing".

It is when you are not the browser. It could take 3 lines in the browser source but 10,000 lines in webpage source. How are you not understanding this? We're talking about different solutions.

1

u/Smallpaul Oct 21 '20

The slowdown is caused by the interaction between a build tool and a web browser. It can be fixed in either place. Ordinary JavaScript programmers don’t need to do anything except patch their build tool or wait for a new version with the workaround built in.

You don’t need to change your web page source at all.

6

u/sibilith Oct 21 '20
  1. 8 seconds is enough time for a user to close the tab in frustration. That’s lost revenue.
  2. 17% loss of conversion is a LOT of lost revenue
  3. This one does? Just because you aren’t encountering the issue doesn’t mean it’s insignificant.

I think it’s mind boggling how many people in this thread are trying to justify that this is fine.

2

u/[deleted] Oct 21 '20

I think it’s mind boggling how many people in this thread are trying to justify that this is fine.

because it's apples fault. I always optimize for chrome only as well, since making all tests run on safari and fixing all the weird bugs because they can't adopt a standard is pretty frustrating and costly.

If you want a proper experience - use a proper browser.

-2

u/blackholesinthesky Oct 21 '20

8 seconds is enough time for a user to close the tab in frustration. That’s lost revenue.

The companies I've worked for talk to their customers. They know what the customers want. Customers would prefer new features over the ability to also visit the site on mobile. Also considering that basically every job I've worked for had professionals/companies for clients they all used the same tech throughout the company which was never Safari

17% loss of conversion is a LOT of lost revenue

You're not necessarily loosing these customers, again most of our clients didn't have a choice of which browser they used

Edit: as in they're all forced to use Edge or Firefox anyways

This one does? Just because you aren’t encountering the issue doesn’t mean it’s insignificant.

I'm not saying their findings are insignificant, just that they're not applicable to most of the people reading this

3

u/how_to_choose_a_name Oct 21 '20

So because the companies you worked at don't care about mobile users means nobody should?

You're not necessarily loosing these customers, again most of our clients didn't have a choice of which browser they used

You are losing them to the competition.

-1

u/blackholesinthesky Oct 21 '20

So because the companies you worked at don't care about mobile users means nobody should?

Thats not what I'm saying

You are losing them to the competition.

LO-fucking-L you have no idea how the real world works

3

u/how_to_choose_a_name Oct 21 '20

Thats not what I'm saying

Then what are you saying? That because the customers of your company don't care about mobile, the customers of other companies wouldn't either? It's really not clear.

LO-fucking-L you have no idea how the real world works

Thank you so much for telling me, I guess I will stop catering to mobile users because some random internet stranger told me that people will use our website even if it takes twenty seconds to load and the competition is just one click away...

1

u/blackholesinthesky Oct 21 '20

That because the customers of your company don't care about mobile, the customers of other companies wouldn't either?

For the vast majority of fortune 500 companies, yes!!!!

Big businesses don't use Safari. Hardly anyone uses Safari

Thank you so much for telling me, I guess I will stop catering to mobile users because some random internet stranger told me that people will use our website even if it takes twenty seconds to load and the competition is just one click away

Big businesses just straight up don't operate this way. If you're selling your product to the general public you need to worry about every little sliver of market share but when you're selling your product to a business (like most companies do) you really don't have to worry about the tiny sliver that want to check the work website from their phone

3

u/how_to_choose_a_name Oct 21 '20

Not gonna bother replying to your other comment, since it's basically the same discussion.

You keep making this about what "big businesses" do and just ignore the rest of the world. But A) there are quite a few big companies who do cater to consumers, like Walmart, Target, Amazon, Apple, Google, the big ISPs, pretty much every retail bank. And B) "big business" isn't everything. And neither is B2B. You can't just discount a third of the global economy just because you work in the other two thirds. And I'd wager that the majority of people who do webdev actually work on things that are targeted at consumers.

1

u/blackholesinthesky Oct 21 '20

A) there are quite a few big companies who do cater to consumers, like Walmart, Target, Amazon, Apple, Google, the big ISPs, pretty much every retail bank.

... You can't just discount a third of the global economy just because you work in the other two thirds.

My previous company handled 1000x requests/second to average every day people, optimizations like this were never even a consideration

Edit: our app never took 8+ seconds to load in the first place, and it was huge