How I learned to love static types

Last year, I took a shot at doing advent of code in Lua. Because text is a universal interface, AoC provides inputs as text files that need to be parsed. when using a dynamically typed programming language like Lua, this can create issues when trying to compare values if you don't explicitly call type casting.

In one of the problems, I needed to compare two numbers on the input, which were space-seperated. I began experiencing a bug where some comparisons weren't evaluating "properly"; the case I remember was 10 < 9 was evaluating to "true." It took the better part of an hour for me to debug this - the issue was the 10 was actually "10", and the 9 was actually "9", and for some reason the string "10" is less than "9" in Lua. It was especially a pain because I was debugging with print statements - it's exceptionally difficult to see the difference between 10 and "10" in a terminal on it's own line.

I ended up peppering the code of my dynamic language with explicit type casting. And now, I prefer to have a language that will check this stuff at compile time - it's a bit of up-front work, but it pays dividends in preventing errors down the line.

I'm doing work in Python for one of my classes now. I do admit, it's very fast to work in; but I feel that's simply trading drafting time for debugging time. And having the compiler catch errors gives me an exact place to look, and specific error to fix, which is much faster to solve than searching for a bug from runtime.