So it is faster, for the particular benchmarks that are run in that game, given the implementations that volunteers have contributed. It does not automatically mean that JS is better; speed is not the only thing that matters.
@juliangonggrijp This is a very useful website which also makes it obvious that the performance of a language isn't easy to determine. It's still interesting.
I'm surprised that #Go seems to be significantly slower than #Rust or #C. Vut that could be due to vector instructions or things like that.
@teotwaki@juliangonggrijp I always thought Go and Rust would be somewhat similar because both just compile down to CPU instructions. So there wouldn't be much difference. Which - based on this data - seems true for C/C++ and Rust, but not for Go.
@fell@teotwaki@juliangonggrijp Optimized Rust code will always be faster than optimized Go code. Go has a runtime with garbage collection which Rust doesn't have.
In addition, Rust allows you to go as low level as you want/need. But you can also stay relatively high level.
@mo8it@fell@juliangonggrijp It also depends what you’re benchmarking. Rust/Go/C will blow Node/Python/Ruby/Java out of the water when it comes to startup cost (process start time), but a tight inner loop in a warm JVM can give C a run for its money.
@teotwaki@mo8it@juliangonggrijp I do not believe that a JVM can ever beat an optimized C program. This would imply that the C compiler is generating suboptimal machine code or the JVM has knowledge that the C compiler does not have.
Is that what happens? Does the JVM observe the running program and amend the instruction stream to improve performance? I doubt that, but it would be amazing.
@fell@teotwaki@mo8it Yes, that is what might happen, although I honestly think it is a bit theoretical. Java has such substantial costs compared to C (GC, forced type erasure) that hotspot optimization will probably only compensate for those effects in the simplest loops with low memory intensity. I think those situations will tend to be relatively easy for a C compiler with -O3 as well.
In practice, Java is usually 1.5-2 times slower than C, as demonstrated by the benchmarks game.
@fell@juliangonggrijp Golang is also the only garbage collected language out of all three. I haven’t looked at the benchmark, but that alone can give a serious slow down.
But just to clarify something: it’s not because something gets compiled down to machine code that it is inherently fast (or faster). JIT can perform miracles, and depending on the workload, cache-friendliness can have a dramatic effect.
A good Python program can outperform a bad C one, etc.
@teotwaki@juliangonggrijp Of course, good Python can outperform bad C. But what I'm looking for is typical Python vs typical C. Every language has their ways things are typically done, and that's how most code will be written. This unwritten standard is probably the biggest factor when it comes to language performance.
@fell Depens on what you are doing and where. I contend that PHP can be extremely fast and efficient on a server when it doesn't include huge frameworks to load, and JavaScript is your only real choice in a Browser. As it's on the clients computer, you could argue that it's much more efficient that whatever you run on the server. JavaScript on the server: also depends. An F1 racer and a drag car are both efficient. At different things.
At the raw code-execution level, PHP and JS are very comparable these days, AFAIK. And both are far ahead of Python or Ruby.
PHP is usually not async, though it can be. JS is always async. Depending on the use case, that may or may not impact overall performance. PHP's modern async has fewer DX problems compared to JS, but it's still new and not widely used.
Add comment