DEV Community


Discussion on: Convince me that types are awesome

andrewbastin profile image
Andrew Bastin

Well, the first argument for types is that it basically acts as documentation, you can expect certain fields to be present and know what they are exactly represented as.

For example, Dates can be represented as a single number (unix epoch usually) or as a complex object with properties, with static types you don't just hope you get the certain kind of value out, instead, you know you get certain kind of values out.

One argument against types is the added verbosity, but I honestly think it isn't that big of a deal with like modern languages like typescript offering the magic that is type inference.

I kinda believe that stricter the type system becomes, the less chance there is for errors (I really love the null safety Kotlin provides over the inferred strict type system) and more it is difficult to express errors in code, the more awesome the language...

Another awesome feature strict type systems provide, is the amazing static code analysis it gives you. Since the compiler knows what types are flowing, it can suggest code completions and produce better compile time errors...