• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

javascript performance discussion wanted

 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is javascript really that slow?

At work we are just starting to write a new ExtJS front end to our app and 2 gurus are doing all of the code reviews.
They are quibbling (my opnion) that i use the wrong type of for loop as a is more efficient than a foreach loop.

are they being sensible?>
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's quite a bit of information on this if you google it. The general consensus seems to be that foreach loops are slower. And it seems to be slower/faster depending on the browser. If your app is very front-end heavy then I wouldn't consider it to be "quibbling".
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or is this just a case of premature optimization?

 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Or is this just a case of premature optimization?



Quite possibly. I would just say that if you know something is slow and there is already an alternative then why use the slow one? It just becomes something you have to go back and refactor later.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps but in this case I've never seen a difference in performance that has had any visible effect.

For the record I use both styles -- choosing whichever seems to fit the situation better or improve the clarity of the code.
 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys,I have done some reading and with the newer browsers it doesn't make that much difference but as we are mainly going over arrays, it makes it easier anyway.

And our front end is very very heavy, it makes HTML look and behave like swing (but with enough differences to keep you irritated).
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are right that it does not make a difference anymore. Most bottlenecks come from poor design decisions and people refusing to change backends to fit the front end needs.

Eric
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic