This week's book giveaways are in the Cloud and AI/ML forums.
We're giving away four copies each of Cloud Native Patterns and Natural Language Processing and have the authors on-line!
See this thread and this one for details.
Win a copy of Cloud Native PatternsE this week in the Cloud forum
or Natural Language Processing in the AI/ML forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

speed of Javascript

 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How has the speed of Javascript changed during the war of browsers? Thanks in advance, Gregor
 
Author
Posts: 23
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's gotten much much faster. IMO it is now "good enough" for most applications. It will never be as fast as Java, however.
 
Marshal
Posts: 67273
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JavaScript speed has been a "selling point" for browsers, so there is stiff competition for speeding up the JavaScript engines. This is a very good thing.
 
Author
Posts: 4
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do a comparison of JavaScript with other scripting languages in a number of presentations. Generally, it is somewhere between 6-20x faster in benchmarks over native Ruby, PHP, Perl, and Python. In some cases, it approaches Java's speed. Due to the JS wars, most JS today is JIT compiled, and now run-time optimized (Chrome). Mozilla introduced type-inference to reduce execution time an additional 30%.

This means that for long-running JS applications, like an SPA, JS performance is very good, and in the latest Chrome, it can even improve over time as run-time optimizations are employed.

The Web client will be JavaScript for the foreseeable future, so this is great news. On the server, it might be even better news: using Node.js + MongoDB over something like Ruby + ActiveRecord + MySql might be 6x faster for some workloads. So do we want 7 RoR servers (1 for redundancy) or 2 Node servers? *All else being equal* the answer is obvious.
 
Josh Powell
Author
Posts: 23
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are so many what-ifs else's and but's when it comes to benchmarks and performance that it's really hard to know what the answer is. You have to quantify each particular use case, what kind of equipment it will be running on, and then you have to write efficient code in that language. Crap code can be written in any language. Then performance isn't the only reason to choose a language, you have to balance it against ease of use/development/maintenance, how it can interact with other components, how well supported it is in the developer community, and much more before arriving at a conclusion about a technology choice. That's why I say it is "fast enough" because it's to the point where discussions of speed is irrelevant for most applications.

7-10 years ago in the JavaScript community one big argument was what the fastest way to concatenate strings was: using the + operator ( "string1" + "string2") or array joining (["string1", "string2"].join). This really mattered then, the difference could be in the seconds, these days the difference is measures in milliseconds and it doesn't matter for most practical applications. The difference in speed between javascript, ruby, java, and whatever else just doesn't matter for most applications. They are plenty fast. Most often the biggest speed penalty is in network latency and database query time and is fixed by better structuring the data and smarter caching.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!