
Ask HN: Do you buy into types? - mdgrech23
Based on my own personal experience I can&#x27;t say I&#x27;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.
======
treve
If you ever had to do a large refactoring project, I would predict that you
either:

1\. 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.

------
PaulHoule
It is a discussion that has gone on forever in the industry without a
conclusion.

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.

------
mpweiher
It is true that there is at best very little evidence that code gets better.
(Some studies found very, very small positive effects, others found none, some
went the other way).

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.

~~~
PaulHoule
"The web" is an interesting one.

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.

~~~
mpweiher
You can certainly write specific sites using whatever you want. However, the
web as a whole is and has to be dynamically typed.

