Ask HN: Do you buy into types?
Based on my own personal experience I can't say I'm sold on the idea that typed languages or even optionally typed languages lead to any metric of measurably better code yet I continue to see people types. What are you thoughts.
5 comments
[ 5.8 ms ] story [ 19.5 ms ] thread1. Had great typing 2. Had very comprehensive automated (unit) testing 3. Had a very difficult time
If you are tremendously diligent in writing tests for everything, the additional benefit of typing (in language where it's optional) is lower. The biggest advantage that typing offers in those scenarios is that there's a large amount of tests that you no longer need to write.
Ultimately with static typing and testing you test for the contract of your code and static typing is much faster.
If you are just thinking of adding typescript to an existing javascript application, this benefit will not be immediately obvious. Using typescript will over time change how you write code, and when you get to that point it will be better, I guarantee it.
However, the documentation effect is well-supported, and also something I find to be true anecdotally: if you have a library or code-base that you need to figure out, the types really help.
On the other hand, it is unclear whether very large software systems such as the web would be possible as statically typed systems.
I think web browsers are overwhelming implemented in systems languages, but people often write other clients in scripting languages. Javascript is the dominant client-side scripting language but many people like Typescript, GWT, Dart and things like that.
You certainly can write dynamic web sites in a systems language, but almost always people use a scripting language like Perl, PHP, Python, Cold Fusion, etc. Java may be the exception that "proves the rule" but Java tends to have escape hatches for compile-time binding such as Spring.
Certainly a strongly typed language can give better performance. As a Pythoner the thing I like the best about optional types is better completion in the IDE.
I think we've "agreed to disagree" on this issue so there are "scripting languages" with less explict typing and "systems programming languages" with more explicit typing. In fact, one view of the optimal environment for applications work is to combine a scripting and a systems language; say Python and C or Clojure and Java.