Skip to content
Tech News
← Back to articles

Elixir v1.20 released: now a gradually typed language

read original get Elixir Programming Book → more articles
Why This Matters

The release of Elixir v1.20 marks a significant advancement in the language's capabilities by integrating a gradually typed system. This development enables Elixir to detect verified bugs and dead code more efficiently without burdening developers with extensive annotations, improving code reliability and developer productivity. It signals a major step forward in making dynamically typed languages more robust and maintainable, benefiting both the industry and end-users.

Key Takeaways

Elixir v1.20 released: now a gradually typed language

In 2022, we announced the effort to add set-theoretic types to Elixir. In June 2023, we published an award winning paper on Elixir’s type system design and said our work was transitioning from research to development.

With Elixir v1.20, we have completed our first development milestone which is to perform type inference and gradually type check every Elixir program, without introducing type annotations. This means Elixir increasingly reports dead code and verified bugs: typing violations that are guaranteed to fail at runtime if executed. Elixir can find verified bugs in existing programs efficiently, without introducing developer overhead, and with an extremely low false positives rate.

In this announcement, we will break down the type system goals, what the dynamic() type means in Elixir, and how it finds verified bugs. In particular, our implementation performs well in the “If T: Benchmark for Type Narrowing” benchmark. Elixir passes 12 of the 13 categories, showing that it can recover precise type information from ordinary Elixir code, which we use to find verified bugs in dynamically typed programs.

The type system was made possible thanks to a partnership between CNRS and Remote. The development work is currently sponsored by Fresha, and Tidewave.

Types, in my Elixir?

Our goal is to introduce a type system which is:

sound - the types inferred and assigned by the type system align with the behaviour of the program

gradual - Elixir’s type system includes the dynamic() type, which can be used when the type of a variable or expression is checked at runtime. In the absence of dynamic() , Elixir’s type system behaves as a static one

developer friendly - the types are described, implemented, and composed using basic set operations: unions, intersections, and negations (hence it is a set-theoretic type system), with clear error messages

... continue reading