Live data from Hacker News

OCaml 4.03: Everything else

blogs.janestreet.com

11–20 of 84 posts

Re: OCaml 4.03: Everything else

#11

Still no support for threads running in parallel? I guess things didn't go well: https://news.ycombinator.com/item?id=9582980

There's still hope! There are a number of much anticipated features that haven't made it into this release. In particular, the multicore GC, which at one point had been expected to land in 4.03, has been pushed back, likely to 4.04.

and when exactly 4.04 will pop up ?

~~ Well, I know, it's hard. ..

Re: OCaml 4.03: Everything else

#13
post #8

If I were already sold on using Haskell or OCaml for a new project, what would be the big seller for OCaml being the choice? I haven't dug into SML or OCaml and I'm not expert with Haskell yet but from looking at them they don't look substantially distant from Haskell.

I've only written Haskell, but I'll try to give a fair shakedown from my perspective: + OCaml is eagerly evaluated while Haskell is lazily evaluated. This makes it easier to reason about things like memory use in OCaml. + IO is reflected in the type signature of Haskell functions. You may find this annoying because it stinks to have to change a lot of type signatures just because, e.g., you want one of your utility f…

> IO is reflected in the type signature of Haskell functions.

What you mean is, "effects are reflected". Haskell has a monadic effect system (IO is very rough-grained part of it), which can be combined via monadic transformers.

Situations where you don't want to use OCaml:

- you need good parallelism and using multiple processes are not enough (concurrency is fine, though)

- you want a large pool of developers (also applies to Haskell, but less so)

- you like monadic effect systems

- you need a number of libraries which are not present in the OCaml ecosystem

- you want a build system that doesn't suck

- you want a good standard library

- you want typeclasses

Why you'd want to use OCaml over Haskell:

- fast compilation (especially if you compile to bytecode)

- no monadic effect system

- no awful, ridiculous record field name collisions (OCaml lets you have two distinct types with an "id" field, imagine that)

- best-in-class package manager

- faster than Haskell (I think?)

- eagerly evaluated (Haskell's informal motto is "if it compiles it works", complemented by "until you get a memory leak") and therefore makes it much easier to reason about performance

- high-quality ecosystem (though not always very well documented)

- labeled arguments (many Haskell libraries have these functions with lots of arguments which are quite confusing in the absence of labeled arguments)

- great support for Vim/Emacs (IMHO, the Haskell equivalent to Merlin/ocp-indent are not nearly as good, or at least were not as a few years ago)

- great REPL via utop (just don't use the standard one, it's terrible)

- an object system if you really need one

- functors

- pleasant "printf debugging" option, with a possibility of using a real debugger if you need

Re: OCaml 4.03: Everything else

#15

Still no support for threads running in parallel? I guess things didn't go well: https://news.ycombinator.com/item?id=9582980

I really wanted to use OCaml, but it is adding features way later than I can continue to wait. I've started learning Ponylang as my CSP language over Elixir ever since I checked it out several months ago. Maybe OCaml will fit the bill one day. Jane Street's inertia seems to keep it going outside of the academic world, but that's a single linchpin in the commercial world outside of its academic pen.

Re: OCaml 4.03: Everything else

#16
post #8

If I were already sold on using Haskell or OCaml for a new project, what would be the big seller for OCaml being the choice? I haven't dug into SML or OCaml and I'm not expert with Haskell yet but from looking at them they don't look substantially distant from Haskell.

I've only written Haskell, but I'll try to give a fair shakedown from my perspective: + OCaml is eagerly evaluated while Haskell is lazily evaluated. This makes it easier to reason about things like memory use in OCaml. + IO is reflected in the type signature of Haskell functions. You may find this annoying because it stinks to have to change a lot of type signatures just because, e.g., you want one of your utility f…

>I've heard the quality of OCaml libraries tends to be very high. I feel the same way regarding Haskell libraries, but I do definitely think that there's more work put into documentation of OCaml libraries than their tends to be on Haskell's, which arguably makes as big a difference as the actual quality of the library.

Re: OCaml 4.03: Everything else

#17
post #8

Earlier quoted context omitted.

I've only written Haskell, but I'll try to give a fair shakedown from my perspective: + OCaml is eagerly evaluated while Haskell is lazily evaluated. This makes it easier to reason about things like memory use in OCaml. + IO is reflected in the type signature of Haskell functions. You may find this annoying because it stinks to have to change a lot of type signatures just because, e.g., you want one of your utility f…

> IO is reflected in the type signature of Haskell functions. What you mean is, "effects are reflected". Haskell has a monadic effect system (IO is very rough-grained part of it), which can be combined via monadic transformers. Situations where you don't want to use OCaml: - you need good parallelism and using multiple processes are not enough (concurrency is fine, though) - you want a large pool of developers (also…

"- you want a build system that doesn't suck"

This is a very surprising claim. Do you have any examples how Ocaml specifically induces systems built on it to suck?

Re: OCaml 4.03: Everything else

#18
post #8

Earlier quoted context omitted.

I've only written Haskell, but I'll try to give a fair shakedown from my perspective: + OCaml is eagerly evaluated while Haskell is lazily evaluated. This makes it easier to reason about things like memory use in OCaml. + IO is reflected in the type signature of Haskell functions. You may find this annoying because it stinks to have to change a lot of type signatures just because, e.g., you want one of your utility f…

> IO is reflected in the type signature of Haskell functions. What you mean is, "effects are reflected". Haskell has a monadic effect system (IO is very rough-grained part of it), which can be combined via monadic transformers. Situations where you don't want to use OCaml: - you need good parallelism and using multiple processes are not enough (concurrency is fine, though) - you want a large pool of developers (also…

What if I want some hybrid? From OCaml, I want the awesome module system and strictness by default. (I'm not dismissing laziness or any other evaluation strategy - just saying strictness is a better default.) From Haskell, I want effects tracked in types, higher-kinded types and painless parallelism.

Re: OCaml 4.03: Everything else

#19

If I were already sold on using Haskell or OCaml for a new project, what would be the big seller for OCaml being the choice? I haven't dug into SML or OCaml and I'm not expert with Haskell yet but from looking at them they don't look substantially distant from Haskell.

OCaml is a bit more traditional. Strict evaluation and mutability may be more friendly to programmers with an imperative background.

My general experience with OCaml hasn't been great. To be blunt, it seems sort of like a less-well-thought-out version of Haskell.

The biggest downsides that I remember were:

* IO sequencing via (;) : () -> () -> (). This is sort of a relic from before we had monads, and is relatively pretty clumsy.

* No type classes. "Generic" operators like (), etc. There are separate functions for ints and floats. Again, clumsy.

Questionable unboxing techniques. On a 64 bit processor, ints are 63 bits because ocaml has to use a bit to tag them as non-pointers. On the other hand, Haskell differentiates boxed/unboxed values statically at the kind level, so there are no weird pointer tagging tricks or related overhead.

I have limited experience with OCaml, so take this with a grain of salt. I also think OCaml has valid use cases. In Jane street's case, I can see OCaml being a better choice than Haskell for the reasons I mentioned. The people there definitely know the advantages and disadvantages of both. One of the hardest interview questions of my life was a very interesting Haskell question from Jane Street!

Re: OCaml 4.03: Everything else

#20

If I were already sold on using Haskell or OCaml for a new project, what would be the big seller for OCaml being the choice? I haven't dug into SML or OCaml and I'm not expert with Haskell yet but from looking at them they don't look substantially distant from Haskell.

Can't speak for OCaml yet; I've wanted to learn for a while but decided to go with Haskell first. On the Haskell side of things--it's biggest seller (functional purity) is also the biggest downside. To give you an idea, papers have been written about the best way to implement common data structures purely functionally. From what I've seen, OCaml has less "abstraction overhead" because it can dip into imperative code.…

The real downside isn't purity - purity is a good thing! What Haskell suffers from is a lack of flexibility w.r.t. the evaluation strategy of pure functions. More precisely:

(0) Haskell starts with a bad default - laziness.

(1) Haskell uses special annotations to introduce strictness. The presence of these annotations isn't tracked by the type system, which reduces the usefulness of the type system as a tool for understanding your program.

(2) More sophisticated evaluation strategies (e.g., memoizing functions, which can be seen as a generalization of laziness) are difficult to achieve in Haskell, even though it's completely straightforward in ML.

Post reply on HN