👋 Dom Jackson

haskell just gets me

23rd october 2014

laptop on desk with code on screen
photo by the joshua aragon on unsplash

in my first year of university i studied a module called 'java programming' which began to teach me the concepts of programming. using java meant that we got to discover and play around with the object oriented programming paradigm. we learnt all the good stuff, including the three main pillars of oop; encapsulation, inheritance and polymorphism and the general gist of designing programs in terms of classes, interfaces and objects.

in my second year, however, we moved on and studied another module called 'advanced programming'. in this module, we were taught functional programming using haskell as the weapon of choice. now i'm not sure if it's haskell as a language, or functional programming as a whole, but it just gets me.

i should probably explain myself a little here. when i program, i tend to just try things by typing out some code that i think makes sense to me and at the same time i'm working it out in my head and then hoping it works. only a portion of the time the code works first time. on follows a process of me reading the errors and then changing the code or googling for an answer. writing tests while i write the implementation usually helps this process massively. but it still isn't foolproof.

however with haskell, i seem to write lines and lines of code that make sense to me as i type, and when i run it, it just works. my brain's way of thinking seems to fit perfectly with the way haskell works. meaning the portion of times that my code runs successfully first time jumps up through the roof.

i think the main thing, for me, is how other languages deal with data. i dread to think of the amount of time i must have wasted debugging my loops and nested loops around data structures. they can just be a real pain when you know exactly what you want to do but are having to instead figure out a sensible way of getting around the data. composing pure functions around data in the haskell way using techniques like recursion just seems so much more straightforward in my head.

so yeah, if you don't know what haskell is, or you've never tried it before and enjoy programming, i urge you to have a go. it may be a little different at start but it's well worth the ride. and if all it does is give you a greater appreciation for functional programming that you can then apply to your favourite language of choice, then that's also a win.

-dom