Is Dialyzer worth the effort?


#1

I have put far too much effort into Dialyzer over the last year or so - and basically - I doubt it’s worth the effort.

It’s not as easy to use as type inference in statically typed functional languages, and you don’t get as much bang for the buck with its super optimistic success typing.

Perhaps some sort of saner alternative would be an option for Elixir 2.0?

I often think Clojure is the closest language to Elixir - Clojure spec and gradual typing sound v interesting.

Thoughts? Perhaps Dialyzer is better than I give credit, would like to hear some good counter-arguments ; )


#2

Dialyzer won’t work in many cases, but the most important for me if I see @spec above the function definition is that I’ more confident what should be input and output for that function. It’s easier to see one line of typespec than to analyze function’s behavior.


#3

I fully agree with @PatNowak. The usage of @specs goes further than using Dialyzer. I find it very helpful that functions clearly indicate what input/output they receive, especially because Elixir is dynamically typed.

Dialyzer’s main purpuse, in my opinion, is to make sure that the written @specs match the function’s implementations. I completely agree that it is less nice to use than typing in a statically typed language, but even when not using Dialyzer, do not underestimate the @spec.


#4

I pretty much share the sentiment. Having types guide your development is a benefit I get when developing with OCaml, Haskell, Java, etc.

I tried to get the typechecking more streamlined with my dev by integrating Dialyxir as a linter in Atom. I was surprised at first that it doesn’t exist already, but as I developed the package myself I can guess why anyone doesn’t bother; it’s kinda slow, even for a small project built on top of Phoenix, and the output is not easily parse-able. I finally just create a command using process-palette that will run mix dialyzer and I execute it every once in a while.

I however agree that the @specs helps a whole lot as documentation, especially when it shows on atom-elixir’s autocomplete. Types are great ^^


#5

As long as you have Dialyzer in your build process - i suppose that’s v true - keeps some verifiable documentation front and centre.


#6

Yup, that’s part of the problem, in order for specs to be useful you have to use Dialyzer - and it’s not a great tool…


#7

I however agree that the @specs helps a whole lot as documentation, especially when it shows on atom-elixir1’s autocomplete. Types are great ^^

Oh that is v cool - I have been using VS Code for too long : )