3.3 Dynamic Typing != Weak Typing
In a statically typed language, we specify the types of variables, references, and so on at compile time—and many compilers insist that we do. Take C/C++ for example. We have to specify the variable type as a primitive type such as int or
double, or a specific class type. However, what if we cast the variable to a wrong type? Will the compiler stop us? No. What’s the fate of the program when we run? It depends. If we’re lucky, the program will crash. If not, it may wait until that important demo to crash or misbehave. Depending on how the memory is laid out, whether our call is polymorphic, and how the v-table (some languages like C++ maintain a method dispatch table with addresses of polymorphic methods—see ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access