Static and strong typing are often confused and used interchangeably. However, they describe two different properties of a programming language.
A statically typed language assumes that all variables must have either a manifestly declared data type (like in Fortran or C) or a data type inferred from their use (like in Julia, Nim, or Rust) at compile time. The opposite of static typing is dynamic typing, where the types of all variables are evaluated at runtime. Python, JavaScript, and Lisp are a few examples of dynamically typed languages. Static versus dynamic typing is thus about when (at compile time or runtime) the types of variables and expressions are determined.
Strong typing refers to the level of type checking that’s done when combining variables of different types in expressions, or when passing an argument of one type to a function that expects another type. For example, Fortran allows type coercion, or so-called mixed-mode arithmetic (see section 5.2.2), where lower numeric types such as integers are promoted to real or complex. On the other hand, passing an argument of one type to a procedure that expects another is not allowed. This very property makes Fortran a strongly typed language. The opposite of strong typing is weak (or loose) typing. JavaScript is a typical example of a weakly typed language, since you can pass any variable to any function.
It’s worth noting that whereas static and dynamic typing are clearly defined and distinct, the difference between strong and weak typing is more fuzzy. I give a couple of examples in table 9.2.
Table 9.2 Examples of languages and their type systems
Many other languages would fit in one of the cells in this table. For simplicity, I include only the characteristic languages that a scientist or engineer is likely to have in their arsenal.
To be honest, you don’t need generic procedures and custom operators to survive as a Fortran developer. However, they’ll make your code easier to understand, use, and extend. This is aligned with our case for functions, modules, or derived types. Although none of these language elements are absolutely necessary to solve any programming problem, they allow you to design elegant solutions to difficult problems.