Live data from Hacker News

Why is C++ still a very popular language in quantitative finance?

quant.stackexchange.com

41–50 of 51 posts

Re: Why is C++ still a very popular language in quantitative finance?

#41

It always amuses me the way people treat C++ like it's some kind of dark, corrupting magic that no right thinking person would use.

I find the cachet that C++ has when you interview for jobs at financial corporations to be equally depressing and hilarious. When you go in to interview for a C++ position, the guy starts off by looking at you like you're some kind of brain damaged impostor who eats babies when nobody's watching and starts asking about how sizeof works on pointers to member functions or when "inline virtual" does and does not inline…

> starts asking about how sizeof works on pointers > to member functions or when "inline virtual" does > and does not inline something.

You really had such kind of interview encounters? It's just weird.

Re: Why is C++ still a very popular language in quantitative finance?

#42
C++ is popular in other sectors as well. I use it daily and love it. I can build Python modules with it (Boost Python) so Python coders can easily use my C++ code. I can build Windows DLLs too so the Windows C# guys can use the C++ code as well and they never have to write a line of C++ (nor do the Python guys). C++ is awesome for systems and embedded work. Boost is awesome too and very easy to use IMO. I've no idea why so many people keep trying to find fault with it.

I think many people are intimidated by C++ and never really dig in and learn it well. If you do, you'll be a much better programmer because of it.

Re: Why is C++ still a very popular language in quantitative finance?

#43
post #40

I'm a moderator on the Quant Finance Stack Exchange. This link has been posted to HN before: http://news.ycombinator.com/item?id=2934042 And I'll say what said then: The accepted answer on the SE comes from someone who doesn't even work in quantitative finance. In fact, most of the answers on there are totally speculative and should be taken with the proverbial grain they deserve.

