-
Notifications
You must be signed in to change notification settings - Fork 0
type systems
Jorge Estanislao Barsoba edited this page Nov 26, 2021
·
1 revision
-
Type-checking is answering a question about type equivalence, e.g.
x = y, "Is the value thatxholds equivalent to whatywants to hold?" - In Static languages (aka "strong-typed"), type-checking is performed at compile time; e.g. C#, TypeScript
- In Dynamic languages (aka "weak-typed"), type-checking is performed at runtime; e.g. JavaScript
- In *Nominal languages, *everything is about what is the name of your class; e.g. In Java,
myCaris considered aCaronly if its class is namedCar - *Structural languages just care about shape; e.g. In TypeScript,
myCaris considered aCarif it has the same properties thanCarand its member's types can hold -
Duck typing: When the language passes the "duck test", it's considered a duck-typed lang, like JavaScript; Duck-typed lang = Dynamic + Structural typed lang
If it looks like a duck, swims like a duck, and quacks like a duck, then it probably is a duck