I once had a discussion with a founder of an Israeli startup developing a GPU-based database with a focus on speed. The work stack included Haskell and C++, among others, and the founder was complaining about how hard it is to find competent programmers. Which was part of the reason he came to Moscow.
I carefully asked if they considered using something more popular and new. And even though the answer was rather polite and well-supported with arguments, it still sounded like âCome on, donât even bring up these toysâ.
Until then, all I heard about Haskell could be summarized as âbe VERY careful in dealing with itâ. To get to know Haskell programmers better, I came to a topical Telegram chat with some questions. I was quite afraid at first, and, as it turned out, I was right.
Haskell doesnât lend itself to popular explanation, and people seemingly donât even try. If the topic is ever brought up, itâs only talked about in full depth and as objectively as possible. Someone wrote to me: âOne of the defining features of both Haskell itself and its community is that they didnât try to achieve any kind of mainstream recognition. Instead, they focused on building a logical, principal way of solving real problems over trying to appease the widest audience possibleâ
Nevertheless, a couple of people did tell me about their experiences, which are shown below.
Denis Mirzoev (nolane): When I was in college, theyâve offered me to do a Coursera course on Haskell for extra credit. Then we also had a functional programming course that included Haskell. Iâve written one of my term papers, plus the graduation paper, on GHC. Then I found a job as a Haskell programmer.
It was, and still is, hard. When you start learning Haskell, you have to cram a lot of new concepts into your mind. Itâs like learning to code from scratch all over again.
People tend to forget (or smooth out) their earlier memories: like when they were struggling to understand what a âpointerâ, âfunctionâ or âclassâ was. Maybe thatâs why itâs so hard for them to learn Haskell: it gets harder to learn new stuff with age.
Doctor_Ryner: Once I failed my trial period at a job because of a Redux fuckup, so I tried to get a bit more comfortable with it by watching videos from its creator. First I practiced in JavaScript, but then I learned about Haskell, considered to be the âtrueâ functional language. I was fascinated by its unique concepts and how neat it was.
Tutorials arenât too user-friendly, though, plus its imperative background prevents new concepts from emerging.
Yuri Syrovetskiy (cblp): the hardest thing is to learn Haskell as your second language, when memories from learning the first one are still fresh,
What is Haskell good and bad it?
Doctor_Ryner: Itâs concise, elegant and flexible. No wonder half the libraries there are on EDSL (or at least it feels like it).
Yuri Syrovetskiy: Itâs (subjectively) easy to adapt your thoughts to code, it has a great balance of imperative and functional paradigms. Building abstractions of data and algorithms is rather simple, which allows to think about the task at hand without getting distracted by little annoyances too much.
John Doe: Strict, strong (even fascist, Iâd say) typization.
Igor Shevnin (interphx): A great type system. Itâs not as powerful as in Idris or Agda, but still reaches that convenient middle point where you can describe almost anything, and yet type inference works well. You donât have to mark them manually every time.
But a powerful type system forces you to pay closer attention to values transmitted. A bunch of type definitions could look like a boilerplate. Each command has its own extension set, or doesnât have them at all. The code is âdenserâ â each string often carries more information than in other languages, so itâs harder to read for an inexperienced developer.
Doctor_Ryner: When learning Haskell, youâll probably stumble upon this saying: âIf it compiles, itâs probably correctâ. Null doesnât exist, the functional paradigm itself is very strict and keeps you within certain guidelines, which in most cases lead to better design.
For example, Haskell doesnât have variables â only constants. You donât have to keep track of whatâs assigned where. Haskell incentivizes the use of âpureâ functions, which donât have side effects. Functional design forces the program to work as a whole, as opposed to object-oriented languages, where a lot of objects try to communicate with each other using these side effects, turning the app into an unpredictable mess. Weâve suffered this in C# and Unity a lot at work.
Denis Mirzoev: When the languageâs naturally âlazyâ, itâs generally more expressive. Algorithms get simpler. If intermediate results arenât used, it greatly increases performance.
Igor Shevnin: The âlazinessâ often helps, but when the order of function calls is important, itâs sometimes really hard to understand whatâs going on.
Doctor_Ryner: If it complies, itâs probably pretty fast.
Denis Mirzoev: Performance-wise itâs comparable to Java, but not as fast as C.
Igor Shevnin: It has extension support out of the box, which allows you to tailor the language and the type system to your liking. There are a lot of extensions that are widely used by the community and have decent samples and documentation.
Doctor_Ryner: The standard Prelude library has a lot of bad functions like read, head, readFile, which can throw out an exception and crash the app instead of returning Maybe. So I have to use alternatives or write my own.
Igor Shevnin: the biggest problem is lack of standards, to the point where a lot of people replace the standard library with one of the alternatives, which arenât in any way compatible with each other. The communityâs split on what the standard library should be, what has to be included in the core distribution and what can be offloaded to extensions⦠In my mind, it stifles development of the language.
Denis Mirzoev: It lacks tools: there isnât a proper IDE, very few performance benchmarks, no âstep-by-stepâ debugging â itâs a fundamental issue.
What projects is Haskell best fit for?
YS: For complex, security and finance-related tasks, where mistakes are expensive.
Doctor_Ryner: For everything where you need to compute, convert and analyze. Iâm surprised Haskell is less popular in Data Science applications than Python.
IS: I wouldnât risk using it for embedded systems (itâs fast, but thereâs still significant memory overhead due to âlazyâ computing) or small scripts (where its strict nature isnât needed). Itâs also important to understand how hard it is to find developers compared to mainstream languages.
John Doe: For writing industrial code thatâs going to be read by others, but then you need an entire team of Haskell developers. There isnât a lot of them.
IS: But thanks to it concise and strict nature you can use Haskell for almost anything.
Is it a good idea to start your development career with Haskell?
IS: Probably not, because the overwhelming majority of code bases a developer has to work with isnât written on it.
John Doe: Bad idea! Non-ML languages â which is almost everything in industrial applications â would be a shock to you.
DS: Often people learn math first, and switch to programming later. So theoretically, learning a language that requires a lot of math concepts (algebraic data types, pure functions) should be easier than imperative languages. I think itâs a good idea.
Doctor_Ryner: All rookie developers I work with I introduce to Haskell first. People that donât have the baggage of the imperative style are a lot quicker to learn functional code, and even when they work with object-oriented languages later, they tend to utilize good architectural solutions because theyâre used to them.
YS: Itâs best to start with a couple of fundamentally different languages, for example C, Haskell and Smalltalk, in any order. No one language could give you full understanding of the landscape.
Haskell is quite an old language. Is it good or bad?
YS: The language is developed very actively, it doesnât drag the weight of backwards compatibility for the sake of it.
John Doe: it was standardized in 1998, but you wouldnât notice: to this day, roughly every 6 months thereâs a new compiler version that can potentially break backwards compatibility.
DS: Haskell isnât old, itâs simply tried-and-tested. It doesnât (and will never) introduce mindless changes. So itâs probably good for the health of the community.
Itâs often said that Haskell is one of the toughest languages to learn. Is it really?
Doctor_Ryner: As a language itself â no. The hardest part are the abstractions it uses. A person whoâs never seen a Haskell code before could go mad from the amount of new information and strange instructions. What doesnât help is that the language ârestrictsâ a lot of stuff that doesnât fit its functional concept.
John Doe: It took me two months of bedtime textbooks, manuals and tutorials just to get my first project to compile. Though, once it did finally compile, it worked right away under full load (6k RPS average, with 15k peaks) for half a year with no changes whatsoever.
DS: Iâd bet that if you give a college student Haskell as a first language and he goes far with it, then imperative programming would look complicated and less intuitive to him.
IS: Itâs all relative. Out of mainstream languages, I consider C++ the hardest. Theorem-proving languages (like Agda or Coq) are harder than Haskell conceptually. Haskell isnât a hard language, but it takes time to learn its pattern and libraries (both standard and third-party).
Is its complexity justified?
IS: Patterns and a high abstraction level are justified, since it makes code shorter and more durable. But I think operators, function names and a lot of other things couldâve been a bit user-friendlier.
Doctor_Ryner: Oftentimes Haskellâs complexity allows you to make very short, flexible and modular solutions.
YS: Iâd say only effect control is a bit wonky, though itâs still almost always preferable to no control. And thereâs an ongoing project to make it simpler.
John Doe: For people used to Python/PHP/whatever, Haskell feels dislodged from reality. For those you werenât already interested in the theory of categories, itâs very hard to learn from scratch. But when you do understand it, you find a new approach to solving a problem.
Itâs often said Haskell isnât a language for developers, but for mathematicians. Is this the reason itâs not mainstream?
DS: It showcases the main idea of Haskellâs main developers â âavoid success at all costsâ. Not meaning âavoid successâ, but âavoid too expensive of a successâ.
They couldâve made Haskell popular. For example, Microsoft supports the language. They couldâve made it more imperative, sacrifice rigidity for popularity. There are a lot of dirty tricks they couldâve used, but never did.
Sure, the language isnât popular, but that means itâs quality doesnât suffer. Advantages of Haskell compared to imperative languages are obvious to me and its problems can all be solved, so I believe itâll get popular later on.
YS: Only people who donât know anything about it say so. Haskell is used a lot in âreal-worldâ development, you could probably find examples in your favorite search engine. In particular, we at Kaspersky Labs are very happy with Haskell and wouldnât trade it for anything else.
IS: Whatâs a âmathematicianâs languageâ? Itâs either R/MatLab/Mathematica built specifically for statistics and calculations, or Python because itâs simpler and doesnât require as much engineering background. But not Haskell. It has stuff from algebra, like monoids, but it has practical application.
The reason why C/C++/Java are so popular is because theyâve historically been very widespread in the enterprise space. They filled a niche. But nowadays a lot of companies start to use Haskell and other functional languages.
What PL would you compare Haskell to?
John Doe: out of the popular ones, probably with Erlang. But Erlang is simpler to learn and write in.
DS: I know C, C++, Java and Haskell. C++ is awful and canât compare to anything. C is great for low-level development. In all other applications Iâd prefer Haskell.
Choosing between Java and Haskell is harder, but it depends on the application. For example, Java is better for Android, but in server applications theyâre almost equal. If the environment â tools, libraries â allow, I often choose Haskell.
Doctor_Ryner: I compare with C#. Just Google âhow to do Maybe in C# and Haskellâ. Itâs strange that such a strictly functional language as Haskell feels a lot more flexible and free. But in reality, theyâre the polar opposites.
C# is one of the most object-oriented languages, and its advantages go in contrast with Haskell. C# always forces you to write a lot of extra stuff, which slows the code down and often makes it less elegant. After Haskellâs short and neat solutions, itâs hard to go back.
IS: With Rust, and so far Rust probably wins. It takes a lot from Haskell and other functional languages, but mixes functional and imperative approaches, plus the developers have handled its development a lot smarter.
Whatâs your opinion on the Haskell community?
John Doe: The vast majority of people are very friendly and ready to help, which is a nice contrast to a lot of other languages.
Doctor_Ryner: Haskell communities are often full of terrifyingly smart people. Local memes about PhDs and academia exist for a reason. In other communities people mostly discuss regular production problems and data structures, while in a Haskell chat people discuss monads, applicative functors, crazy types and things like that.
You always learn something you never even thought about before.
Itâs said that Haskell developers are too full of themselves. Is it true?
DS: Yes. I feel like itâs because they really like their language and are disappointed how unpopular it is.
John Doe: Nothing of the sort.
Doctor_Ryner: People probably say that because a lot of mainstream developers get annoyed with a Haskellist starts talking about functional programming and its perks. The Haskellist, meanwhile, gets annoyed that no oneâs listening to him and start throwing terminology around, and thus gets labeled as âfull of himselfâ.
IS: Itâs a bit harsh to call them that. Itâs probably because functional programming, OOP, differences between OOP-classes and union types, the extension problem and a lot of other definitions slowly build into one coherent picture, and then itâs hard to understand people who continue the holy wars of OOP vs FP.
Why are FP languages so niche?
DS: Their advantages arenât enough to interest programmers. Being hard to learn doesnât help matters, either. Tooling issues also scare people away, even though that problem would probably be solved if more people were interested. Itâs a vicious cycle.
IS: Well, FP concepts slowly bleed their way into other languagesâ¦
Doctor_Ryner: The core principles of FP and its languages are fairly widespread already. Even Sharp has Linq and some other similar libraries. But purely functional languages probably just have too many novel concepts to be popular.
Donât forget that 20 years ago the hardware wasnât fast enough to handle functional languages yet, so it only entered the mainstream fairly recently, and Haskell itself is only growing.