Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The GP's point was that "good" statically typed languages have type inference and indeed do not need to be told that 2 is an integer and "two" is a string. It is pretty orthogonal to the question of dynamic vs. static typing.

In C++:

    auto i = 2;
    auto s = "two";
Scala:

    val i = 2;
    val s = "two";
C#:

    var i = 2;
    var s = "two";
Rust:

    let i = 2;
    let s = two;
and so on. Note that these are not dynamically typed bindings - you cannot later assign a string to i, or an integer to s.

However, these are examples of local type inference where the compiler simply deduces the type of a variable binding based on the type of the bound expression (although Scala and Rust type inference is actually somewhat more general than that). Haskell, on the other hand, has global type inference where the compiler considers the whole program when assigning types to bindings that are not explicitly annotated. However, some arguably useful capabilities of a type system such as subtyping and implicit conversions make global type inference a much more difficult problem to solve.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: