Search code examples
programming-languageserlangtypechecking

Static typechecking in erlang


I'm slowly falling in love with Erlang, and only have one big, BIG problem.

I'm a big fan of languages like Standart ML and ocaml with their strong static typechecking.

is there a nice and clean way to introduce somesort of static typechecking in erlang. I'm looking at the -type and -spec annotations.

Does anyone have a nice solution?


Solution

  • I've been there! I love both OCaml and Erlang and use them regularly.

    By the time I started using Erlang I had years of experience with OCaml. It took me several weeks to adjust to the fact that there's no static typechecker in the compiler. But after that, the pain was completely gone.

    To a certain extent, going without the typechecker is a worthwhile exercise. For me, it was enlightening experience and really made me a better programmer.

    There's is, however, an external static typechecker for Erlang called Dializer. I find it very useful. The problem with it is that you need to call it separately and it is slow. Running it once in a while (e.g. before committing code or as a part automated builds) works great. I've never tried running it after each compilation as it would be too much of a distraction to wait until it completes.