Logo
Print this page
Save to disk

C++ clear winner in Google language tests

06 Jun 2011, Derek du Preez, Computing

http://www.computing.co.uk/ctg/news/2076322/-winner-google-language-tests

decoding-edm

Google has released a research paper that suggests C++ is the best-performing programming language in the market.

The internet giant implemented a compact algorithm in four languages – C++, Java, Scala and its own programming language Go – and then benchmarked results to find "factors of difference".

"We find that in terms of performance, C++ wins out by a large margin," the paper says.

However, despite C++ trumping the others in performance, Google also suggests that it requires the "most extensive tuning efforts, many of which were done at a level of sophistication that would not be available to the average programmer".

This compares to Java, which the paper describes as the "simplest to implement", but also the hardest to analyse for performance.

The research found that Scala had "powerful language features", which allowed for the "best optimisation of code complexity".

Google also ran tests on Go, a language it began developing in 2007. In May 2010, the company said that Go was being used for "real stuff", by which it probably meant distributed web services.

However, Go did not stand up too well against the more established languages, as the tests indicated that the compilers for it are "still immature", which was reflected in "both performance and binary size".

Reader comments

yay I program in C++ ^^

Sweet, I feel lucky that I'm learning C++ lol

Posted by: Some Guy  09 Jun 2011

As expected, glad to hear it.

This is pretty much the results I would have expected. Still, it is nice to hear that the testing has actually been done by some entity like Google.

Posted by: Agentlien  09 Jun 2011

Expected

Java was expected to lose, its an interpreted and not compiled language. Obviously being compiled to ASM and run natively on the processor is the fastest option. I'd like to see the actual speed comparison between GO and C++ though..

Posted by: Dan  09 Jun 2011

Best of the Best

Now I have something from the biggest web services company in the world to show some people. Java is one of the best, but C++ is always best of the best.

Posted by: Shadi Naif  09 Jun 2011

To Dan

Dan,
Though you are partially right, the things are not completely as you said: Current JVM compile the bytecodes to native while executing the program (JIT). The nice part of that is that you can perform more optimizations on running code than when compiling statically (the JIT can inline some methods, compile to use very specific features of your processor, etc); so, though this test proved the natively compiled code is faster than the JITted one; in real-life desktop applications I think such velocity is unnoticed.
If you like to see the numbers, you could open the research paper PDF that is linked in the fist paragraph of this article.

Posted by: Ernesto  10 Jun 2011

I am doing C++ since ~20 years

Not surprised... although 'C' is even faster than C++, and then I remember Borland PASCAL was the fastest flying exec than anything above ASM.

Long Live to C++ :-)

Posted by: Serge Lussier  11 Jun 2011

premature conclusions!

Speed was normalized to a handcrafted C++ version, unattainable in mortal programming situations.

So dare we compare the real-world unoptimized C++ to any of the others?

Conclusion: C++ is buried by all of them!

This test highlights Scala: the best code yields the best performance!

The test is OK, but the conclusions are totally wrong.

Posted by: Yan Neyer  11 Jun 2011

lame test environment

They were testing on P4...

They managed to select the most unrepresentative processor ever, made to reach high clock speeds and superb only for frying eggs.

was used to test algorithm.

Posted by: Yan Neyer  11 Jun 2011

Duh...

As if this wasn't obvious without running any tests...

Posted by: Sam  12 Jun 2011

To Yan

The other versions were also handcrafted. They tried very hard to optimize the Java version, apparently as much as any other.
My feeling is that in C++ you have to know much to do much in terms of optimization, and in Java you don't have to know much because there isn't much to do!

Posted by: DrGibbs  13 Jun 2011

It is obvious...

Has anyone stopped to think that most other programming languages ARE implemented in C++

Posted by: Michael  14 Jun 2011

Eh?

How about 'C' &| Assembler.

Posted by: tswain  15 Jun 2011

C isn't faster than C++

That is a myth. In fact, C++ as a language is equally fast, but sometimes faster. Why is it faster? Because C++ has the means to inline code a lot better than C.

Posted by: Jörgen Sigvardsson  15 Jun 2011

C++ is NOT faster than C

Untrue - it all depends on the compiler, not C or C++. Turn off all optimization in the compiler, don't use any external libraries, and try a C vs. C++ program - you'll see there is almost no difference at all in terms of speed or memory utilization.

Posted by: Ed  15 Jun 2011

Every situation needs its programming language

You can't just say language X is faster than language Y.
In C it's easy to optimize if you know the underlying platform. So is C++. But it's also very easy to produce bugs for "the average programmer" (what is this anyway?). So, if you have a large bunch of C++ developers, you wouldn't choose Java for your project. If you need to finish a large project very quickly, you wouldn't choose C. If you want largest possible public participation, you (still) choose C or C++. C is closest to ASM and thus can be (theoretically) optimized best but it's a pain in cross-platform world then. There are lots of cases where this is just impractical. It's all about the platform, the programmer and the problem you need to solve with your program.

Posted by: rigid  15 Jun 2011

Tests like this are silly

Different operating environments, compilers, VMs, etc will make a significant difference, but the real truth is that different tools are good for different jobs.

