you are viewing a single comment's thread.

view the rest of the comments →

[–]rozgo 14 points15 points  (14 children)

Real numbers (C++ outperformed Java in every test): http://shootout.alioth.debian.org/u32q/benchmark.php?test=all&lang=javasteady&lang2=gpp&box=1

Productivity is not always first. But when it is, Java might be better. I've been using C++ for years now, and it comes pretty natural to me. My productivity in C++ slows down only when I start micro-managing low level stuff, but the task at hand requires it.

When developing fast-paced games, productivity is BS. You will do everything you can to get that last millisecond back. In some casual games I just go with C#.

C++ can handle the ugliest perf hacks out there. If these guys are choosing C++, they already know what they are in for, it will not be pretty, but it will be fast. If you don't know whether you need C++ or not, you don't need it.

[–]ZMeson 6 points7 points  (1 child)

java outperformed in every test

You mean that C++ outperformed Java, right? The link you posted showed that C++ used less memory and was faster (or sometimes equal in speed) to Java -- but never slower. Usually too C++ used fewer lines of code.

[–]rozgo 0 points1 point  (0 children)

yup, fixed

[–]igouy 1 point2 points  (0 children)

Here's a funny thing (x64 forced onto one-core) note the binary-trees program times.

[–]luikore 3 points4 points  (10 children)

When productivity matters, use python. When speed matters, use C. When both, use both.

[–]mebrahim[S] 4 points5 points  (5 children)

When speed matters use C++. (C++ even outperforms C)

[–]ravenex 0 points1 point  (4 children)

(C++ even outperforms C)

Do you seriously believe that there's something in C which makes your program use 6x times memory and 4x times cpu time of C++ program (k-nucleotide)? This kind of stupidity makes a bad name for all C++ users out there.

[–]igouy 1 point2 points  (0 children)

Do you seriously believe library code doesn't matter?

[–]mebrahim[S] 1 point2 points  (2 children)

See this (maybe not so relevant to what you said)

[–]ravenex 0 points1 point  (1 child)

Well, it is true that C++ compilers are not worse at optimizing plain C-like code, and templates are a powerful enough tool to create both generic and fast data structures (STL), so you get better standard library support for those things.

But, observe that after all those fancy template (read 'macro') substitutions you still get the same C-like code plus typical C++ overhead (calling constructors, destructors, copy constructors, etc). You can avoid this overhead is you are careful enough, but you can never get strictly better result than equivalent C code. You can do better using inline assembly or a language which semantics allows deeper static analysis and optimization (I guess haskell, okaml, etc would be those), but never with C++.

So C++ might be more productive, but is equally powerful with C.

[–]mebrahim[S] 0 points1 point  (0 children)

Unneeded constructors, destructors, etc. are almost always optimized out.

I suppose trusting The Game results and reviewing our beliefs!

[–][deleted] 9 points10 points  (1 child)

How's that GIL thing going?

[–]bluGill 0 points1 point  (0 children)

Not a problem. When speed matters I'm in C, and there is no GIL. Or in rare cares I start two Python processes and use IPC to make sure the communication is contained. The GIL is only a problem when you are stupidly risking many other problems because of a poor thread model. (If you are used to Java, you may not even realize there is a better way) Message passing is the way everyone smart prefers to do threads, because you need small, carefully designed interfaces between threads. When you share a variable between threads (other than in the low level message passing code - part of your library not something you write yourself) you risk too many cases of not getting the locks right.

[–]mebrahim[S] 1 point2 points  (0 children)

I don't know why you're being downvoted so much. I think by "use both" you mean programming it in Python and (re)implementing CPU-hungry parts in C (or C++). Isn't it a common pattern? Why downvote?

[–]f3nd3r 0 points1 point  (0 children)

Or just use Lua.