A reasonable grain I'd say :) While I'm not a quant in anything other than job title (I'm a Quant/Dev really), my experience in the financial world suggests that there are two main reasons why C++ is used so often - 1) Legacy Code. When you've already got a C++ pricing platform and teams of C++ devs, you're not going to suddenly rewrite it in another language. 2) Libraries. Almost every bank/hedge fund/trading house…

Here's the question that should be featured on HN:

http://quant.stackexchange.com/q/306/35

Essentially, C++ is popular because of existing code, particularly proprietary third-party libraries. And you are correct; even HFT shops will use languages other than C++, which is why anyone who's actually worked in this industry will know that the answer to the question of popularity is not performance.

And that's why I hate that SE question so much. It was asked by someone outside the industry and is mostly answered by people outside the industry.

Re: Why is C++ still a very popular language in quantitative finance?

#44
post #30

Many Quants are not really interested in new languages. I know at least one bank that's C++ and Perl, because that's what they know.

That was a quote from a quant who works at a major bank in Atlanta. Odd thing to downvote.

They're hiring btw, can't find enough C++ programmers who want to be paid 6 figures.

Re: Why is C++ still a very popular language in quantitative finance?

#45
post #11

Earlier quoted context omitted.

Exactly, many critiques of C++ are well and truly obsolete. What are the practical advantages of Java's GC over C++'s smart pointers? Actually not much, so why carry that overhead. Plus the elephant in the corner of the room is that actually, write-once-run-anywhere in the real world turns out to be, write on Linux on x64, run on Linux on x64. In the Java world, they like to run one VM (JVM) inside another (on Xen or…

What are the practical advantages of Java's GC over C++'s smart pointers? Actually not much, so why carry that overhead. Smart pointers aren't free, memory or otherwise. The syntactic overhead of declaring smart pointers is one. Say what you want, but the verbosity of these declarations is quickly tiring, and ergonomics is relevant. typedef's help, but that leads to the next bit, which is that smart pointers are leak…

Totally agree, but I just have to pick one nit on your final point re GHC and unpacking: If you do this you forfeit all generic programming because a 'lifted' polymorphic type has to be represented by pointer to a heap object. This is where C++'s unique take on generic programming still wins big.

Re: Why is C++ still a very popular language in quantitative finance?

#46
post #24
post #20

Earlier quoted context omitted.

Aren't C++ smart pointers essentially reference counting? That's well known to be much slower than well implemented GC.

[citation needed] Depending on how many cores you use, what processor you use, and other use cases (e.g. copy-on-write, which is free with RC and super expensive with GC), one of them can be significantly faster than the other. But for a non-specific use case, it has been my experience that they are roughly equivalent. The place where GC consistently excels is the "no random pauses" - most GCs will occasionally need…

You have a strange definition of "excel".

Re: Why is C++ still a very popular language in quantitative finance?

#47
post #24
post #20

Earlier quoted context omitted.

Aren't C++ smart pointers essentially reference counting? That's well known to be much slower than well implemented GC.

[citation needed] Depending on how many cores you use, what processor you use, and other use cases (e.g. copy-on-write, which is free with RC and super expensive with GC), one of them can be significantly faster than the other. But for a non-specific use case, it has been my experience that they are roughly equivalent. The place where GC consistently excels is the "no random pauses" - most GCs will occasionally need…

Just reread, and I got the GC and RC mixed up there (thanks, chancho) too late to edit, so I'll repost a fixed version:

The place where RC consistently excels is the "no random pauses" - most GCs will occasionally need to stop the world, even when they can mostly do incremental collections. Note that this does not mean they are slower - it is just that the overhead tends to be concentrated in bursts instead of uniformly spread out as in RC.

The place where GC consistently excels is reference loops, and less dependence on implementation robustness.

Re: Why is C++ still a very popular language in quantitative finance?

#48
post #46
post #24

Earlier quoted context omitted.

[citation needed] Depending on how many cores you use, what processor you use, and other use cases (e.g. copy-on-write, which is free with RC and super expensive with GC), one of them can be significantly faster than the other. But for a non-specific use case, it has been my experience that they are roughly equivalent. The place where GC consistently excels is the "no random pauses" - most GCs will occasionally need…

You have a strange definition of "excel".

Thanks! I managed to get the two lines confused, not sure how, and it is too late to edit; just posted a correction:

The place where RC consistently excels is the "no random pauses" - most GCs will occasionally need to stop the world, even when they can mostly do incremental collections. Note that this does not mean they are slower - it is just that the overhead tends to be concentrated in bursts instead of uniformly spread out as in RC.

The place where GC consistently excels is reference loops, and less dependence on implementation robustness.

Re: Why is C++ still a very popular language in quantitative finance?

#49
post #31

It always amuses me the way people treat C++ like it's some kind of dark, corrupting magic that no right thinking person would use.

Because they have no idea about C++11? Usually those who treat it this way obviously don't know C++.

C++11 has been finalized for almost two months now! And there's almost one compiler that fully supports it! That's enough time and products for everyone to re-evaluate their experiences with C++!

Seriously, C++, even C++11 is still a mess. Compiler error messages relating to template use -- including the standard library -- are unhelpful at best, except for very recent Clang builds. Compilation time when you actually use what the language has to offer is measured on a geological time scale. The footprint of the generated code, more often than not, makes I-caches cry. You'd be amazed how much faster your computational code runs when it fits properly into an I-cache.

I moved back to plain C a few years ago after having used C++ intensively since '94 or so -- and I'm not looking back. Yes, I do write ~10% more code; it compiles instantaneously, is easier to reason about and to debug, and usually runs just as fast.

I haven't had a chance to try the newfangled C++11 features, but I'd be surprised if they'll make a difference for me.

Re: Why is C++ still a very popular language in quantitative finance?

#50
These kinds of judgements-wrapped-in questions always come off as a bit sophomoric. It's like an artist asking, "why do some painters still use oil instead of colored pencil? Pencils are erasable, and so much easier to work with. No nasty fumes!". Or an architect-in-training asking, "Why use concrete and steel to build skyscrapers? They have so many constraints, and are so ugly, and hard to work with." I appreciate an iconoclastic spirit, but not one based on ignorance.
Post reply on HN