Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Are we talking about native C++ or C++ with all the .Net stuff? ;)

Two years ago I have heard about many benchmarks, people saying that higher level languages can be nearly as fast. (Or even faster!) In fact I even believed this because it was said so often and Ruby for instance went fast.

However reality proofed me wrong. When the CPU is going to 100%, C/C++ are always faster. (In case of Ruby it can be orders of magnitude...) However when doing mostly I/O-intense web apps, it pays to have a language that makes performant design easy.



Ruby seems like a bad basis of comparison, as it appears to be designed without concern for runtime speed at all and the main implementation uses a slow, simple design. High-level languages in general can be very fast, but it doesn't mean any particular one is.

C# and Java can produce very efficient programs, and for a lot of CPU-bound problems the obvious solution in either of those will be faster, particularly stuff that needs to perform lots of little allocations or where the obvious C++ program does too much accidental copying.


Once I worked on a C++ program and when we really had to optimize, I did some profiling with valgrind. It turned out more than 50% of the CPU time was spend with memory allocations...

However with C++ it's easy to work around that by using pointers or (const) references. Or even one step further one can use a memory pooler or GC.


Some real world applications (not microbenchmarks) show it is possible to get on par with C/C++ performance when using Java.

- Netty vs Nginx - Tomcat vs Apache - Jake2 vs Quake2 - H2 vs PostgreSQL (there is no clear performance winner here)

However, to achieve good performance in high-level languages, I'm afraid you still need a pretty deep low-level knowledge, so learning C can be very beneficial.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: