Programming

Haskell

Haskell Advocacy

By me:

A Totally New Language Comparison

If you search the web for programming language comparison you will find many religious tracts seeking to draw you away to some language camp: Java, C++, C#, even Python, Perl, etc. They will entice you with a list of important features and annoying blunders of the other languages. But no list (except this guy's and this) guy's will contain the following features from my required feature list. Most people don't even know what these are, why they're important, or what they're really missing by not having these well established language features, already decades old:

  • Strong, safe, powerful typing, including type inference, polymorphism, type classes, allowing you to reason in a veritable type algebra
  • Structural pattern matching (pattern matching on constructors of any type, not just built in types), guards
  • First class functions w/ partial application and currying (even on constructors!), first class lambdas (GvR wants to take lambdas out of Python!), function types
  • The most awesomely simple and beautiful syntax this side of Scheme: using prefix functions as infix or arbitrary non-alphanumeric operators as values/sections
  • Complete and utter referential transparency and resulting lack of side-effects related bugs, non-strict (lazy) evaluation, computational clarity that these result in (e.g. infinite lists), monads, etc.

Note that none of the common "modern" languages (C++, C#, Java, even Python ☹️) have any of these modern features, despite the fact that these features have been around for over a decade! That means that C++, C#, Java, and Python are all from a generation of languages ago (and some would argue, even older!) Why are we all stuck in the past! What are we afraid of? That we might learn something?

Haskell v. OCaml

If you code in OCaml after coding in Haskell for a while, you will start wondering why they didn't include (even simple) things to make your life easier, like type classes. Or 'where' clauses. Or the layout rule. And while we're at it, add do-it-yourself infix operators, sections and user-defined (non-alphanumeric) binops for convenience. And we might as well go for the modularity that laziness provides, and add monads, etc. etc.... Oh wait, now we have Haskell!

It's more than just a list of features. It's a way of thinking and a more productive way of doing things, at least for me. BTW How did I go so many years without Haskell? (besides the fact that Haskell 1.0 came into existence when I //started// programming around 1990).

Quotes

If C code is one step up from assembly language, good Haskell code is one step down from poetry, or from a beautiful mathematical theorem.

— Mike Vanier

(cf. this poem)

”That's like cheating. It isn't even programming. You just tell it what to do and it does it.'” — My friend upon seeing some Haskell code

— Speck from The Haskell Sequence.

Archive