by sgeisenh · 10y ago · 0 comments
Java, C, Python and Javascript all lack algebraic datatypes and pattern matching, which make writing a compiler much easier. There are many additional features of Haskell that make it especially good for implementing a compiler, if you know what you're doing.
I guess that's cheating because a compiler is just a function from source language to target language, so it is easily expressed in a functional language. But it does answer the question nicely.
The idea that Haskell or OCaml or SML are specially suited for compiler writing is a nineties truism that is thrown around a lot, never backed by any evidence whatsoever.
Also I'm not aware of any research into why they're better (I'm not a PLT researcher, so I wouldn't be aware of papers like that), but a huge amount of languages are originally written in ML derived languages. Here's a list of ones just written in haskell: https://wiki.haskell.org/Applications_and_libraries/Compiler...
Pattern matching makes for more readable code. And more readable code makes writing projects easier.
It is also more convenient to write code using pattern matching, but that isn't the primary benefit.
"True" readability is achieved through a consistent structuring of your program, which has to conform to the expectations of the reader.
Programmers must first build this expectation from picking up patterns in the code, which emerge no matter if you use pattern matching or an equivalent structure using the available language constructs.
You can always write in assembly code, with all that consistent structuring and conforming to expectation. But I'll takes writing in higher language with "abstraction you can write yourself" any day.