Haskell: The Good Parts

by Marc Scholten, 29.10.2020

There’s been a recent blog post Haskell: The Bad Parts in the haskell community. To keep things in balance and to spread some positive vibes we should also talk about the good parts of the haskell programming language and it’s ecosystem.

Here are some of the best parts we encountered while using Haskell at digitally induced. We focus on the advantages in the web dev space because that is what we are currently working on.

Type Safety

Haskell has one of the most impressive type systems of any programming language in practical use. If you have used TypeScript or other type safe languages in the past, you should be aware of the great advantages of having a type-checked codebase. Now think TypeScript - but 10x better. That’s how Haskell feels like.

You save a lot of time debugging runtime errors. Once the compiler approved your code, you can be pretty sure that it is working. This kind of development process is usually a lot more fun than debugging why something is null or undefined.

Once your system has hit a certain size and when new feature requests are rolling in you will want to make changes and refactor some parts of your code base. With Haskell you feel empowered to make changes to any part of your codebase.

Compare this to the ruby ecosystem: When working with rails you usually need to have lots of tests or otherwise you cannot confidently refactor code after things are running in production. And even then things will break. With the power of the type safety provided by Haskell, we can make refactorings whenever we want.

It’s really a blessing.

Managed Side Effects

The way you deal with the file system, external APIs and user input is way different in Haskell than in other less functional programming languages. Your program consists of a main routine that handles the side effects and calls all your pure functions that do the real business logic.

Systems build this way scale really well because there are less moving parts. Additionally pure functions can be easily tested and changed later on.

Most other languages encourage you to do side effects in an unrestricted way. For example when working in Java, a call to an object method might indirectly change the state of many related objects. This means you cannot easily reason about what a method calls does. In Haskell most functions are pure and thus don't trigger side effects like this. And when they do you can see this already by the function's type signature.

Haskell forces you to manage your side effects in a more careful way. You can still do IO and have mutable state, you just need to make this explicit inside the type signature. This leads to a far more robust system in overall.

Performance

Out of the box the performance of Haskell based web applications is great. It just feels faster than your typical Rails or PHP application. Thanks to it’s highly optimized runtime system it can also handle way more requests than a nodejs application.

And you get all that without ever thinking about performance at all.

Tooling

In 2020 it’s finally good. Thanks to Haskell Language Server there’s now an easy way to have type information, documentation on hover and smart refactorings inside your text editor.

With nix, cabal and stack we have the best tools for managing Haskell dependencies. Cabal hell is a thing of the past.

Great things are also happening to the Haskell compiler itself. We soon can write dot expressions as you know from most other programming languages: project.name instead of name project.

Hiring Haskell Developers

Haskell is a secret super power in that regard. The Haskell community consists of many very smart and talented software engineers. Haskell developers usually learn about Haskell because they care about their craft and about building high quality software products instead of learning about it to get a high paying job. Exactly the kind of people you want in your team.

2020 Haskell is Ready for Prime Time

For years there has been this trend of growing use of type safety as well as the growing use of functional programming techniques. What language could fill this space better than Haskell. Haskell has really matured in the last years and in 2020 it feels like it’s finally ready to conquer the world.

If this post made you interested, check out IHP, our batteries-included haskell web framework.