Haskell actually does change the way you think

Last year I started trying to learn Haskell. There have been many ups and downs, but my only Haskell project so far is on hold while I work on other things. I’m not sure yet if I’d choose to use Haskell in production. The problems I had (and the time it’s taken so far) writing a simple server make me think twice, but that’s a story for another blog post.

The thing is, the whole reason I decided to learn Haskell were the many reports that it made me you think differently. As much as I like D, learning it was easy and essentially I’m using it as a better C++. There are things I routinely do in D that I wouldn’t have thought of or bother in C++ because they’re easier. But it’s not really changed my brain.

I didn’t think Haskell had either, until I started thinking of solutions to problems I was having in D in Haskell ways. I’m currently working on a build system, and since the configuration language is D, it has to be compiled. So I have interesting problems to solve with regards to what runs when: compile-time or run-time. Next thing I know I’m thinking of lazy evaluation, thunks, and the IO monad. Some things aren’t possible to be evaluated at compile-time in D. So I replaced a value with a function that when run (i.e. at run-time) would produce that value. And (modulo current CTFE limitations)… it works! I’m even thinking of making a wrapper type that composes nicely… (sound familiar?)

So, thanks Haskell. You made my head hurt more than anything I’ve tried learning since Physics, but apparently you’ve made me a better programmer.

Advertisement
Tagged , , , , , ,

3 thoughts on “Haskell actually does change the way you think

  1. oderwat says:

    Yes, that sounds like my experience. I did not get Haskell to work for me 😦 But now I constantly see the cry for FP inspired solutions in my daily code. Even so much that I feel bad about not using it. This is one of the reasons I am currently adopting Nim (nim-lang.org) as our second main development language (after Rust failed me for taking to much mental overhead). Nim is not even advertising FP features but it has an irresistible mixture of: meta-programming, static type system, algebraic types, “type classes” + operator overloading, first class functions, closures, immutable and pure declarations and a lot more I still explore. This gives me the tools to use FP in something which I am comfortable with for every day work.

  2. Sander Rossel says:

    Interesting. Been looking into functional programming a bit lately, but didn’t do anything serious yet. I still have a course on Haskell which I plan on starting any time soon. I’m mainly a C# developer, so I hope I’ll see the same paradigm shift as you have!

  3. […] the mental warping caused by me learning Haskell kicked in. What if… I add types to everything? They won’t even really do anything, […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: