github.com/ocsigen/lwt

OCaml promises and concurrent I/O

Open this visualization on its own page →

Contributors

121

Lines of Code

6,414

From

2008-05-24

To

2020-12-18

About ocsigen/lwt

Lwt is a concurrent programming library for OCaml that introduces promises as its core abstraction. A promise represents a value that will be computed in the future, and creating one spawns a computation. When that computation involves I/O operations, Lwt executes them in parallel with your OCaml code while keeping all user-facing OCaml code running in a single thread by default, eliminating concerns about locks and preemption.

The library provides extensive functionality beyond basic promises, including Unix system call bindings through Lwt_unix, higher-level I/O channels via Lwt_io, subprocess handling with Lwt_process, and pure-OCaml concurrency primitives like mutexes, condition variables, and message variables. A PPX syntax extension allows developers to write concurrent code naturally using familiar let-binding syntax. Lwt compiles to native code across Linux, macOS, Windows, and other systems, and can also compile to JavaScript for front-end development via js_of_ocaml.

The project maintains a substantial ecosystem of compatible libraries for HTTP clients and servers, JSON parsing, logging, testing, and web frameworks. It's designed to support both CPU-bound work through opt-in system threads and I/O-bound work through non-blocking file descriptors and worker threads, making it suitable for building everything from simple concurrent programs to complex server applications.

Share this video