Live data from Hacker News

Real World Ocaml announced

realworldocaml.org

1–10 of 58 posts

Re: Real World Ocaml announced

#3
I'm curious. How many folks here have used OCaml for production work? I'd just like to get an idea of the numbers.

Edit: By 'production work' I meant built things that are being used by other people.

Re: Real World Ocaml announced

#4
post #2

Oh.. I thought that this was going to be an actual version of Ocaml that was practical in the real world, rather than a book.

So what's impractical about Ocaml? I just looked at it and it looks cool, but I haven't tried it for anything.

If they actually have event driven programming that seems like a big step over most functional languages, where I/O is kind of an afterthought.

Steve Yegge wrote some points about Ocaml quite awhile ago. http://sites.google.com/site/steveyegge2/ocaml He says it is quite fast and I've seen that in other places.

The thing I don't like about competing with C/C++ in "fast" is that those languages invariably are memory hogs. They hide that in the benchmarks.

Anyone know if you have control over memory layout in Ocaml? Or if you can reason about it like you can in C/C++?

Re: Real World Ocaml announced

#5
post #4
post #2

Oh.. I thought that this was going to be an actual version of Ocaml that was practical in the real world, rather than a book.

So what's impractical about Ocaml? I just looked at it and it looks cool, but I haven't tried it for anything. If they actually have event driven programming that seems like a big step over most functional languages, where I/O is kind of an afterthought. Steve Yegge wrote some points about Ocaml quite awhile ago. http://sites.google.com/site/steveyegge2/ocaml He says it is quite fast and I've seen that in other place…

OCaml isn't actually a pure functional language: it has side-effects and mutation. In fact, you can code that looks an awful lot like C if you want, except with automatic type inference. But then you can also lift up your level of abstraction in the same codebase to use a purely functional idiom where it's appropriate, or use an object-oriented style for something else. All of those styles are supported as consistent, first-class features in the language.

There are several event-driven programming libraries in OCaml, and two that I like that use monadic abstractions (to hide the messy control flow that makes node.js so painful) are Async (https://ocaml.janestreet.com/?q=node%2F100) and Lwt (http://ocsigen.org).

You have good low-level memory layout in OCaml, either via an FFI or the Ancient module to import in non-GCed values. You can read about the OCaml heap and GC at this blog series by Richard Jones. http://rwmj.wordpress.com/2009/08/04/ocaml-internals/ (and yes, the memory representation is a straightforward mapping from the type declaration; very little magic happens in the compiler)

OCaml is used all over the Xen Cloud Platform (http://github.com/xen-org/xen-api), and I'm running an ongoing microkernel research project called Mirage (http://www.openmirage.org) which has a full network stack written in pure OCaml (and is also competitive performance-wise).

Re: Real World Ocaml announced

#6
post #4
post #2

Oh.. I thought that this was going to be an actual version of Ocaml that was practical in the real world, rather than a book.

So what's impractical about Ocaml? I just looked at it and it looks cool, but I haven't tried it for anything. If they actually have event driven programming that seems like a big step over most functional languages, where I/O is kind of an afterthought. Steve Yegge wrote some points about Ocaml quite awhile ago. http://sites.google.com/site/steveyegge2/ocaml He says it is quite fast and I've seen that in other place…

> So what's impractical about Ocaml?

The biggest issue Ocaml has is that its GC is single-threaded which basically removes the ability to do parallel programming inside a single executable. You have to resort to message passing between multiple processes.

For what it's worth, I think I heard rumors there's work on an improved GC.

Re: Real World Ocaml announced

#7
post #3

I'm curious. How many folks here have used OCaml for production work? I'd just like to get an idea of the numbers. Edit: By 'production work' I meant built things that are being used by other people.

You might find this interesting: https://ocaml.janestreet.com/?q=node/61

TL;DR: Jane Street is a quantitative trading firm whose language of choice is OCaml and has several people programming in it full-time. Besides experiencing the commonly-cited advantages of FP (productivity, expressiveness, local reasoning), they also found it highly performant, useful for rapid prototyping and resilient to changing requirements.

Re: Real World Ocaml announced

#8
post #6
post #4

Earlier quoted context omitted.

So what's impractical about Ocaml? I just looked at it and it looks cool, but I haven't tried it for anything. If they actually have event driven programming that seems like a big step over most functional languages, where I/O is kind of an afterthought. Steve Yegge wrote some points about Ocaml quite awhile ago. http://sites.google.com/site/steveyegge2/ocaml He says it is quite fast and I've seen that in other place…

> So what's impractical about Ocaml? The biggest issue Ocaml has is that its GC is single-threaded which basically removes the ability to do parallel programming inside a single executable. You have to resort to message passing between multiple processes. For what it's worth, I think I heard rumors there's work on an improved GC.

JoCaml, my friend.

Re: Real World Ocaml announced

#10
Discussions of whether OCaml is "practical" or useful or good aside, this book really, really needed to be written.

It may be the case that there are truly excellent resources for learning OCaml, but I know the language, and I've never heard of them. There's Jason Hickey's tutorial, an introduction or two scattered around the internet, and some book that was fan-translated from French, sure, but OCaml lacks the hackerly dialogue that typifies discussion of languages like Haskell. It is a problem, for example, that these usually very incomplete hobbyist-curated tutorials almost always outstrip the professional literature: when people do publish books about OCaml, they are often littered with errors or flat-out wrong (I'm looking at you, Practical OCaml).

Regardless of whether we can all get on board with asynchronous whatever, or pronouncements about its "real" speed, or whether it should be used when Haskell is around, it is clear that there is a huge divide between the people who actually can argue these things well, and those who cannot, and switching from the first group to the second by yourself is tempestuous and trying. Is it the case that there are no OCaml experts in the world? If you are going by the amount of information on the Internet, it is not really obvious that this is actually the case. How can you, then, become one?

Besides that, though, having a sound OCaml counterpoint will do communities like Haskell good. I hope this finally ushers in the golden era of learning OCaml. Not everyone can take CS51 at Harvard, and besides, the credulity of a real (and good?) book about OCaml will hopefully advance the dialogue further than the typical questions of whether it can actually be done in X, Y and Z enterprise environments. That is a debate I (and probably many OCaml fans) have heard enough of.

Post reply on HN