>A repo dedicated to showing why Java is better than all other languages
>0 stars
The premise of the JIT compiler and optimizations leading to faster execution seems plausible. It's not the first time I've heard it either. I just thought the above two things were humorous. ;)
Also countPrimes() is side-effect free, and the value isn't used. So I wouldn't be surprised that at a high enough optimization level, that neither instance of countPrimes() is called for C or C++.
This is about the optimising of logic, not languages. At the bottom there are the same instructions which know nothing of the language that conjured them up. Hats off to whoever did the work on this, but let's not get confused about where the magic happens.
True but let's also not forget the unpredictability of stupidity in human developers which probably cause the majority of performance loss in any language.
Your upper limit (1000000) needs to come from runtime (user input/file), otherwise you could create a C++ template program to compute the answer at compile time. Also, you might be interested in the Benchmarks Game:
Feel free to create a PR on the linked repo and prove me wrong.
To add some detail: I think that 99% of algorithms are faster in Java in their second run than in any other Language due to the better JIT compiler and optimizations that are possible.
I am talking about the GraalVM distribution of Java and its latest version, but we might as well use other distros.
evanjrowley|1 year ago
>0 stars
The premise of the JIT compiler and optimizations leading to faster execution seems plausible. It's not the first time I've heard it either. I just thought the above two things were humorous. ;)
Osiris-Team|1 year ago
floxy|1 year ago
Osiris-Team|1 year ago
beardyw|1 year ago
Osiris-Team|1 year ago
SleepyMyroslav|1 year ago
Osiris-Team|1 year ago
floxy|1 year ago
https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
...where it looks like GCC C++ beats GraalVM in all the tests.
Osiris-Team|1 year ago
Osiris-Team|1 year ago
To add some detail: I think that 99% of algorithms are faster in Java in their second run than in any other Language due to the better JIT compiler and optimizations that are possible. I am talking about the GraalVM distribution of Java and its latest version, but we might as well use other distros.
igouy|1 year ago
https://sgitario.github.io/graalvm-getting-started/
https://github.com/openjdk/jmh/