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?
feedback
|
|
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:
On the other hand, C++ is
And by the way, for the typical user, the performance difference between C++ and, say, C# won't be as pronounced (F# is another matter, though). | |||||||||||||||||
feedback
|
|
The main reason is traders/quants currently in business often learned C++ in their formation rather than C#, they naturally used this language when starting new projects. It will gradually evolve, I guess you could have asked "what's the reason cobol is still the most popular language in Finance" 20 years ago. Also most projects in production use C++ but I think now most new projects gradually evolve towards C#/Java. | |||||||
feedback
|
|
Garbage Collection. The amortized performance between C++ and more modern languages is similar, but when your heap gets large, a GC can still take 100ms or more! That's an eternity, and just isn't acceptable for anything with real-time requirements | |||||||||||||||
feedback
|
|
I don't know if it the most popular but it is popular for sure - I think there are several reasons for that, which not only apply to QF:
There are few languages out there that have all of these characteristics - but there will finally be a transisiton at least towards C# and Java (This is already happening). | |||||||
feedback
|
|
Whichever treasury system the banks implements it will have pieces in C/C++ and/or Java. So C++ is just easier to interface. Also, as little as the difference of performance is, it does matter if you need to plug that model in a Montecarlo simulation running hundreds of scenarios - for value at risk computation. | |||
feedback
|
|
The optimization possibilities offered by C++ templates can make code potentially very fast; faster than C, and faster than Java could ever hope to be. (A C programmer will typically use a function pointer and a compiler cannot inline that; a C++ functor can and will be inlined.) I know C# has templates that look like C++'s but I cannot personally comment on speed benefits. C# is too closely tied in with Windows. And Windows is not a good platform to build financial systems on (IMHO, but also that of the LSE and others ;-) And don't get me started on DLL Hell when you try to mix APIs from two companies... I do agree with others that the tide may be turning against C++, but C++11 may give it a new lease of life. The speed and power is still all there, but the auto keyword and the built-in lambdas (to name but two) can make the code look much cleaner (meaning easier to maintain and harder to introduce bugs). Finally, as a reason to use C++ in finance, there is Rcpp and RInside ! | |||
feedback
|
|
People use C++ because it offers a balance between performance and convenience. It is true that you can get Java to be (almost) as fast as C++, but you need to put a lot of effort into it. On the other hand, an average-quality C++ code will be much faster than average-quality Java code. I know this from personal experience. | |||||
feedback
|
|
Its because the people still "think", it must be faster and hence favor C++. Real arguments are sparse. Some of the most ideological arguments:
At the end, every system is heterogenious. The choice of a language for a specific task should not be biased by the personal experience too much, but rather reflect the abilities of the language to get the work done fast and reliable. I would not use C++ for user interfaces anymore. C# is better at that - and equally good for many tasks which were assigned to C++ uniquely in the past. | |||
|
feedback
|
|
Not all will agree that "the maintenance cost of the program [is] lower than the C++ one." For just one thing, when we use C# or similar, we have to wrestle with the C# "framework," which aims, but often fails, to deliver a "richer," "more powerful" development environment. But "richer, more powerful" is in the eye of the language designer or design committee and often translates, on the mat, to "a briar patch of needless complexities, obstructions, irregularities, dead ends, unexpected stupidities, counterintuitive rules, and lazy, dumbass assumptions." C and C++ (and, yes, assembler) present no such hurdles, which considerably eases programming and maintenance. | ||||
feedback
|
|
C is tought at courses at universities everywhere. And people invested many time and efford to get into it. Now we want to collect the fruits and not reinvest into any new platform/language. But the IT world is changing so fast as does the computer architecture. "Next Generation" developers are used to handle C# and Java even more than C++. And they are getting tired of changing platforms - if everything they need is already there. I have switched to Visual Basic 6 years ago and didn't regred so far. | |||
|
feedback
|
|
I do agree with the argument on historic reasons, speed and GC with regarding the original question. To add my 2 cents to the rest of the discussion, I believe that Scala/Akka combination will gain a strong foothold in QF. Of course Languages like Erlang did exist long before Scala/Akka, but did not get much footing due to its esoteric nature and cryptic syntax (at least for people familiar with C/C++ like languages) and not many used it. Scala syntax is also cryptic but there is a growing user base and IB and funds have started using it. Also another language to watch-out is F#. | |||
|
feedback
|
protected by chrisaycock♦ Aug 29 '11 at 19:32
This question is protected to prevent "thanks!", "me too!", or spam answers by new users. To answer it, you must have earned at least 1 reputation on this site.