Advent of Code 2019 - (re)learning OCaml
I’ve been programming in Python (and, when I can’t avoid it, JavaScript) for the past several years. Before that, I was a Java certified programmer and before that, I committed some atrocious C/C++ code. And when I say ‘committed’, I don’t mean in the Git sense…
But before all this, before I typed my first public static void main(String[] args)
or (shudder) malloc
, I learned to program in Caml Light (OCaml’s predecessor — this was in 1997).
The fact that I learned programming with Caml rather than say, Pascal or C, is due to the strong influence of the INRIA (the research institute behind Caml) in the French higher education system.
And that’s a good thing! It makes much more sense to learn the basic concepts in a high-level, functional language than by messing with memory allocation. malloc
will come soon enough.
Fast forward twenty years. Hacker News seems to put a lot of stock in this Functional Programming thing, and who am I to resist peer pressure? After reading a few books on the topic, I still don’t understand what a monad is but I’m yearning for curried functions and immutability. So I decide to pick up OCaml, hoping that I haven’t forgotten too much from my Caml Light days (spoiler: I’ve forgotten everything. Especially the messy parts).
What better way to learn a new language than by writing short, easy programs? That’s how I learned Python, by working on Project Euler problems after reading this xkcd comic (check the alt-text — Randall is talking about the first Project Euler problems). So I’m currently working my way through the Advent of Code, and since I shouldn’t be the only one to suffer through this, I plan (hope) (well, I think it’d be cool) (okay I’ll probably give up in less than a week) to talk you through how that’s going.
Next up, how ridiculously long it took me to get through the first day. If you’d like to follow along, the puzzles are here and my code is here. Stay tuned.