Caml Trading talk at CMU

I was at CMU several weeks ago, and gave a version of my "Caml Trading" talk there. See below if you are interested in seeing the video. It's a reasonably good source if you're interested in understanding more about how and why Jane Street uses OCaml.

Comments

Quoting for OCamlCore.com

Is it possible to use your different arguments (against OO and F#) on my own website ?

Thanks in advance Sylvain Le Gall

(website: www.ocamlcore.com)

Quoting

Do you mean you'd like to quote something I said? I don't have any objection to that...

Excellent talk

Hi,

Thanks for putting this talk here.

It is very interesting and I know I'll now have an excellent link to give to people with a bad opinion of OCaml !

Quoting

No direct quote, but use your idea about :

  • The three main ideas in Object Oriented programming:
    • interface: good idea,
    • polymorphism: good idea but OCaml parametric polymorphism is a better implementation
    • inheritance: wrong idea because you need to read the code inherited...
  • F# is good but its GC is not made with FP in mind, so it can't handle the allocation rate of FP and calling .NET method just raise the scary "NULL" pointer exception again
  • Paying a lot of people to read a code full of "boilerplate" is not a good idea. OCaml allow to have a very small codebase which is more easy to read than more mainstream language
  • OCaml is good for:
    • Brevity
    • Pattern matching
    • Refactoring (with pattern matching in mind)

(I am not a native english speaker and just listen to your talk 1 time, so maybe I have misunderstood some points)

So this is not about quoting like "OO is ... " as Y. Minsky from Jane Street Capital said. I just want to take your ideas, write some web pages and thank you in another web pages for giving me ideas about these points.

Do you still agree ?

Quoting

No objection. These ideas weren't really invented by me in any case, merely collected. A couple of corrections, though.

First, I think this is what you were trying to say, but to be clear, my point about subtyping is that it is the wrong default form of polymorphism, and that the right default (not implementation) is parametric polymorphism.

Second, while you've correctly pointed out some of my worries about F#, the language also has a great deal to recommend it. I don't think we'll be switching over all of our code anytime soon, but I do think it's a lovely language, and may be the way in which the Hindley-Milner type system hits the big time...

Very nice talk

Thanks for publishing it here. I got a real enjoyment from hearing many of my own thoughts in your speech :-)

Great seeing OCaml being used in such a large company

I am used to seeing OCaml in research facilities, but it was great to hear why Jane Street has chosen to go with OCaml. I used to program in VB when I worked for banks/telcos as a programmer and so have stuck with .Net for my flights site, but it would be great to rewrite it in OCaml & get all that static-typing goodness.

Monitoring software

You mentioned that it's very important for your code to be correct so it doesn't cause you to lose money fast. Why don't you create software that monitors the effectiveness of your trading algorithms and shuts things down if you seem to be losing a lot of money?

tiger, Isn't that basically

tiger, Isn't that basically equivalent to solving the halting problem? If your code on how to trade things is incorrect, isn't the code to monitor how you are trading things going to be incorrect as well?

Further Reading?

Is there any suggested reading for some of the points Yaron made about OCaml's strengths? Specifically, he mentioned that in Java it is hard to know what type you are working with given inheritance. But it seems like OCaml would have the same problem if you consider polymorphic variants and OCaml's object system. Does Jane St not use these two tools?

OCaml vs Haskell

Firstly I greatly admire your conviction for basing your business on a functional language and I can fully understand your reasons for choosing OCaml over traditional imperative languages.

As a Scheme programmer myself working on AI solutions for trading I have been looking at more performant alternatives to Scheme and have gravitated towards Haskell rather than OCaml because of its support parallel processing and marginally better performance than OCaml on the Language Shootout.

Did you evaluate OCaml against Haskell and what were your reasons for going with OCaml ?

Regards

Andrew

Credit where it's due

As a long time admirer of ocaml, stuck in a job with limited (but thankfully expanding) opportunities to code solutions in my favoured language, I want to thank you for publishing this video for the following two reasons.

  1. Being the only functional programmer in my workplace, it is hard to win over traditional OOPists ( even after providing ocaml solutions such as parsers and on-the-fly code generators ) as to the long-term benefits of using ocaml.

  2. The sheer joy of listening to someone describe a subject with an engaging combination of wit, intelligence, energy and clarity.

Very well done.

Poor example for ADTs

Hi,

I think that the example for ADTs is rather poor, since this kind of thing can be done just as well in OOP languages. For example, in Java you'd write something along the lines of

interface Instruction {
    int getId();
}
class Order implements Instruction {
    int id;
    public int getId() {
        return id;
    }
}
class Cancel implements Instruction {
    int xid;
    public int getId() {
        return xid;
    }
}
class Stuff {
    static List<Instruction> filter_by_oid(List<Instruction> l, int oid) {
        List<Instruction> new_list = new LinkedList<Instruction>();
        for (Instruction i: l)
            if (i.getId() == oid)
                new_list.add(i);
        return l;
    }
}

This is certainly uglier than the OCaml version, but it's not because Java doesn't have ADTs. It's ugly essentially because all the other FP stuff like higher order functions, closures etc. is missing. Note that I'm not disputing the superiority of functional languages, I just think that you chose a bad example to prove your point that ADTs help writing less buggy code.

examples

It's hard to convey what's going on in such a short example, but there really is something wrong with the Java version above. The issue is that you have to make a choice in getId as to what ID to return. For the cancel, should you include the identifier for the cancel message, or the identifier for the order to which the cancel is referring? There are really two valid choices, and you may need to make the choice differently in different contexts. By using a variant, you get to make the decision differently in each context. By doing this with object-style subtyping, you have to make the decision in the "Stuff" interface. For a library which is used in many different contexts, this means that you end up having to stuff all sorts of usage-specific details into the library, which is unnatural.

For a tiny example like this, it's not a big deal either way. But as you scale up to real examples, it becomes clearer what you get from using algebraic data types.

For what it's worth, this is connected to the so-called "expression problem" which Phil Wadler has written on.

User-Interfaces

What are your feelings about using web-based user-interfaces that are written in OCaml in lieu of a desktop application?

Web-based UIs

We feel pretty good about that, and that's how we solve some of our UI problems. Honestly, though, it's an area that we're not great at. Our web UIs tend to look pretty ugly. That said, it's a great way to deploy an app with a minimum of configuration nonsense.

High Throughput Computing?

Are you using OCaml with something like Condor on your clusters or did you roll your own?

a worthwhile hour

I have been tracking Jane Street ever since late 2006 - pondering an ad here in Seattle's craigslist. I liked the stripped down, almost spartan function call it created to attract great coders. Now, several years later, I see what that was all about.

I am interested to see how OCaml synergizes with the way I think. I like the balance points stated, and I really appreciated the perspective shared here.

Syndicate content