I had to ask this question after reading the answers to What programming languages are most commonly used in quantitative finance? I understand that C++ programs can be optimized pretty well and are faster than anything else. But in this era, the performance of a program written in a language based on frameworks such as C# and Java can be pretty close to that of C++, while the maintenance cost of the program would be lower than the C++ one. But why is C++ still a very popular language in QF?
Answer
The other posters have already noted that the prevalent use of C++ appears to be due to historical reasons and unwillingness to change. Those reasons aren't the ones that people should be applying. If you want real reasons to use C++, how about the following:
- Powerful infrastructure. Take a look at Intel Parallel Studio for an example.
- Performance compared to .Net or Java (see my course on HPC). When each array element access checks the bounds and throws exceptions, you know you're leaking CPU cycles there.
- Parallelization. The C++ ecosystem has vastly superior paralellization in both 'blind' mode (OpenMP vs TPL's
Parallel
) and explicit mode (Intel TBB vs TPL) - Lots of SDKs, most notably CUDA, base their development on C/C++.
- Possibility of invoking low-level CPU instructions (e.g., work with SSE intrinsics).
On the other hand, C++ is
- Extremely noisy. What with all the headers, include directives,
friend
class declarations, and myriads of other redundant things. - Has hard-to-use libraries (STL, Boost) with very cryptic, global-level mechanisms. Think
bind_2nd
:) - Editor support is vastly inferior compared to IDEA/ReSharper. Navigation, refactoring, analysis - all are weaker or non-existent. This is going to be improved in the near future for both VS and standalone editing.
- Compiler errors are beyond cryptic. Clang attempts to fix it to some extent, but things are still cryptic, just not as abysmally bad as they were previously.
And by the way, for the typical user, the performance difference between C++ and, say, C# won't be as pronounced.
No comments:
Post a Comment