Elixir v1.20: Now a gradually typed language

elixir-lang.org

926 points by cloud8421 a day ago


yeetosaurusrex - 18 hours ago

I wanted to use functional programming in actual projects and Elixir's lack of static types almost stopped me from picking it up initially.

I tried it out and, although I do miss static types sometimes, immutability and not having to deal with inheritance and other OO abstractions has made the trade-off worth it for me.

Yes some people do claim that pattern matching makes up for the lack of static types. I don't agree with that, but can say that anecdotally the number of type related bugs I notice in *my* Elixir code is much lower than the number of similar bugs I used to write in languages like Python. Whether that's because of common usage of pattern matching, or community adherence to patterns like returning tuples of {:ok, result} | {:error, error}, or something else is anyone's guess.

An important point not in the heading is that gradual typing has been added without any new language syntax.

It's still not statically typed. Maybe it never will be, but this is a step in the right direction and at least they're trying.

losvedir - 21 hours ago

Oooh, here we go! As a professional Elixir developer for... 10-ish years now, I've been super excited about types coming. I'm very excited that the beginnings have started to land here.

That said, I would love to know how the state of what's in v1.20 compares to un-spec'ed dialyzer. I was under the impression that dyalizer's "success typing" approach (not flagging a function if there are some combination of parameters such that it works, rather than flagging it if some combination of parameters can make it fail) was like what Elixir is doing here, and I haven't found dialyzer terribly useful.

teleforce - 19 hours ago

Honest question, in the era of vibe and AI assisted coding is there any advantages of using untyped programming languages, apart from the fact that non-typed languages has more traning data for the LLM?

This probably controversial, but personally I consider untyped languages as technical debts that need to be fixed sooner or later, and the OP article is partly addressing this very issue.

Rewriting critical software infrastructure (infostructure) to more reliable typed languages happened to most of the Ruby on Rails (RoR) software unicorn stacks for examples Twitter, Airbnb and Shopify to name a few [1],[2],[3].

The main reason provided for these migration is transitioning away from monolith architecture, but almost all of the new programming languages being used are typed thus make it obvious that the untyped languages are not performant and difficult to scale even by changing the architecture.

[1] Why did Twitter move away from Ruby on Rails?

https://www.quora.com/Why-did-Twitter-move-away-from-Ruby-on...

[2] How Airbnb Scaled by Moving Away From a Rails Monolith:

https://www.reddit.com/r/programming/comments/1756q7z/how_ai...

[3] Is Shopify shifting away from Rails?

https://news.ycombinator.com/item?id=33409597

sestep - a day ago

I've seen various posts about Elixir's gradual type system pop up on HN, but haven't been following too closely. Does anyone know whether this particular gradual type system can change the asymptotics of programs vs untyped code? As far as I'm aware, most gradual type systems (e.g. Racket) can make programs run asymptotically slower, although there are some exceptions [1].

[1] https://doi.org/10.1145/3314221.3314627

mrdoops - a day ago

It's very nice updating Elixir, having no breaking changes across my many projects and it then the compiler just finds bugs for free. I'm so spoiled.

alprado50 - 21 hours ago

Maybe it is only my experience, but i feel that languages that were not typed since the begining never work as well as "true" typed ones.

anonyfox - 5 hours ago

Between professional Elixir, Go Rust and Node over decades now I am arriving actually at OCaml now. Using LLMs to actually teach it to me.

Andd boy, a REAL type system is just something i won't ever again compromise upon. I mean yeah I did many years of Ruby/Rails and loved it back then, and Elixir in that regards at least on surface felt strictly better (sweet pattern matching, pipes, ...) but just SO MUCH CODE is written either at runtime or in loads of tests that essentially make up for the lack of a compiler guarantee about type errors i cannot unsee it anymore. Rust is way better here for example for sure, Trait system and all, but here the compile time tax is very real even after fiddling with optimal crate splits. Plus _sometimes_ a bit of simple mutable code just hits home in a few lines instead of often slower pure FP equivalents.

Happy to see that Elixir finally after years in the making is arriving somewhere, but I essentially left the ecosystem now since I really do either TDD (Type driven Development) now or quick solutions with node/go when quality isn't the concern... and now I discover OCaml (with Effects based multicore now) and yes the syntax is _a bit_ alien but damn it checks all boxes of all techstacks I ever wanted. I can write nearly Elixir style code, pattern match pipes and all, I can write (nobody does but I could) failry powerful OOP stuff, compile instantly, in a statically linked binary, with true parallelism, and a type system that is amazing (don't get me started about module functors). Beam is a impressive feat of engineering, but its also moving like molasses and deployment is nontrivial and quite cumbersome to operate (at least people need quite a lot of learning curves until theyre comfortable with this powerful beast). And then there is OCaml. And the tradeoff here is on the human side, nearly no one knows it, learning curve is high, so statistically no team would pick it in most businesses or has experience with it, and that specific situation is personally for me irrelevant now as a solo builder in an LLM age.

Lets see how good this becomes at some point, I am watching and would have loved to have this at least gradual typing available years ago!

gworkman - 10 hours ago

Congrats José and the Elixir team :)

I love the fact that I can upgrade my elixir version and the compiler finds a bunch of free bugs. The last several releases have been like this, and basically no breaking changes.

misiek08 - a day ago

Im so happy seeing this. We are approaching „great language” level and for me this is the first one.

I would be thankful for pointing at any other language that reliably and safely adds great features and is already convenient to use. I jumped from mastering Go to learning advanced C#, because Go stopped with adding great things :(

dzogchen - 21 hours ago

The past month I have been going through the Elixir exercism.io track https://exercism.org/tracks/elixir

It is really excellent!

tines - 5 hours ago

Funny how all these dynamically typed languages are gradually becoming typed, but none of the statically typed languages are gradually becoming untyped.

satvikpendem - a day ago

How does it compare to Gleam? Or rather, why use Elixir over Gleam now? I suppose Phoenix and Live View in particular are big draws to Elixir.

sa1 - 6 hours ago

What do set-theoretic types mean? Aren’t types an alternative approach meant to avoid the paradoxes with sets?

Is it just being used as a marketing term?

bad_haircut72 - 20 hours ago

Im not Jose so I bow to his wisdom but imho thinking about Elixir in types means you arent treating is like a lisp any more, which imho undermines how great Elixir is

in the agent of agents this will probably give us a big boost though so thankyou Elixir team

NeutralForest - 9 hours ago

It's exciting to see those developments in what is a language with already great economics. I'm sad there's pretty much no market for it in western Europe aside from maybe Germany.

meszmate - 12 hours ago

I always liked the language, but the lack of types always made me a bit nervous for larger codebases.

keithnz - a day ago

seems ironic that critics were saying, it needs typing, and all the elixir fans were saying you don't need typing, you don't get bugs related to typing because elixir is somehow magic, now they get typing and it finds bugs for them.... but you said you didn't need that to prevent bugs? But good to see! I spent a bunch of time trying out Elixir a while back, I enjoyed it, but just didn't agree with the lack of types.

sevenzero - a day ago

Oh shit here I go (and learn Elixir for a whole year (again)) again.

I love everything about Elixir, but Elixir constantly makes me doubt myself like no other language. My brain isnt made for functional stuff, but this makes me want to try again.

Sucks that it's not really a beginner friendly ecosystem and usually, when having questions answered, people assume you already know a lot about the language.