News for hackers. Stuff that matters.
Re:Plans for OCaml 4.08 by losvedir on Wednesday July 04, 2018 @05:35PM (#17459558)
How's the performance of OCaml, and what's its concurrency story?

I feel like on paper, at least, OCaml ticks all the boxes on my programming language wishlist: non-nullability, ADTs, type inference, compiles to binary. A lot like rust but a little higher level. But I've never really had a go at it. I'm sort of reluctant to sink time in it if there's not a future, but it seems to be kind of chugging along, not really gaining or losing ground, AFAICT.

Re:Plans for OCaml 4.08 by klibertp on Wednesday July 04, 2018 @07:21PM (#17459950)
The concurrency story is similar to what you get in Python. On one hand, you have event loop implementations with various conveniences for scheduling callbacks (Async, LWT); on the other, you have OS-level threads, but the runtime system has a global lock which makes only one thread execute at a given time. So no parallelism without forking[1] to separate processes. Moreover, the interactions between an event loop and OS-level threads which sometimes arise are non-trivial and in my experience very hard to get right, even with the helpers in Async.

Single-threaded performance is generally good when natively compiled. In a benchmark I did a few years back, which consisted of traversing the filesystem with `opendir`, `readdir` and friends, OCaml was minimally slower than C++ and Nim (when compiled natively) and around Python and Racket when byte-compiled. It probably would be even faster if I used its imperative features. Looking at the code today I also see some unnecessary copying of lists, which could be mitigated. All in all, I think OCaml has a really good performance considering its high-level semantics. You have to be aware of relative costs of operations, but if you do, "as fast as C" is certainly attainable. OCaml code for the benchmark: https://klibert.pl/posts/walkfiles-ocaml.html and the results: https://klibert.pl/statics/images/walkfiled_perf_test1.png

[1] Actually, I just checked and it looks that `fork` is not implemented, so copy-on-write memory sharing is impossible, even on POSIX systems. Docs: http://caml.inria.fr/pub/docs/manual-ocaml/libunix.html http://caml.inria.fr/pub/docs/manual-ocaml/libref/Unix.html

Re:Plans for OCaml 4.08 by gmfawcett on Wednesday July 04, 2018 @09:51PM (#17460423)
Re-read the page that you linked. Fork isn't implemented on Windows, where fork doesn't exist anyways. Forking works just fine in Ocaml (on Unixes).

Unix module docs (with fork!): http://caml.inria.fr/pub/docs/manual-ocaml/libref/Unix.html

Re:Plans for OCaml 4.08 by HumanDrivenDev on Wednesday July 04, 2018 @05:53PM (#17459623)
As a language, it's great. As a real world environment/eco-system to get stuff soon? I've been waiting for it to get there for years, and it still hasn't. I check in every 12 months or so, am reminded how nice the language is, and quickly abandon ship when I realise how annoying it is to actually develop software.
Re:Plans for OCaml 4.08 by chrisseaton on Wednesday July 04, 2018 @06:38PM (#17459803)
> what's its concurrency story

I think concurrency is fine (threads and async are options) but parallelism still seems to always be just around the corner and never actually here. I understand part of the problem is making their GC able to handle parallel allocations without hurting basic allocation performance more than they're willing to do.