What are some great features of Haskell according to experienced developers?

Being a complete beginner with Haskell, i'd love to hear praise by people writing code with it.

Comments (2)

Sandeep Panda's photo

I am not a Haskell expert, but I keep hearing good things about it. I'll try to summarize some of the best features of Haskell here :

Purely Functional in Nature

Functions in Haskell are pure i.e. they don't produce side effects. For example, a normal function may change some global variable, write to a file or even mutate some arguments. This is called side effects. Haskell restricts these side effects which in turn makes your code less error prone. It's also worth mentioning that some functional languages like Scala don't restrict side effects, but it's upto the developers to avoid them. Haskell, on the other hand, lets you express side effects (e.g. some kind of stateful mutation or I/O) using Monads. In this way Haskell restricts side effects, but lets you express them if you need to. This is a great feature, IMO.

Lazy Evaluation

Lazy evaluation (Opp. is Eager Evaluation) doesn't evaluate an expression until it's bound to a variable. For example, consider the function :

F(a,b)  = 2^a;

Notice that the argument b is not being used by the function. So, a language that employs eager evaluation will compute the variable b anyway. But in Haskell (because of Lazy evaluation) only the necessary arguments (i.e. a in our case) are computed. So, Haskell will evaluate an expression depending on whether it is actually being used in the function.

Lazy evaluation has its own merits and demerits. For example, it lets you implement cool stuff like Infinite Lists (Common in Mathematics) easily. There are also performance benefits associated with Lazy evaluation. But the drawback is that memory allocation becomes hard to predict. Lazy Evaluation are one of the greatest features in functional languages and Haskell does it really well.

Static Type in Haskell

All the values in Haskell have a type which is determined at compile time. So, if you try to pass wrong types of arguments to a function, the compiler will be really unhappy! Haskell, like other Functional Programming languages, is also strongly typed. This gives Type Inference which catches hidden bugs at compile time and reduces your code size.

Concurrency

Haskell boasts of its flagship open source compiler GHC, which is a high performance parallel garbage collector and light-weight concurrency library containing a number of useful concurrency primitives and abstractions. Again I don't have any real experience here but I can see that it's a big and powerful system.

Community

This is not really a feature, but Haskell has a very active and growing community all around the world. Hackage works as a central repo for all open source Haskell packages.

I can think of these 5 features as of now. But if you are thinking of diving into Haskell, you should start by all means. FP is great and Haskell is definitely worth trying.

P.S. I am not an expert in Haskell. Feel free to correct me if I am wrong somewhere.

romain's photo

bitwise esthete

Thank you Sandeep ! I was not aware of the GHC features.