What does HackerNews think of eio?

Effects-based direct-style IO for multicore OCaml

Language: OCaml

Its a good time to try it. The tooling has come a long way and OCaml has an excellent build system [1] (dune is probably the best build tool I've used and I miss it whenever I use other programming languages), excellent editor tooling for vscode [2], emacs and neovim. OCaml 5.0 will bring multicore support [3] and an effect system that will cover a lot of interesting use-cases. As an example with OCaml 5 it'll be feasible to have concurrency libraries that still let you write in direct-style [4] [5]. I don't intend to say that OCaml will fit every use-case, but there is a lot going for it even in its current form before multicore support lands. If you want a language that compiles fast (it does compile really fast, at-part with Go if not better), has excellent performance characteristics, and has a good story for concurrency, you should give OCaml a chance!

[1] https://dune.build/

[2] https://marketplace.visualstudio.com/items?itemName=ocamllab...

[3] https://discuss.ocaml.org/t/the-road-to-ocaml-5-0/8584

[4] https://github.com/ocaml-multicore/eio

[5] https://github.com/anuragsoni/sandbox/tree/main/ocaml/effect...

Work has already started: https://github.com/ocaml-multicore/eio

There's also now https://github.com/talex5/lwt_eio, which allows you to run existing Lwt code alongside code using effects, to aid with porting.

OCaml is currently going through something similar, with some solutions in sight. The "motivation" part of the eio (https://github.com/ocaml-multicore/eio) documentation is a great introduction:

"The Unix library provided with OCaml uses blocking IO operations, and is not well suited to concurrent programs such as network services or interactive applications. For many years, the solution to this has been libraries such as Lwt and Async, which provide a monadic interface. These libraries allow writing code as if there were multiple threads of execution, each with their own stack, but the stacks are simulated using the heap.

The multicore version of OCaml adds support for "effects", removing the need for monadic code here. Using effects brings several advantages:

1. It's faster, because no heap allocations are needed to simulate a stack.

2. Concurrent code can be written in the same style as plain non-concurrent code.

3. Because a real stack is used, backtraces from exceptions work as expected.

4. Other features of the language (such as try ... with ...) can be used in concurrent code.

Additionally, modern operating systems provide high-performance alternatives to the old Unix select call. For example, Linux's io-uring system has applications write the operations they want to perform to a ring buffer, which Linux handles asynchronously."