Things that set Haskell apart from almost any other even-semi-mainstream language: But the problem is, it takes quite a while to acclimate to the wackiness. It's more like, we have all these other programming languages, and they're all more or less similar, and then there's Haskell which is totally different and wacky in a way that's totally awesome once you get used to the wackiness. Haskell is not a language where you go look at a few cool examples and go "aha, I see now, that's what makes it good!" You are kind of asking the wrong question. Fewer lines for bugs to exist on.Ĭompile errors. Reduced complexity leads to fewer logic errors.Ĭompact code. The amazing type system, lack of side-effects, and of course the compactness of Haskell code reduces bugs for at least three reasons:īetter program design. So, Haskell lets you write compact, readable programs - often without sacrificing a lot of performance.Īnother thing I must add is that Haskell simply makes it difficult to write buggy programs. which looks a lot like what the efficient C implementation of a file copy would do. While the results are compiler-dependent, what will typically happen when you run the above program is this: the program reads a block (say 8KB) of the first file, then writes it to the second file, then reads another block from the first file, and writes it to the second file, and so on. ![]() For instance, if you were to remove the writeFile line, Haskell wouldn't bother reading anything from the file in the first place.Īs it is, Haskell realises that the writeFile depends on the readFile, and so is able to optimise this data path. It doesn't calculate things until it needs to, and by extension doesn't calculate things it never needs. In most languages (even some functional ones), a program structured like the one above would result in the entire file being loaded into memory, and then written out again under a new name. But how is this so different from (say) a Python program with a very similar structure? ![]() In that sense it's better than a C program. This is the example that convinced me to learn Haskell (and boy am I glad I did).
0 Comments
|