josevalim

josevalim

Creator of Elixir

What are your concerns about a future type system for Elixir?

Hi everyone, as you may be aware, we are researching a type system for Elixir.

As preparation for my upcoming ElixirConf US talk, I would like to hear what are your concerns about Elixir adopting a type system in the future, hence this thread.

The goal of this thread is not to provide answers but simply have a general understanding of potential concerns and conflicts. Even if your concern turns out to not apply, it is important for us to know as it can be helpful material to include our guides and documentation.

I will establish some ground rules for this thread as an experiment:

  • Keep your concerns short, one to three sentences maximum. For example: “I worry the type system will make the compiler slower”.

  • Be precise if you can, avoid being too vague. For example, “I worry it will make Elixir bad” is too vague and therefore not helpful.

  • You may list at most your top three concerns.

  • Do not reply or comment on other concerns in this thread. If you agree with a concern someone else posted, feel free to “Like it” by clicking the heart button.

Let’s see how this goes, thanks. :slight_smile:


Edit1: for those who say “what about those who prefer dynamic”, I suggest to dig a bit deeper. Why would you prefer to be dynamic? Assuming that types provide values, what worries you about static types that you would rather avoid them?

Edit2: for those wondering why types and how they would impact Elixir, I have talked about this during my ElixirConf EU keynote 2022.

First 10 of 87 Posts! Switch mode

josevalim

josevalim

Creator of Elixir
rlopzc

rlopzc

Hello! Excited to hear about the type system. My main concern would be the adoption and gradual migration to this new type system. A big downside would be that you either migrate fully to types or can’t use them.

22
Post #2
sodapopcan

sodapopcan

Fragmentation and Rust-style drama (the “unsafe” Rust drama, not the political Rust drama… oh, Rust). IE, “How dare you write your library without types!” incidents. I worry it will bring in an influx of people to the community with a different mindset who will make a lot of noise and apply massive pressure to make major changes to the language. I’m not overly concerned about the second as I trust the core team there, but thought I’d voice it (sorry for the extra sentence).

22
Post #3
keep_zen

keep_zen

I like the dynamic type,I worry the type system will lost the dynamic type style. Like typescript for JavaScript.

15
Post #4
aayushmau5

aayushmau5

I’m concerned about the syntax for defining types. It should be friendly to new/existing elixir devs while not being too verbose or too vague.

Eiji

Eiji

  1. How well type system would be integrated in future?
    Would we be able to write a macros with a new dollar ($) syntax just like we are doing now for @spec?
    Would we be able to read information about it from beam files?
    For reference: Dynamically generate typespecs from module attribute list

  2. Would we be able to write multiple $ spec like we did for @spec?
    This is supported by ex_doc and not supported by dialyzer?
    For reference: What is the idiomatic way to use @spec?

  3. What would happen with @spec and what with ex_doc?
    Would ex_doc prefer $ over @spec or maybe it would just present both of them?
    Would @spec be deprecated in long term or it would be only recommended to use one over another?

13
Post #6
derpycoder

derpycoder

  1. Verbosity in pattern matching is scary. (People are already asking me to break my non typed / non verbose pipelines!)

  2. Hope we don’t have to include typedefs for libraries, like it happens with TypeScript projects.

  3. If type system comes, it should be integral to the language, otherwise if it’s optional like @spec or proptypes in React, then my code base will be a mess. (I will become lazy about adding types, just like I leave out tests!)

13
Post #7
polypush135

polypush135

The biggest annoyance with strong typed languages from my past experiences has always been around inheritance vs composition and the way interfaces abstract the types for encapsulation and polymorphism.

Often times it has more to do with the choice of things people lump into the interfaces calling them abstractions because they don’t have a better place to put said thing.

None of this is a concern of accessibility of said feature but rather use and abuse of the feature.
I think it would be wise to educate as much as possible around good uses cases and anti patterns.

Thank you to all the devs who keep pushing this awesome language.
I’m sure what ever you choose its going to be great,
just let necessity drive innovation and the path will show itself.

muelthe

muelthe

I don’t have any concerns.

In support of my comment, I am relatively new to programming and Elixir is the first language I worked with.

Edit: for clarification i.e. I do not fully understand the ramifications.

Fl4m3Ph03n1x

Fl4m3Ph03n1x

I worry that:

  • The type system won’t be strong enough, i.e. that it will be only a smaller improvement over dialyzer. Ideally, it would do justice to HM Type system (Hindley–Milner type system - Wikipedia) as a minimum.
  • The error output of the analyzer will be hard to read for newcomers. A good example is Rust compiler which gives precise and readable errors. A bad example is dialyzer errors as they are.
  • There won’t be a standard for how to and where to place type definitions in projects, thus causing types to be scattered all over the projects in random ways.

Last Post!

josevalim

josevalim

Creator of Elixir

Thank you everyone for sharing your concerns/worries. :slight_smile: If folks want to continue the conversation in a new thread, you are more than welcome! Meanwhile this is more than enough to cover the most common concerns during my presentation, thank you! :smiley:

Where Next?

Trending in Proposals Top

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
akoutmos
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New

We're in Beta

About us Mission Statement