
In imperative programming, we are giving the program a series of commands to run. The first step in truly understanding Haskell’s type system is to remember the fundamental difference between functional programming and imperative programming. However, this is isn’t a big a problem for Haskell, as we’ll see. In languages like C++ and Java you declare the type of almost every variable you make, which you don’t have to do in Python. This is very hard in Haskell, but easier in Javascript or Python.Īnother disadvantage is that there’s more boilerplate code in statically typed languages. Suppose you suddenly find it useful to do a database operation in the middle of otherwise pure code. It’s oftentimes a lot easier to hack together a solution in a dynamically typed language. So what are the disadvantages of static typing? Well for one thing, development can be slower. It doesn’t excuse a total lack of testing, but it certainly reduces the burden. As a result of this, static typing needs a lot less unit testing around type agreement between methods. An object with the wrong type will raise a compile issue at its source, rather than further down the call chain where it is actually used. This also means that errors are more likely to be found where they first occur. With static typing, your code will simply not compile in the first place. But then in production a user stumbles on an edge case where, for instance, you forget to cast something as a number. With a dynamically typed language, you might ship code that seems to work perfectly well. One important benefit of static typing is that many bugs are found at compile time, rather than run time. To understand why the type system is so important, we have to first consider the advantages and disadvantages of static typing in the first place. It’s even different in some respects from other statically typed languages like Java and C++.

It is radically different from the dynamic typing of languages like Python, Javascript, and Ruby. Understanding this system is one of the keys to understanding Haskell.

One of the things that makes Haskell unique is its strong, static type system.
