Re:Google paper comparing performance of C++, Java, Scala, a...
by MrScruff on Friday June 03, 2011 @04:59AM
(#2615626)
Could you give an example of where this would be the case? I write both Python and C++ code all day and I can't think of a single situation where I'd expect better performance from Python than a similar C++ implementation.
[ Parent
| on HN ]
Re:Google paper comparing performance of C++, Java, Scala, a...
by saucetenuto on Friday June 03, 2011 @11:56AM
(#2616829)
Here's one that bites every c++ newbie at least once (please forgive minor syntactic mistakes, it's been a while):
std::vector<LargeStruct> things = GetABunchOfThings(); // Why does this take so long?
// Oh well, time to sort
std::sort(things.begin(), things.end(), LargeStructComparator());
...and then your program takes forever and your profiler tells you that 99.9% of your time is spent in LargeStruct's copy constructor. And then you refactor to use pointers and teach the comparator to dereference them, whatever, it's fine, but the naive Python version will just work.Of course, after c++0x becomes widespread this problem will go away. Yay move constructors.
Re:Google paper comparing performance of C++, Java, Scala, a...
by jongraehl on Saturday June 04, 2011 @05:44PM
(#2620542)
Basically correct, except std::sort uses assignment, not copy construction.
It's also likely that the optimizer will have GetABunchOfThings construct its result once in the caller's "things". Lambdas are C++0x, so maybe move constructors (another C++0x feature) will be employed instead.
Re:Google paper comparing performance of C++, Java, Scala, a...
by ajross on Friday June 03, 2011 @11:53AM
(#2616808)
Python might be a bad example, as the interpreter really isn't terribly fast. But with Javascript, I wouldn't be surprised at all if the same naive implementation of a typical web-ish task (lots of strings, parsing, lots of heap churn) ran faster on V8 than it did compiled from C/C++.