Static vs. Dynamic
This refers to how the programming language manages variables. Static typing is when types are checked at compilation and dynamic is when types are checked at runtime.
Strong vs. Weak
This refers to how types can be converted. In strongly typed systems, only explicit conversions are allowed. In weakly typed systems, implicit conversions are okay. Or another way, in a strongly typed system, "you cannot work around or subvert the type system".
For instance, in Ruby or TypeScript, if you try and run
"1" + 1, or even
"1" + , and it will implicitly figure out "what you wanted".
Duck typing is where instead of determining what types are allowed or disallowed to be input in a given class or function, "the set of methods and properties determine the valid semantics".
For instance, in Python or Ruby, if you wanted to handle either a single name or a list of names in a duck typing system, you could use conditionals for "if input is a string" and "else if input is a list", and then manage the types that way. In a non-duck typing system, if the function expected a string and you passed in a list, the function would throw an error because it would be expecting a certain type for the input.
Last modified: 202206101419