During all that time I am engaged with programming, I hear that C and C++ are the speed standards. Fastest of the fastest, compiled straight to ass...
For further actions, you may consider blocking this person and/or reporting abuse
Excuse me, but this is utter bullshit. The issue with such benchmarks is that they compare suboptimal and often even unoptimized code. To really assess the performance of languages (and thus quality of compilers), you have to compare the best programs with one another. There are projects with hundreds of participants, all trying to put out the fastest solutions in their favorite languages, like PlummersSoftwareLLC/Primes, which provide some actually useful information. In the mentioned project, currently the fasted faithful Java solution has
16466
passes (in 5 seconds), compared to372283
passes for the fastest faithful C solution. That is a performance increase by more than 2160% (and there are compiled Java solutions included). Potential hardware differences do not account for differences anywhere near. Some languages even have features that when optimizing based on a little more knowledge (than considered "faithful" in this case), performance can be pushed much further, e.g. with591836324
passes in thisconstexpr
-heavy C++ solution. That's another improvement of over 158874% over a solution that was already over 2160% faster than the best known Java solution.The relevant question w.r.t. optimized performance is how much a language and its compilers (on best optimization settings) support creating really performant machine code.
Slow crappy code can be written in every language, and C code that is only a few percentages faster than Java code is likely garbage. There are good reasons why there are usually only three languages considered acceptable for high-performance computing: Fortran (outdated), C, and C++. One of them is that managed languages tend to both multiply required memory and computing time when it comes to well-written programs.
If so, you are welcome to provide faster C code for this test.
If there is no better code for C test, it means we already have best one.
I do not waste my time on such trivial matters, but since you suggested it and are into these things, you yourself could provide faster Java code for PlummersSoftwareLLC/Primes.
Regardless, you seem to have entirely missed the point that your benchmark doesn't show anything significant. The code is too trivial. You even ruled out compiler optimizations which produce constant-time algorithms. It's worthless on so many levels, and if you carefully follow what I wrote in my last comment, you might even understand why.
Come on, why are you talking about programming and performance when not even able to form basic logical thoughts? All you did is "perform exactly the same high level algorithm without decent optimization and measure the time difference".
Real world problems are far too complex for nonsense like that. Good algorithms for the same problem adjust based on the language they're written in. A problem like yours can easily be solved via
constexpr
, i.e. virtually no runtime, in C++, for example. And in greater programs where runtime matters, it would. Java doesn't even support that for non-primitive types, therefore it is far inferior. Programming languages are about design principles, features and compiler quality. Your test is merely asking whether hardware suddenly performs miracles when executing almost the same instructions due to originating from a different language, which of course it does not. The only plausible offset there is virtual machine overhead.By the way, already in the beginning of your article, your
demonstrated that you are a complete amateur to coding. Not only do C and C++ not compile to assembly but to machine code, but also are there many amateurs trying to challenge such things early on, but it keeps being an obvious fact that languages like Java are terrible when it comes to performance, while languages like C and C++ are decent. Just like most amateurs putting out such beliefs, you did not even understand where and how software performance matters, possibly not even what it is, and definitely not how it is accomplished.
Whether compilers internally take such an intermediate step is both compiler-specific and irrelevant, since the object files contain already machine code, and the machine code is also what is executed and determines performance.
You are projecting.
False. You just seem unable to read properly, and apparently you are emotionally overwhelmed by sincere criticism since you feel like I'd attack your personality rather than your stupid claims, which is false. So far I kept expecting more from you before you requested me to dumb down things for you multiple times.
However, since you asked again, I'll just lay it out as if you were mentally retarded — you are clearly acting as such:
You asked me to
I answered, among other things:
I was just trying to help you and other people new to programming. You might be resistant to learning thus a waste of time, but others might not. What is definitely a waste of time is reading your article...
Nah, I'm sincere. But you are so insincere and wrong about everything, it is disgusting.
You have nothing like that, as I have already provided valid arguments for.
Yes, I just happen to be disgusted by such levels of stupidity and willful ignorance, it's a personality trait.
Ah, feel free to check out my project: github.com/xamidi/pmGenerator
Originally, I just came here today for this comment where I mentioned it. Unfortunately, I got baited by your bullshit article and thought I'd do a good deed today and debunk it.
All that I wrote about that actually useful benchmark project and how things work, insane that you ignore it all. It strongly suggests that you are trolling, but seeing that you put out that article and repo, clearly being at least trying, you just must be super delusional.
I guess your self-description as an "in a healthy way arrogant person" is deeply twisted. More like full of narcissistic delusion, with a Dunning-Kruger of doom.
Edit: Deletes embarrassing comments, proceeds with baseless crap hereafter.
Can't even make this shit up, lol.
:D said guy who also said "I don't waste time on trivial matters".
Really you know a lot about narcissism.
You are a joke.
Also, if you start using dirty tricks - I checked your github, it is a shame.
That's what I call an amateur.
Seems you really don't know C++, because your code is a disaster.
I don't know how to take you seriously after that.
Incase you didnt get the notification, I made a version of class_alloc that also uses std::allocator for comparison as you requested.
dev.to/plotarmouredtitan/comment/2...
I wasn't online, sorry, thanks for your code. I answered in that thread
@plotarmouredtitan FYI, one of the deleted comments of Taqmuraz was
(apart from calling C++ code on expert level "a disaster"),
so it's clearly pointless trying to teach them C++ since they're just trying to hate on it.
After the garbage collector moves or disposes of objects, there may be "holes" in the allocated memory unless it performs "defragmentation" afterward. So, newly created objects do not necessarily mean simply "moving the pointer to the right."
Additionally, the garbage collector is notoriously known for causing the entire system to wait while it completes its tasks. It runs unexpectedly and can take significant amount of time in large projects, so you literally cannot build "real-time" systems on GC languages
the garbage collector is notoriously known for causing the entire system to wait while it complete...
You know about which amount of times we are talking? micro seconds? Also depending on which GC you are using...
Well, it depends on the allocated memory size and sometimes it takes dozens of milliseconds which can be noticeable in smooth animation or gaming. I also came across articles about experimental operating systems built on managed code, which tend to operate too slowly.
Benchmarks demonstrate opposite.
In Java or Go GC allocates memory just moving the pointer after filling by zeros. As I said in the article, GC moves all alive objects to the end of the last generation heap peak. So, there are no gaps between objects.
Go has a non-moving GC.
Thank you very much for the information
According to the methods used in this article, Clojure should be close to Java:
github.com/Taqmuraz/speed-table/is...
On my machine Clojure test takes 373ms. If I do benchmarking wrong, let me know