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.
>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++.
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:
I know there was a lot of teeth gnashing in the past about HotSpot warmup, and I think it mostly boiled down to not much of a difference for most tests.
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.
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.
>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. ;)
I just now created the repo for this purpose, hoped to reach some more experience C developers with it and prove me wrong.
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++.
Yeah, feel free to contribute / create a PR with a more C/C++ suited algorithm.
1BRC was quite fun read. Author really needs better benchmark if they want to get PR out of it =)
I added some further optimizations and guess I was wrong!
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:
https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
...where it looks like GCC C++ beats GraalVM in all the tests.
Do they compare the second run of Java? Because using GraalVM native image does not really benefit from runtime info and optimization.
I know there was a lot of teeth gnashing in the past about HotSpot warmup, and I think it mostly boiled down to not much of a difference for most tests.
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.