Hacker News new | ask | show | jobs
by andybak 1704 days ago
Having spent a decade with Python and more recently a few years with C# I still can't quite put my feelings into words but here's an attempt:

"The benefits of explicit typing are obvious and clear but they downsides are subtle and hard to communicate"

I still think typing in general is a net win but I'm not sure whether static typing is. You find yourself writing code that just wouldn't be neccesary in a dynamic language - and I don't just mean the direct code you write to declare and cast types. There are more subtle costs.

I need to spend time with a good type inference in a language with modern typing and dynamic features to sort out how I feel about this.

1 comments

Types are effectively assertions about the values they represent, and statically-typed code constitutes proofs that the assertions actually hold at runtime. The static typing forces you to be sufficiently rigorous in those proofs, which may require additional code as you mention. Without static typing, one has to rely on the "proofs" in one’s head to be correct (which humans aren’t really good at), instead of having the compiler double-check one’s reasoning.
I think this falls into the category of "The benefits of explicit typing are obvious and clear". It's the other side of the equation that I'm intrigued by and struggling most to formulate.