evanjrowley 8 months ago

>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. ;)

  • Osiris-Team 8 months ago

    I just now created the repo for this purpose, hoped to reach some more experience C developers with it and prove me wrong.

    • igouy 7 months ago

      ? Fastest implementation: c_clang with 14.51 ms (0.0145 s).

      • Osiris-Team 7 months ago

        Yeah I proved myself wrong after adding more compiler optimizations.

floxy 8 months ago

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++.

  • Osiris-Team 8 months ago

    Yeah, feel free to contribute / create a PR with a more C/C++ suited algorithm.

beardyw 8 months ago

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.

  • Osiris-Team 8 months ago

    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.

SleepyMyroslav 8 months ago

1BRC was quite fun read. Author really needs better benchmark if they want to get PR out of it =)

Osiris-Team 8 months ago

I added some further optimizations and guess I was wrong!

floxy 8 months ago

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.

Osiris-Team 8 months ago

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.