Learning Kotlin with Advent of Code 2017

December 29th 2017 Advent of Code Kotlin

It's December again and for the third year in a row I've spent a significant amount of time solving Advent of Code programming challenges. To make it even more interesting, I decided to write the solutions in Kotlin - a programming language I heard a lot of good things about, but had no prior experience in.

Of course, these programming challenges were not enough to fully learn Kotlin, but I got a good glimpse at it and I really like what I saw. It's the first language with strictly enforced null safety that I've used and it didn't take me long to get used to it and appreciate it. I'm looking forward to the upcoming implementation in C# even more now.

Kotlin also favors immutable data structures and functional approach to programming, especially if you're using IntelliJ IDEA. With default settings, it underlines all mutable variables and provides many inspections, which encourage you to use the Kotlin Standard Library more. Although I applied the suggested fixes unless they made the code too cryptic for me, it would still require a much more focused effort to solve all the puzzles in a truly functional manner.

I made my code repository public again. Feel free to check it out if you're curious how I solved the puzzles and how my Kotlin code looks like. I'm pretty sure it's far from idiomatic, but it was learning experience and I can leave with that. I know that I'm still far from fluent in Kotlin, but that will probably have to wait until I get to work on a new project, where I can use it full time. I'd gladly pick it instead of Java if I had a choice.

The Advent of Code puzzles themselves in general seemed easier than last year to me. I also found them more varied and I really enjoyed solving them. Although it's already too late for a competitive approach, I can still recommend them, if you're just starting to learn programming, if you want to try a new programming language or just want some problem solving fun. I know I have already marked Dec 1st 2018 on my calendar, hoping to get a new set of problems to solve.

Creative Commons License