DEV Community

Discussion on: Why learn... a statically typed language?

Collapse
 
n4bb12 profile image
Abraham Schilling

Which language(s) do you think make the best introduction to static typing?

I think TypeScript is really a great choice for this.

It has smart inference, can be configured to be less strict and you can always opt-out with "any" in case you need to.

It has many features that reduce verbosity, like "typeof" or "infer" to derive types from existing code.

Take for instance this snippet from above, I'd shorten it to:

const five = 5
const banana = "banana"

function add(n1: number, n2: number) {
    return n1 + n2
}

add(five, banana)

Now it looks almost like plain JS and produces the same error.