A case for inline type annotations

Me neither. In fact I rarely read @specs except for the odd hairy function. In fact I used to highlight them as comments because for the most part I see them as pure noise (this broke and I haven’t bothered to fix it). And yet, with clear variable names, pattern matching and guards, as well as low-bar good coding practices like not making “rabbit hole” function calls, I can always easily identify the types.

All that coupled with Elixir (likely/hopefully) getting type inference, there is absolutely no need for inline types. We can use our modern editors to give us clarity in the times we’re confused. As @jam says, let the compiler do the work! I also don’t appreciate this rhetoric that inline types are “clearly superior” as it doesn’t lend to good faith debates. In my mind, having them them on their own line is clearly superior. If you’re having trouble reconciling them then you’re stuffing way too much in your function head.

As far as “familiarity in the name of adoption” goes, I’m also not convinced of this. Elixir is already different in many weird and wonderful ways. For example, it makes the “obviously superior” decision to have separate syntax for blocks vs data structures (oh the horrors that poor overloaded curly brace is forced to endure in all those “modern” languages!) This is to say that anyone moving over to Elixir is already going to have to have an open mind or they’re going to have a very bad time (as we see on this forum from time to time). Adding inline types almost feels like a step towards the normalization of proposals to “make Elixir less like Elixir.” If you want a “familiar” syntax on the BEAM, there is the fabulous Gleam project! Though you’d be missing out on Elixir’s exceptional macro system meaning you’ll never have awesome projects like Ash. I should say, though, that I have no idea what José’s adoption goals are, these are just my feelings.

That said, in the name of community and open ideas, I love that this is being entertained. If it is found to be possible and this is what the community wants, then so be it. But also, please no :frowning:


If we’re all going to be vibe coders by next year, does any of this even matter? :grin: :grimacing: :upside_down_face:

2 Likes