Let's reignite this age old debate; well maybe not all that age old but definitely something worth discussing. It is a widely regarded notion that C is faster than C++ though I havne't found any concrete reasons or literature to support this claim.
This is what I have inferred from what I have read -
Use of virtual functions and run-time polymorphism slows down the code a little. So if this feature of C++ is not used, C++ code would run as fast as C code.
Having said this, the difference between run times is due to the compilers and not the languages themselves. Last I heard, C++ compilers don't optimize C++ code as well as C compilers optimize C code.
The code that goes into CFD applications handles millions of points, so even a little function overhead (eg virtual function) is significant.
Bottomline - if virtual functions, run-time polymorphism isn't used, C++ code would run as fast as C code.
Thoughts, comments, links?
No comments:
Post a Comment