[erlang-questions] Why is Erlang what it is?

Tobias Lindahl Tobias.Lindahl@REDACTED
Thu Dec 14 15:01:44 CET 2006

Kirill Zaborski wrote:
> Thanks Ulf for your reply!
> But I have one more question: except that this would be much of work to
> "inject" the type system into Erlang, what do you think - are there any 
> real
> obstacles in the nature and the architecture of Erlang/OTP for some kind of
> static typing?
> It seems to me that if it possible we would became a language very 
> different
> from the "original" Erlang.

Yes, and I think this is really the essence of why the type systems has 
not caught on in Erlang. People are quite happy with the way they 
program, the expressivness of the language, and that they do not have to 
fight the type checker.

Basically I think it is possible to build a new language that looks a 
lot like Erlang, but that is statically typed. People have already 
mentioned the problems with code loading and message passing, but with 
some restrictions (and/or additions) to the new language there could be 
feasible solutions to this.

The more important issue is the programming style Erlang programmers 
adhere to. One example is the catch-all patterns. This sometimes makes 
the analysis results from Dialyzer more imprecise, but it can be handled 
without a problem. A type checker, on the other hand, would often end up 
with types that cannot be checked and thus reject the program, even 
though it is obvious to the programmer that there is nothing wrong.

There is a big difference between changing your program to make it more 
type friendly to aid a tool that incrementally can give you more precise 
warnings, and having to change _all_ of your programs to even being able 
to compile them. I know that there are people out there who has put a 
lot of efforts in making their pattern matching explicit and adding type 
guards in their code, and I also believe the bugs they have found have 
made their effort worthwhile. However, I think that few of them would be 
ready to perform the massive reconstruction work that adopting to a 
static type system in one go would mean.

The basic philosophy behind Dialyzer (and Typer which is soon coming to 
an erlang distribution near you) is to add benefits to a type aware 
programming style, not to enforce it, and make the type information that 
are already there in your code more visible so that you can make use of 
it if you want, and still enjoy the fruits of an inherently dynamically 
typed programming style.

If you like to know more about Dialyzer and Typer I recommend you to 
have a look at the papers at 
http://www.it.uu.se/research/group/hipe/publications.shtml where you 
also will find more reasoning about static/dynamic typing.

Best regards,

More information about the erlang-questions mailing list