Elixir 1.19

https://news.ycombinator.com/rss Hits: 20
Summary

Elixir v1.19 brings further improvements to the type system and compilation times, allowing us to find more bugs, faster. Type system improvements This release improves the type system around two key areas: type inference and type checking of anonymous functions and protocols. These enhancements seem simple on the surface but required us to go beyond existing literature by extending current theory and developing new techniques. We will outline the technical details in future articles. For now, let’s look at what’s new. Type inference of all constructs Type inference (or reconstruction) is the ability of a type system to automatically deduce, either partially or fully, the type of an expression at compile time. Type inference may occur at different levels. For example, many programming languages can automatically infer the types of variables, also known “local type inference”, but not all can infer type signatures of functions. Originally, our plan with Elixir’s upcoming type system was to support type inference of patterns, guards, and return types. Therefore, if you wrote this simple function: def even?(x) when is_integer(x) do rem(x, 2) == 0 end Elixir would correctly infer the type to be integer() -> boolean(). However, if you wrote this function: def even?(x) do rem(x, 2) == 0 end The type would be dynamic() -> boolean(), since there are no guards, even though the functions behave virtually the same, as the rem operator expects both arguments to be integer (they just raise different exceptions for non-integer values). Inferring type signatures comes with a series of trade-offs: Speed - type inference algorithms are often more computationally intensive than type checking algorithms. Expressiveness - in any given type system, the constructs that support inference are always a subset of those that can be type-checked. Therefore, if a programming language is restricted to only fully reconstructed types, it is less expressive than a solely type checked counterpart. I...

First seen: 2025-10-16 20:50

Last seen: 2025-10-17 15:53