Leandro Ostera presented Carmel. Carmel is a statically typed functional language designed for the Erlang VM, offering a middle ground between complex and unsound ML languages and simpler ones. The language focuses on functional programming, immutable data, and type safety, while embracing Erlang and OTP patterns, leveraging the existing Beam ecosystem, and interoperating with these languages at minimal cost. Leandro chose Caramel, an OCaml dialect, for the Erlang VM due to its pragmatic and proven type system, which guarantees type safety and provides escape hatches for more pragmatic use. The small functional core language, good scaling properties, support for functors and type-safe macros, and extensible compiler were also significant factors. The Erlang Virtual Machine (BEAM) was chosen as the target due to its ability to support massive concurrency and parallelism, low latencies, and reliability. Caramel is a type-directed, pattern-matching language with exhaustiveness checks, flexible module system, named arguments, default arguments, and external definitions. It includes a standard library modeled after Erlang’s and aims to be batteries included. Future plans for Caramel include writing the core of a Phoenix app and building a community to ensure its longevity. Leandro shared his background and how he got into functional programming, inspired by the need to solve bigger problems and the influence of Erlang’s pipelining concept.
Caramel: Bringing OCaml to the Erlang VM: A comprehensive overview
The vision behind Caramel
Leandro Ostera’s motivation for creating Caramel stems from a desire to embrace Erlang and OTP patterns while leveraging the existing BEAM ecosystem. Caramel is designed to interoperate seamlessly with these languages at minimal cost, providing a middle ground between complexity and simplicity in functional programming.
Why OCaml?
Leandro chose OCaml for several reasons:
- Type safety: Caramel’s type system ensures robust type safety and offers escape hatches for pragmatic use.
- Scalability: With a small functional core language and good scaling properties, Caramel is well-suited for large codebases.
- Compiler extensibility: The language supports functors, type-safe macros, and an extensible compiler, making it a versatile choice for developers.
Having worked with Erlang for seven years, Leandro recognizes BEAM as one of the most scalable runtimes for functional languages, making it an attractive target for Caramel.
Advantages of the BEAM
The Erlang Virtual Machine (BEAM) is renowned for its ability to support massive concurrency and parallelism, allowing efficient program execution on single or multiple cores. BEAM is optimized for low latencies and designed for reliability, embracing failures and providing built-in supervision patterns. These features make it an appealing target for various programming languages, including Elixir, Gleam, Clojure, and LFE.
The importance of a sound type system
Leandro emphasizes the significance of a sound type system in software development. Type systems guide developers during the compilation process, helping prevent issues and improve the overall development experience. Caramel, as an OCaml dialect, features a full Hindley-Miller type inference system, which automatically determines types, making coding more efficient. Its features include algebraic data types, tuples, records, polymorphic variants, type-safe macros, and a lightweight FFI syntax for interacting with Erlang and Elixir.
Key features of Caramel
Caramel offers a range of features aimed at enhancing developer productivity and code reliability:
- Type-directed pattern matching: Ensures exhaustiveness checks, knowing all possible variants of input values.
- Flexible module system: Supports nesting, passing modules as functions, and tail call optimizations.
- Named and default arguments: Provides convenience in function definitions.
- External definitions: Allows for type-safe function calls.
- Tooling: Caramel is distributed as a single binary with no external dependencies, including a code formatter, language server, documentation generator, and a preprocessor for embedding GraphQL syntax.
The Caramel ecosystem
The Caramel standard library includes core modules for booleans, strings, binaries, collections, file system utilities, and a net module. Future plans for Caramel involve writing the core of a Phoenix app with ease and building a community to ensure its longevity.
Leandro Ostera’s journey
Leandro’s journey into functional programming was driven by the need to solve bigger problems and the influence of Erlang’s pipelining concept. His vision for Caramel is to create an approachable language with a robust standard library, inspired by languages like Rust and Golang.
Conclusion
Leandro Ostera’s presentation on Caramel showcases the potential of bringing an OCaml dialect to the Erlang VM. With its focus on type safety, scalability, and seamless integration with the BEAM ecosystem, Caramel promises to be a powerful tool for developers. As Leandro continues to refine the language and build a supportive community, Caramel is set to become an essential addition to the functional programming landscape.