Saturday, October 13, 2018

Haskell by Day

I had played around with Clojure for a couple of years by 2015. I wanted to use it for more than just a toy-project, and when we had to build a data pipeline for my employer, I was more than happy to give it a try.
I hired a developer for our team who had more serious functional programming background than I had. He started doing interesting things with our code base like separating out functions based on purity and using currying like no one I had seen before.

I asked him, how he knows so much about FP. His answer was plain and simple: "I've been learning Haskell." Oh. I have always thought Haskell is this far-out, esoteric, academic language that no one uses. I realized he knew more Clojure just by learning Haskell. Then he showed me Elm and I was blown away. (Elm has its roots in Haskell, it's a similar ML language.)

A couple of months later I watched Chad Fowler's talk about his adventures at WunderList in which he talked about a routing application that they wrote in less than fifty (50) lines of Haskell. It never went done and was blazing fast. His message (the one that I picked up anyway) was "Haskell, Haskell, learn Haskell".

I started digging into the language by following the examples from the book Learn You a Haskell for Great Good. It was an easy read, I was cruising through the examples in GHCi (REPL). Then I stopped looking at the language for about 2-3 months as something came up. I went back to it and was shocked to realize that I did not remember anything. Zero. What the heck is this weird syntax (x:xs)?

I realized reading the book and following the examples in a REPL was not enough, I had to keep coming back to them, and most importantly, practice them. The author of the HaskellProgramming book, Chris Allen had a good talk on how to learn Haskell in less than five years. The message is simple: learn by doing. And keep doing it. This is how my little learning project haskell-katas was born. I needed something I could come back to and practice with. It had mostly helped, but I was still confused by its error messages and type classes, which made more sense by more reading and practice.

I liked my employer, we worked on some interesting problems, but I wanted to try myself on the job market, see how marketable my skills are. At one point I had to solve a Tetris game challenge for a company as a take-home exercise. I knew they were interested in folks with functional thinking. I had no intention working on that problem in Ruby/Python/JavaScript, but I thought it would be interesting to come up with a solution in Haskell. They said I could do it in Haskell and I jumped on the task. I began working on it on a Friday afternoon, played with the problem for an hour or two, I tried to see how I could represent the data with Algebraic Data Types and maybe map the different shapes on the board. When that worked, I knew I'll be able to submit a solution. I worked on it over the weekend and by Monday morning I had the solution working. I submitted my code 3 days early and got invited for an in-person interview. This was the moment I realized I might be able to find a job working with Haskell.

Finding a role with Haskell got more important to me, as the one or two hours here and there in the evening or weekends will never be enough to learn the language fully. I found a job posting on StackOverflow that listed Haskell as a requirement, here in Chicago. I applied, and after a few rounds of interviews I received an offer from them which I accepted.

We are working on a student loan solution for the UK market. Haskell is the brain of the application, all the different calculation models and rules are coded in it. I was intrigued to work for the only company in Chicago that uses Haskell. I started my job about a month ago and boy, it's been an adventure. I feel very slow sometimes, but more productive when I submit a change that makes the code a bit easier to test. For example, I had to dive into a couple of days of learning just to interact with JSON. All in all, I am super happy that I can do something by day that I learned at night, and with this new role I can take my functional programming skills to a new level.

You might ask: How about Ruby? Am I still using? Oh yeah, we have an API app in Rails, plus I started mentoring our intern by pairing with him on different challenges in Ruby a couple of times a week. We also have a fairly significant code base in Python that our data scientists put together to test the Haskell component. I enjoy going into there and help the team make the code better.

The future is polyglot. Follow your heart and work with the language you want to learn. That's the only way to get real deep into it!

No comments:

Post a Comment