I can easily show you applications written in Java for instance which you simply will not touch in C++. At least not without spending several orders of magnitude more time and money.

Their test is actually ideal for C++, being a small and fairly straightforward algo which CAN be hand optimized and which is certainly going to run faster in native code.

Posted by: Tod Harter  15 Jun 2011

7/10

Good job, google.

Posted by: Pietr X  15 Jun 2011

Aren't they forgetting

The real heavy lifting in the supercomputer world is still done in Fortran. For all its faults, you'll still find its what's in use for O(1000) core simulations, and once you are in a MPI, OpenMP, cache tuning, jitter dominated world, having a clever language is rarely better

Posted by: John  15 Jun 2011

development time, not run time

Developer time is the most significant component of software development, not run time. Of the four languages, which makes most effective use of developer time? My guess would be Java. Peter Norvig (of Google) has some material on his personal web site comparing C/C++ and Java to Lisp, and concludes that Lisp can run just as fast as the fastest C/C++ program, and also that Lisp programs can be written much faster and with fewer errors than C/C++ and Java.

Posted by: Charles Carter  15 Jun 2011

C++ is clear winner, Java is most flexible

C++ required the developer to write excellent code so optimization could be compiled in.

Java required mediocre programming skill but excellent tuning at runtime.

Your best bet would be C++ for stuff produced by specialists, and Java for stuff produced by everyone else, so your specialists could tune your Java.

Posted by: Jonathan Fisher  15 Jun 2011

Also, Java _is_ a compiled language

To everyone who still believes Java is interpreted, please call 1995, they want Java v1.2 back.

Java code is (partially) compiled at runtime. Only certain parts are run in interpreted. Believe it or not, the world has changed over the years.

Posted by: Jonathan Fisher  15 Jun 2011

"Compiled language" is a misnomer

Execution model, whether compilation, interpretation, or a combination of the two, is a property of the implementation, not the language. Depending on the implementation, you can compile Java statically to machine code, compile it to Java Bytecode, or compile it to Dalvik bytecode. You can run the bytecode in a pure interpreter, compile it statically to machine code, translate it to some other intermediate representation like CIL, or run it in an interpreter with a JIT compiler. It's simply inaccurate and misleading to refer to Java as either a "compiled language" or an "interpreted language."

Posted by: Jonathan Rogers  15 Jun 2011

Python clear winner

My programming productivity went up 10x-100x when I switched to Python for everything that is not performance-critical. I typically do AI codes but also misc. stuff like machine binary code translation. Typically performance critical stuff uses large arrays, for which numpy provides good performance and really easy programming. To output videos, pictures, or sounds etc. I typically just generate a Matlab script output which I execute in Matlab offline. These practices have worked very well for me.

Posted by: Andrew  15 Jun 2011

Bagley's Shootout

Wondering why Google didn't reuse Bagley's shootout http://ahb.me/39Cz

Posted by: 0x101  16 Jun 2011

How About D?

I'd like to see the D language compared as well. I suspect it will perform similar to C++ but have ease of implementation closer to Java.

digitalmars.com/d

Posted by: Justin  16 Jun 2011

C/C++ is the long tearm winner

If you look at the history of Programming Languages.. you can see that clearly.. some languages comes every couble of years, people learn how to develop with them then they become old to work with.. then a new languages comes and take over..
But C/C++ are there from the start to the end.. now we are using libraries are all C++ like QT, MFC,.NET,WPF,JAVA and all the others ..

Posted by: Rajab Natshah  20 Jun 2011

C++ is the best in the business( The Brand)

I know some people here are favoring other languages, but fact is fact and even that too can become bitter for some people, If you wanna win the race you got have talent, If the people want to develop a simple application without the need competition, then they can use Java or other language, but the Brainy people you wants there application to be the best then they go for C++, of course its not the common man food. But do u wanna be a common?...C++ will rule forever....

Posted by: Bala  27 Jun 2011

Bogus

Their paper is bogus. If you read the paper, you'll notice that they often refused to optimise certain versions further. For example, Java was not optimised heavily, but C++ was. And they they compared them.

Posted by: Lucian  30 Jun 2011

Can't imagine choosing C over over C++ for my own coding

"C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off." -- Bjarne Stroustrup

"IMO, good C++ code is better than good C code, but bad C++ can be much, much worse than bad C code." -- John Carmack.

I think C is a lot more elegant than C++, but I can't imagine choosing it over over C++ for my own coding. I tend to use a lot of C's libraries over C++'s (streams in particular), but the extra tools and syntactical niceties of C++ are just too nice to give up.

Posted by: Ashish  24 Aug 2011

C++ victim of conspiracy

I swear on my grandmother grave! Big software companies wishes to keep C++ for their own dev. only. C++ gives you capability to compete with with the big players. C++ lets re-write Windows, Linux, MsWord, Oracle-DB and they hate it.

Posted by: Mohamad Farhat  11 May 2012

© Incisive Media Investments Limited 2012, Published by Incisive Financial Publishing Limited, Haymarket House, 28-29 Haymarket, London SW1Y 4RX, are companies registered in England and Wales with company registration numbers 04252091 & 04252093