A few months ago someone was desperately trying to get me to learn Haskell. I really wanted to, but kept putting it off. So yesterday I installed ghc a Haskell compiler and started playing. I should have done this ages ago!
So after that intro, its been a few weeks since my last post. Various things have happened, including me developing the dreaded coder’s pinky (painful wrists). So for a while there I was a bit worried and started teaching my computer how to code with my voice. Its doable, but for now simply replacing IDE shortcuts with voice commands, this is already a huge win… ok, back to Haskell.
Enter Haskell. I started noticing notation in Swift that I’ve seen before in a programming Slack channel. It looked similar to Haskell and I got curious. Turns out that Swift was very much inspired by Haskell and other languages. Thats all I needed to know to finally give Haskell a try.
I started playing with Haskell and my mind was blown. Functional programming is very different to my OOP thinking. Favouring struct over class, everything immutable, list comprehension, infinite lists… this stuff is crazy. But as you play around with it things slowly start to make sense and you can’t help but wanting to learn more.
Back to Swift
After playing only a little bit with Haskell and looking at Swift code again, things are making a whole lot more sense. I realised that I can write functions in Swift without even using func structures, operator overloading, filter, map, reduce, but also writing my own generic functions (not so comfortable with that yet, but getting there).
Functional programming is not the be all end all (IMHO), but it sure helps a whole lot if you’re wanting a deeper and better understanding of what is possible with Swift (and I’m not talking iOS or OSX dev here, I’m talking about the language itself).
If you’re learning Swift or already quite comfortable with it, do yourself a favour, head over to “Learn You a Haskell”. Its a nice guide to help you learn Haskell (despite the comical name).