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

C++ can actually be faster because it doesn't throw away as much type information. A good, typed C++ quicksort implementation, for example, will be faster than a C version using void*.


One of the reasons for the performance difference is that you can't inline into the libc DLL blob: If you use qsort(), you'll get a lot of overhead from calling the comparison function.

If you use a custom quicksort implementation and put it into the same translation unit as the comparison function (or compile statically and use link-time optimizations with a sufficiently advanced compiler) you can get the same performance out of C.


Function call overhead is only one of the issues with the C version based on void pointers.

Check out Stroustrup's keynote at Going Native 2012 for more details: http://channel9.msdn.com/Events/GoingNative/GoingNative-2012...




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

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

Search: