Advent of Code 2024 in F#
As part of my functional programming studies, I decided to do this year’s Advent of Code (AoC) in F#. (I actually started by solving each puzzle in both Ruby and F#, but have gravitated to F#. I’ll probably rotate back to Ruby later.) I’m still a newbie to functional-style thinking, so some solutions take a bit of time to work out, but I’m enjoying it and learning a lot.
Though I did so at first, I’m not keeping up with the AoC daily schedule so that I can take my time to learn properly and polish my code (I enjoy refactoring) a bit more than I would otherwise. The point—for me, at least—is to learn, not just blaze through as quickly as possible. Plus, it’s an annual event, so there’s plenty of time to finish this year’s puzzles (though I’m unsure that I’ll attempt all of them).
I think my solution for Day 6 was a bit of a turning point for me. After I finished the code, I honestly just couldn’t stop looking at it for a while. Given how new I am to F#, I doubt that it’s particularly good or idiomatic F# code, but it felt immensely satisfying to write and, honestly, even read over. I’ve never written code quite like this, and I’ve found there’s a certain beauty and efficiency in this style of programming.
After comparing my solution to others in more imperative languages, I think I also gained more understanding of the saying that functional programming involves writing code that explains what you want to do, not how to do it.
F#, too, feels very pragmatic—functional-first, but open to OOP and mutation when its best. I’m really enjoying my time with it. I also think the principles I’m learning are helping me to write better Ruby code at work too, which is a nice bonus.
I’m decently satisfied with my progress thus far, but I still have a lot to learn, so we’ll see how things develop.