Gradualyzer vs Dialyzer - main differences?


In a post I made about having static types in Elixir, someone mentioned the tool Gradualizer. This came as a surprise to me, as though I have seen and read quite a lot about Dialyzer, I have never seen an Elixir book mention Gradualizer.


I understand Gradualizer aims to provide static typing for erlang (and I suppose Elixir) via gradual typing, while Dialyzer takes a different approach.

But as someone who doesn’t understand the differences to both systems, this is new terrain.

  1. What is the main purpose of Gradualizer in regards to its ancestor? (to replace Dialyzer, be a competitor, improve upon it…)
  2. What are the main differences between one tool and the other?
  3. Why should I move to Gradualizer when Dialyzer has been the de facto tool for typing in erlang/elixir since… well, forever?
  4. Is Gradualizer ready for usage in real projects? (I understand it isn’t, please correct me if I am mistaken)

Dialyzer was build on the idea of success typing. This makes so that dialyzer can work even without user input, just based on code itself. It also tries to not report false positives quite heavily. But it comes with the downside of not detecting many of the error cases other static typing systems can detect. (The link below even argues that dialyzer is not a type system)

Gradualizer is a completely different approach. Afaik it doesn’t do type inference, so unless you manually provide typespecs it does nothing. But for the places you do provide them, it’ll statically check for errors even beyond what dialyzer would be able to detect or would acknowledge. The other big part between the lines is that you can gradually add type safety to your systems. It’ll work with as much typespecs as the code does provide.

For more details see this one:

Essentially both tools try to detect errors, but do that in quite different ways with therefore quite different tradeoffs.

1 Like

Have you used both tools in concert in a project? I’m curious since I’m considering it.

I have not. I’ve just seen the talk about gradualizer.

Are there any tutorials/articles how to use gradualizer with Elixir?

@OvermindDL1 created Gradualixir ( ). Right now I think it is the best shot at using Gradualizer with Elixir. If you have any questions you can probably ask him.

1 Like

I think gradualixir is in a slightly broken state due to recent changes in gradualizer (again), PR’s to fix welcome, and I probably need to track specific commits instead of master until gradualizer publishes it’s first release. :sweat_smile:

But when it works you just run mix gradualizer to scan your whole project or mix gradualizer files.beam morefiles.beam path/**/to/files/*.beam, recommend to do individual files for now to work on errors at a time to fix things (when it’s in a working state). Gradualixir itself passes gradualizer (and dialyzer) with flying colors though. :smile:

1 Like

I heard the Running in Production podcast where you talked about Gradualizer and other stuff. Very nice episode :slight_smile: You seem to follow the development of Gradualizer closely, do you know when it will stable enough to use and what the current state is?

Seems to be progressing fairly quickly, dev seems to have slowed lately as most of it is pretty well done now, mostly just needs more typespecs fixing broken typespecs. Other than that it’s usable now for most things, just more typespecs, lol.

1 Like