Elixir Static Typing
Discussions center on Elixir's dynamic typing limitations, the role of Dialyzer and typespecs for static analysis, and ongoing developments toward gradual and static typing features.
Activity Over Time
Top Contributors
Keywords
Sample Comments
There's a component called dialyzer that can help detect type issues, but i wouldn't say its nearly as useful as having real types in a language. That said, I've never found it to be much of an issue in Elixir, and the advantages you get with BEAM are worth it. There's a newer language called Gleam that does have a strong type system you may want to investigate, as it runs on BEAM (like Elixir and Erlang) and can use libraries and applications from both in its apps.
I believe you meant static typing. There's active ongoing work in this space, and Elixir is actually gradually typed now. You can read more about it in the docs: https://hexdocs.pm/elixir/gradual-set-theoretic-types.html
Elixir has had dialyzer + type hints for years
FYI: Elixir may be getting static typing in a future version.https://elixir-lang.org/blog/2023/09/20/strong-arrows-gradua...
awesome - thanks for the reply. Makes sense. I work with elixir full time and the type-safety bugs me. I'll check this out when I can find some time.
Have you looked at Dialyxir? [1] It makes Elixir feel like a structurally typed language. I use it at work, and it catches a lot of inconsistencies at runtime.[1]: https://github.com/jeremyjh/dialyxir
Same. I suffer through it, because the rest is pretty neat.There is no best way. Fortunately the Elixir core libraries are annotated with typespecs, which gets you like 30% there. But dialyzer sucks, and the typespec syntax itself, as well as its expressiveness, leave a lot to be desired. It's clearly an afterthought.One day I'm gonna make a TypeScript for Elixir.Note: There's eg Gleam a statically typed language for BEAM, but it's quite unlike Elixir and it has a mu
I agree and believe that it's harder to maintain a dynamically-typed codebase, but Elixir has a well-thought-out gradual typing solution: typespecs ( https://hexdocs.pm/elixir/typespecs.html#basic-types ). This builds on Erlang's Dialyzer tool and is supported by editor plugins like VSCode's ElixirLS extension. In practice, you do get instant typechecking while
Although I really like elixir, I thought he asked for something with static typing?
Elixir is gradually typed: https://news.ycombinator.com/item?id=38914407...and is gradually getting more gradually typed: https://elixirforum.com/t/elixir-v1-19-0-rc-0-released/71190...