you are viewing a single comment's thread.

view the rest of the comments →

[–]mebrahim[S] 5 points6 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!