OCaml 5 With Multicore Support Is Here!by Christine Rose on Dec 19th, 2022
It's here! It's finally here! On Friday, 16 December 2022, the OCaml community announced the official release of Multicore OCaml! From the beginning, Tarides has been deeply involved in OCaml's evolution, so we're very proud to present OCaml 5!
Our work with the myriad of academics, industrial developers, and the entire OCaml community has been both inspiring and fulfilling. We look forward to continuing our collaboration for future iterations of OCaml. Watch KC's keynote to get a visual overview of all OCaml 5 has to offer!
About OCaml 5
OCaml is a pragmatic functional programming language. Its strength lies in the capacity to balance security, performance, and reliability. OCaml is used in both industry and academia to address problems in which a single mistake could be catastrophic, such as in finance and sensor analytics for sustainable agriculture. It's also used by millions of developers daily with Docker for Desktop.
OCaml 5 brings the long-awaited runtime support for shared memory parallelism and effect handlers. It is a major change (including the full rewrite of a new, concurrent garbage collector), but we worked hard to ensure there would be no breakage for existing OCaml users. This release combines the security and safety of OCaml with new features that bring huge performance benefits and an improved methodology for writing concurrent code.
OCaml 5 supports both the the x86-64 and ARM64 architectures, so Linux, the BSDs, macOS, and Mingw-w64 on Windows are all supported. Over the next year, the OCaml community and Tarides will restore support for most previously-supported architectures that fall outside of this range, but this doesn't mean you can't use OCaml now! OCaml 5 seeks to be completely backwards-compatible, and programs written for any version of OCaml 4 will continue to work in OCaml 5.
With technological advances and the explosive growth of machines with more and more available cores, it's necessary for programming languages to support multicore technology. Until this new release, OCaml was single-threaded, meaning it could only utilise one core to run code. With OCaml 5, programs can now exploit multiple cores and execute processes in parallel, providing users with enhanced performance and efficiency.
Performance is key with OCaml 5 to ensure your programs run smoother, faster, and more efficient, a significant achievement in turning cutting-edge science into real-life applications and industrial-strength tools.
Multicore OCaml has been in the making for 8 years and required a full rewrite of it runtime environment, so you can believe that the OCaml community is absolutely thrilled to see this come to fruition from their years of hard work. Multicore support ensures beginners can achieve the same productivity as OCaml experts!
If you come across any unexpected behaviours that aren't covered by the few exceptions listed on the Discuss post, please report them on the OCaml issue tracker.
Eio & Concurrency
Concurrency in OCaml 5 is supported through the use of effect handlers, a new feature that enables the development of concurrent applications in a seamless fashion. The developer experience is improved, now that programmers can simply write concurrent code in the same style as non-concurrent code.
Eio, our experimental, high-performant I/O library, is an excellent example of use for effect handlers. Since we've already demonstrated that we can reach millions of requests per second while keeping simple, direct-style code, OCaml 5 is meant to be on par with Rust (and outperforms Go) for I/O heavy workloads.
With Eio, asynchronous and synchronous code can be composed together naturally, solving the function colouring problem that affects many languages, including programs written in earlier versions of OCaml. This makes OCaml easier to use, even if you're new to the language.
Another huge improvement with OCaml 5 is Runtime Events, a library included with OCaml 5's runtime, which efficiently processes performance data from the garbage collector (GC) and runtime. Runtime Events provides continuous monitoring of OCaml applications. Multicore programs are notoriously hard to debug and profile, so we ensured that OCaml 5 has a built-in mechanism to build great, relevant tooling. The basis of this is Runtime Events.
Read more about Runtime Events in the OCaml Manual, and watch the OCaml Workshop for a visual introduction to Runtime Events. Also check out these WIP tools: olly and meio.
Open Source and Open Arms
OCaml 5 is freely available to everyone worldwide. For installation instructions, compiler configurations, and a detailed list of changes and new features, please visit this OCaml Discuss post. While you're there, join in the conversation! We welcome you to the OCaml community with open arms! There has never been a better time to learn and use OCaml. Give it a try, and please report any problems to the OCaml issue tracker.
Read more about the journey to Multicore, Runtime Events, Eio, and more over the next six weeks in our OCaml 5 blog series. It will include several articles highlighting OCaml 5's new features, interviews with OCaml engineers, and reasons why OCaml should be the next language you learn. Follow us on Twitter and LinkedIn so you don't miss a thing!
This OCaml 5 release is the best holiday gift for developers, both experienced and those new to programming. Enjoy!
Tarides is always happy to discuss commercial opportunities around OCaml. Especially with the OCaml 5 release, there are many areas where we can help industrial users to adopt OCaml 5 more quickly, including training, support, custom developments, etc. Please contact us if you are interested in discussing your needs.