views:

460

answers:

8

speaking to a number of quants / hedgies, i came to the conclusion that a large number of them seem to be using their a homebrew or caml (for the most part). what many of them couldnt answer was why.

i can certainly understand why they wouldnt want to use c++ for the most part, but why is caml superior for these uses compared to other scripting languages, say python, Ruby etc?

+1  A: 

Because it's blazingly fast (and far more succinct than C++).

Brian
+6  A: 

See for example the programming languages shootout for speed comparisons:

Now, we all heard the line about lies, damned lies and benchmarks so grains of salt recommended -- but this a fairly well done comparison. At the end of the day it matters what one gets done with one's own problem and data.

Dirk Eddelbuettel
+1 for this! That's the speed they crave with the function as first class objects and multiple tail recursions they enjoy.
wheaties
Programming language geek tested, manager approved? B-)
Brian Postow
+1  A: 

Trivial parallelization compared to Python/Ruby? At least this is true for F#, but should be true for Caml/OCaml for much the same reasons.

As much as I love Ruby, it wouldn't be my first choice for heavy-duty tasks that are mostly mathematical or aggregations, and neither Python nor Ruby have really great support for multithreading yet.

The terseness of relatively complex pipelines of calculations thanks to pattern matching and the preference for immutability (harder to enforce in Ruby, slightly easier in Python but still harder than in ML-based languages) are most valuable for calculations on large data sets.

JasonTrue
Parallelization is actually a little bit awkward in OCaml — the whole language has a global lock, so only one thread can be executing OCaml code at a time. You have to split off additional processes to use multiple cores or CPUs.
Chuck
Wow, that's a bummer. I guess that means it's on roughly the same footing as Python, except for all the nice pattern matching stuff and more pervasive immutability.
JasonTrue
+4  A: 

Being a functional language, it is mathematical in nature, which probably fits in nicely with the kinds of problems these firms need to solve. And as others have pointed out, it has a nice performance profile.

Maybe this is why Microsoft co-opted OCaml for F#

Robert Harvey
+1  A: 

I don't work at a place like that, so these are just guesses as to why I might do it in their position:

It's generally quite a bit faster than languages like Ruby and Python and, as a statically typed functional language, it's generally somewhat easier to reason about the code and know that it doesn't contain subtle bugs. (Yes, unit tests should help catch those as well, but extra assurance that your financial numbers aren't getting screwed up is nice to have.) Also, functional programming is very closely tied to math, more so than most high-level language paradigms (like, there isn't an OO branch of math), so it's good at modeling what they actually do there.

Chuck
Couldn't you say category theory is the OO branch of math? There are plenty of functional ways of modeling category theory, though.
JasonTrue
If category theory is the OO branch of math, that would make Haskell an OO language. I don't see how OO languages strive to be computer approximations of category theory any more than any other language with a type system.
Chuck
I suppose so, but a fair amount of the theory of object systems comes from category theory. Granted, the ideas are far less abstract once turned into an OO language and they don't look very much alike.
JasonTrue
A: 

In my experience of Quants it's VBA (read: Excel) with c#, or f# sometimes too

Edit:

I'll rephrase that, for the down vote, I don't know personally of any Quants using caml...

gbn
yeah, i think in the vast majority of cases that is true, but there also seems to be a pretty substantial number (growing?) of cases where other languages / setups are being used for more involved processing...
oneAday
+7  A: 

Try reading Caml trading - experiences with functional programming on Wall Street by Yaron Minsky and Stephen Weeks. They go into great detail about what they feel are the advantages and disadvantages of OCaml, though they for the most part take it as a given that it is better than most other options they considered (i.e. not a lot of direct comparisons with C++, Python, what have you).

The authors work at Jane Street Capital which has invested heavily in OCaml code.

Update: See also the thread What programming language(s) is algorithmic trading software written in?. One of the comments mentions a presentation Yaron Minsky gave at CMU on Jane Street Capital's use of Caml. About an hour long, and very interesting.

Don Wakefield
thanks Don, very interesting stuff!
oneAday
+1  A: 

Picking up on Don's post, Jane Street Captial even has a page dedicated to OCaml, with further links to their OCaml engagement (including a blog). Performance of OCaml is usually a big argument, but I think also the "quants" love it because the functional paradigm lends itself very well to their kind of analytical work, so I think they are the early adopters. And then firms discover that it is equally suited for systems programming.

ThomasH