Static Typing
Read an interesting piece today about static typing. https://labs.ig.com/static-typing-promise. Color me surprised. Although these results are far from conclusive, the data given is enough to cast doubt on the idea that static typing will definitively produce less buggy code. It does make sense that a language with a wider syntax and more features will produce more unintended combinations of logic, and, more unexpected behavior. That’s not an answer many people will like to hear, and I think that’s the point of what the author is trying to say. Dynamic typing has become a sort of scapegoat for project managers and code reviewers to help explain away faults and give people a sense of security that may be unfounded. There is no perfect recipe for producing consistent logic. Make it readable, easy to refactor, and performant enough to get the job done. Absolutes are rarely correct in life or in process. All that being said, Static Typing does provide an extra safety check that does generally lead to safer code or force more correct groupthink among collaborators of differing skillsets. So yes, I’m contradicting what I just said prior. Among highly experienced programmers, Static Typing can seem like a cumbersome redundancy, and if you have an insanely optimised JIT like V8, it becomes unecessary. Yes, Typescript is useful and all, but it’s just attacking the same issue with developer experience. The real benefits of Static Typing are for high performance, low overhead runtimes that are AOT compiled. Rob Pike said it best when he mentioned that general purpose programming languages should differentiate themselves by not all becoming similar languages with similar feature sets. JITs work well with Dynamic Languages, AOT languages are best if they’re implictly or statically typed.
# set the compile-time type
a = 0.as(Int32|Nil|String)
typeof(a) # => Int32 | Nil | StringGuess the language….and why does every language doc have to use a unique name for the exact same concept as used in another langauge? Can we all agree on Sum Typing or Union Typing, instead of both?