6 ms·
Ask HN: why is js winning the dynamic language performance race?
I've been quite surprised to see how quickly the performance of the major javascript engines has improved. It went from being a fairly slow language to a language that in its fastest implementations (v8) is significantly faster than python, ruby, perl and php. The teams working on performance for those languages don't seem to have made anything close to the same progress.
Why is this? Is JS just an easier language to optimize? Are the JS engine teams just more skilled?
- cpr 16y agoSimply because the new hotness is the browser space (the new operating system wars), and he with the fastest browser of the moment gets to brag. It does happen that some of the most skilled virtual machine developers in the world are working on V8, for example. (Lars Bak is leading their effort, and he was one of the leads on the Self/Java Hotspot engines, having now built several generations of optimizers for dynamic languages). This is not a coincidence. ;-) And it also happens that, until a little while back when JS performance became important, the JS engines were pretty backwater-ish, and quite slow. So it's fairly easy to make important speed gains when starting from such a lowly position.
- cageface 16y agoYeah obviously JS had a lot of ground to cover. The surprising thing to me is that they have not only caught up, but surpassed the other dynamic languages, despite all the engineering effort that's gone into speeding them up. I'm sure having somebody with Bak's experience on the job makes a big difference. The other browser JS implementations seem to be keeping pace though.
- chromatic 16y ago... despite all the engineering effort that's gone into speeding them up. Implementing and optimizing a language are big projects. They benefit a lot from sponsors. See Sun, IBM, Microsoft, Mozilla, Google, and Opera. (I don't know of a single company which has sponsored LuaJIT, but it's worth mentioning.)
- acqq 16y agoI don't agree that "it's fairly easy to make important speed gains when starting from such a lowly position" has any relevance: In my micro-tests Opera's JS can run the same numeric loop (producing the same result!) almost 200 TIMES faster than Python, and for example, faster than the C code compiled by gcc 3. Opera manages to achieve that from plain JS code, and up to then only ActiveScript and Microsoft's JScript were able to match, but they both needed explicit typing for the same results. So it doesn't matter where they started, now they really achieve impressive results. It's true, though, that Google's move resulted in everybody else having to do that too. Microsoft tried to avoid, as they knew that Google benefits more from really fast JS, but the pressure continued...
- PassTheAmmo 16y agoLua is still beating v8 rather handily though. http://shootout.alioth.debian.org/u32/benchmark.php?test=all&lang=v8&lang2=luajit http://shootout.alioth.debian.org/u32/benchmark.php?test=all...
- cageface 16y agoYeah Lua bucks the trend. Maybe it's just a matter of the experience and skill of the team and not the number of man-hours dumped into it? Maybe it's a little bit like writing graphics drivers, just one of those things that only a small handful of people can really do well.
- Twisol 16y agoI remember reading something about how JavaScript has so many backwards-compatibility edge cases that it's extremely difficult to write a performant engine. Unfortunately I can't find my source. Lua has the turtle's mindset. It's gone slow and steady, and its releases are anything but frequent. However, that just goes to show how stable of a product it is. (Considering the context, maybe a turtle wasn't the best comparison...)
- igouy 16y agoThose are the measurements for Mike Pall's LuaJIT - not for the standard Lua implementation. Here's JavaScript V8 :: Lua http://shootout.alioth.debian.org/u32/benchmark.php?test=all&lang=v8&lang2=lua http://shootout.alioth.debian.org/u32/benchmark.php?test=all...