My Thoughts on Static Typing
“If you really want static typing, then go all the way and adopt a language that doesn’t allow nulls.”
Let’s break this down. What I mean is that people make the argument that “oh C# is better than Python because it has static typing and prevents a specific class of errors.” While that is true, C# still allows nulls and doesn’t require you to handle all cases in a switch statement. Compare that to a functional language like F# (not the purest choice), Haskel, or even a language like Rust. Those languages require you to handle all cases when pattern matching or they do not compile. You are forced to handle nulls, and if you want to do unsafe things, you have to explicitly acknowledge that is what you want to do. C# now allows you to have non-nullable reference types, which does enforce that. I haven’t seen that feature widely adopted. So as I see it, many languages like C#, Java, etc. don’t take the type checking and compiler to the level I feel would make it vastly superior to Python, especially if you start adding type hints to it.
This post isn’t intended to be negative. It is just a thought about the topic that I keep thinking about.
Thanks for reading,
If you enjoy the content then consider buying me a coffee.