News for hackers. Stuff that matters.
Re:OCaml 5.0.0 release (including multicore and effects) by maattdd on Friday December 16, 2022 @08:03AM (#34014077)
Amazing work from the team! I wonder if this is actually the first mainstream language which has managed to remove its "global lock" without breaking changes ?
Re:OCaml 5.0.0 release (including multicore and effects) by sadiq on Friday December 16, 2022 @08:37AM (#34014347)
Just to add to the sibling comment. To maintain backwards compatibility, OCaml 5 has both threads and domains.

Threads belong to a domain and only one thread can hold the runtime lock for the domain. This is the same behaviour as in OCaml 4.

With OCaml 5 you can have as many domains as you want though (we recommend no more than you have cores though).

Re:OCaml 5.0.0 release (including multicore and effects) by edwintorok on Saturday December 17, 2022 @08:36AM (#34027624)
This backwards compatibility decision to separate threads from domains has been very useful and allows to gradually "port" existing code to 5.0: first just fixup C bindings to avoid naked pointers, and then code can safely run on OCaml 5 just as before.

And once a program (and all its dependencies) have removed dependence on global state they can opt-in to multicore by spawning additional domains.

Re:OCaml 5.0.0 release (including multicore and effects) by gadmm on Friday December 16, 2022 @08:20AM (#34014220)
To clear up any misconception, out of the box OCaml will behave like OCaml 4 with a single domain and a "domain lock". Programs currently using multiple threads for concurrency will remain single-core for the time being, as they will need to opt-in to parallelism features. In this sense, adding parallelism to OCaml does not break existing programs, but they still might have to be audited for thread-safety depending on how they want to use parallelism. There is no magic.