2 ms·
without all the "Foobar foobar = new Foobar()" crap Exactly. You will spend less time restating things the compiler should be able to figure out by itself. Va
by silentbicycle 18y ago
without all the "Foobar foobar = new Foobar()" crap
Exactly. You will spend less time restating things the compiler should be able to figure out by itself.
Vanilla H-M type inference (as in SML and OCaml) requires you to write code which the type inference can completely resolve, however. This tends to lead to compilers that seem really strict until you learn to work with rather than against them, but are excellent at catching several entire categories of bugs at compile-time. The type inference also works with complicated higher-order functions (where the full type signature might be several lines long!), not just trivial examples, and rapidly determines what code will be affected by any small changes, but it can add a little more friction to rapidly changing code, and every once in a while you will still need to do things to appease it.
Whether or not this is a net plus or minus depends on your programming style, the project, etc. (Dynamically-typed languages don't need type annotations either, but they have different trade-offs.)