Caml Trading – Experiences with OCaml on Wall Street [video]
infoq.com
infoq.com
Regarding other functional languages, you are mixing some oranges in your apples. I find Rust appealing, especially with the amount of thought that goes into crafting it, but when it comes down to it, it is intended to replace C++. You are trading the convenience of a garbage-collected runtime for more control over memory allocation, and this comes at a cost. I could imagine OCaml calling Rust code for performance-critical sections, though. Regarding F#, it's no doubt a nice language and works as an incubator for ideas which trickle down to C# eventually, but I for one have little interest in the .Net ecosystem. Scala I find too scattered in terms of features, it doesn't make for a very elegant language. Also, the JVM is performant, but it's a pig in terms of memory. As for Haskell, many OCaml developers have been moving to it in the last few years. On the other hand, you don't switch to language with a lazy runtime with impunity (debugging Haskell is not particularly fun). I find the average complexity of Haskell programs higher, and a combination of syntactic features, popularity of custom ASCII operators and one-letter variable names make for sometimes barely readable code. Not to mention that OCaml is more pragmatic: sometimes it is convenient to write a for loop.
It's not a dig at Rust, which I think is very well designed, but IMHO, it is in a different niche compared to the other functional languages listed above.
Rust, unlike Java, has type definitions[1]; there's no need to use the full expansion everywhere.
(I don't believe it's even necessary in Java, but creating subclasses has its own downsides.)
[1] http://doc.rust-lang.org/0.11.0/rust.html#type-definitions
Last time I checked (0.10 or so) it did not. Gc pointers were the same as Rc pointers with a proper GC to come soon.
The module system of OCaml is very powerful, and a similar module system is not present in F#, or anything else besides some variants of StandardML as far as I know. I was able to accomplish many things using Functors that I have not been able to accomplish in any other languages.
Here's a link to one of my previous comments regarding some of OCaml's compelling or unique features: https://news.ycombinator.com/item?id=7861033
At the time of writing that, there were a couple of reasons why you still might consider Haskell instead of OCaml (assuming you were willing to accept complete purity and were willing to adapt to lazy evaluation). Those two primary reasons were type classes and a multi-core runtime (where immutability would really shine). I don't know much about Haskell, but this is what I've heard from other well informed people. I'm sure there's many other great reasons to use Haskell over OCaml, but these were the main ones from what I could tell.
But since then, it looks like there's been great progress on an OCaml multi-core runtime, and also something very similar to type classes (module implicits). We'll have to see how those develop but it's definitely exciting.
Also since then, Jeffrey Scofield has accomplished a lot to get OCaml working on modern iOS systems so you can build native iOS apps with OCaml: http://psellos.com/ocaml/compile-to-iphone.html
I've been building a small project in OCaml for a while now, and my experience hasn't left me wanting any core language feature that some other language has, aside from possibly a multi-core runtime (I haven't actually needed it yet, but I will soon). Most of the things I wish were different are very superficial syntactic gripes - but OCaml supports arbitrary syntax via ppx extensions so I can just stop complaining and build the syntax I want to program in. (Haskell-inspired syntax? Swift-inspired syntax?).
The only other feature I'd like to see is a unification of the object system and record system: You could describe that as "row polymorphism" built into records (complete with pattern matching). No other major contenders support this, so it doesn't effect my language decision, yet it would be a welcomed feature.
Scala's module system is very similar to ML's.
Object ≅ Structure
Class ≅ Functor
Trait ≅ Signature
Abstract Type ≅ Abstract Type
Refinement ≅ Sharing Constraint> The only other feature I'd like to see is a unification of the object system and record system: (...)
Could you elaborate a little bit on this or maybe point an article about it?
Thanks.
OCaml actually has a very complete object system (with ugly syntax, but don't judge). It's similar to OO you're used to in Java etc, but the types are often inferred instead of requiring that you state up front that classes/objects are subtypes of other classes.
It allows you to use objects just as you would records, except:
1. You don't have to predefine the object types anywhere - with records you do. 2. With OCaml "objects", you get inferred "row polymorphism", which means that you can make a function (without any type annotations) that accepts a point, and accesses point.x, and point.y. This function will also, gladly accept a 3D point that has an extra field point.z, that the function never accesses. In OCaml, you never even needed to predefine a type for 2DPoint or 3DPoint. This is similar to, but different than the OO "subtyping" that you're used to in OO languages. 3. Records don't provide this "row polymorphism" that OCaml objects provide. 4. Records do allow pattern matching. 5. I would like to see the best of both. Pattern matching and row polymorphism into one new record abstraction.
I'm sure there are tradeoffs (likely something to do with predictable memory layout accommodating efficient instructions). Row polymorphism may make type inference times longer, or error messages less readable. I'm definitely not the right person to give an overview of this - so please do your own investigation on the tradeoffs. I'd love to hear an expert chime in.
But all in all, I'm happy with records and the performance I see. Named arguments (with optional defaults) (which OCaml has) can fulfill the role of a unified record/object system, in some cases.
Is there any information about these that I could read?
The multicore runtime: http://www.lpw25.net/ocaml2014.pdf
Recent presentation on the multicore runtime: https://www.youtube.com/watch?v=FzmQTC_X5R4
However, we're still not getting special syntax for field access, so it'll be function application (g f) instead of a dot (f.g). This isn't a major drawback, but it means that a field g has to be in scope for this to work at all.
Fundamentally, it seems exactly the same approach could be used to give Haskell polymorphic variants. They're not part of this extension, but I wouldn't be surprised to see them in the near future.
Haskell is also getting a much better (ie not crippled) module system soon, in the form of Backpack[2]. However, I'm not sure when this is actually going to be released—I don't think it's in the upcoming version.
data Foo = Foo { name :: String }
data Foo = Foo String
What row polymorphism does is give use first-class record types that give us a measure of structural typing so that records with the "same" fields can be used in the same type and "larger" records can inhabit "smaller" types if the fields subsume. So we can write down a function like: foo :: forall r. { a :: Int, b :: Int | r } -> Int
foo x = x.a + x.b
The current proposal doesn't give us this. But we can still simulate it even if it isn't in the language.(Yes, I know about Mono, but I'd rather use something officially supported).
Also, I don't see a real difference between CLR and JVM, and I won't support another VM that purposely breaks up the ecosystem.
(On the other hand, if MS continues the current trend and goes completely open source/free software (edit: and adds an ahead-of-time compiler), I'll probably change my mind.)
* You don't have the C# baggage
* You have a modern module system, which is only paralleled in Standard ML. This is very important for large developments where the need to split your code base into manageble chunks is extremely important.
* The sequential code generator is very good.
* Compilation times are fast. Not Go-fast, but reasonably fast. Building OCaml itself with OCaml can be done in around 1 minute on a fast machine.
* The language is strict! This makes some gotchas w.r.t memory behaviour much easier to reason about, and is a definining distinction towards Haskell
* The language is rather small in the core. In contrast to Scala.
* The Garbage Collector is state of the art. It is fast. It has small pause times. It doesn't overuse memory.
* The language is mature, which Rust isnt'. When Janes Street started, Rust did not even exist.
What swayed me at the time was the fact that you had to roll your own libraries for so many things that you get out of the box with .NET. I understand that's changing, but in my mind it's just not ready yet. Maybe in a year or two. I'm still thinking of moving on to something else. It's either going to be OCaml or Haskell.
Would love to see some folks doing this same kind of thing with F#, talking about real-world production systems.
I've done some small app work with it, and blogged about it ( http://tiny-giant-books.com/blog/real-world-f-programming-pa... ), but what the F# community could use is some fans like OCaml has with Jane Street.
I remember thinking, "Wouldn't it be neat to scrape some web sites?" I couldn't find anything in OCaml, but .NET had the HtmlAgilityPack written in C# for Windows. Pop over to github, pull down the source, recompile? Badda bing, badda boom, it's running in Linux. And I'm able to use it in F# without really having to know C# (Even though that's not the case). I realized that I could do that for literally thousands of different apps and utilities. So you had this entire ecosystem of programmers making open source stuff for windows that you could easily use in linux. That was the deal-closer.
Plus it looked like Mono had finished going through it's almost-ready-but-not-quite stage. I would still love to be able to permanently load .NET apps in Apache and call them a la fastCGI, but heck, even that might be a solved problem by now.
Finally there was the F# community, which was basically a bunch of old OO MS hacks like myself trying to find their way along mixed in with some really nice academic types who were helpful. OCaml, sadly, did not have that kind of feel. Instead there was a lot of French. And searching around the web for answers to how to do really simple things, like get started, write a web app, or cross-system develop.
The barrier to entry was just too high.
But, like I said, that's changing.
Maybe there are better hybrid languages, but compared to Scala I wouldn't even try calling OCaml or F# hybrids. OO/FP interop in those languages feels like the language designers were actively sabotaging it.
http://d1snlc0orfrhj.cloudfront.net/presentations/14-jun-cam...
https://www.janestreet.com/blog/what-we-do/faqs/ <-404's for me