3 ms·
I think the usefulness of type annotations is directly related to whether you are using classes. In JavaScript or PHP, it’s usually easy to figure out if somet
by zeroimpl 6y ago
I think the usefulness of type annotations is directly related to whether you are using classes.
In JavaScript or PHP, it’s usually easy to figure out if something is meant to be an int, string, array or object (yes we’ve probably all done “1”+1=>”11” before, but it’s very rare).
But if you are using classes, it’s very useful to distinguish at coding time which exact class an object is. Often you’ll end up with multiple classes with similar sets of properties, and it’s imperative to know which one is being used so you call the right methods.