Type system#Static type-checking

Static typing ( english static typing ) refers to a scheme of typing of programming languages.

In static typing, in contrast to dynamic typing, the data type of variables and other program blocks is determined at compile time. This can be done by inference or by explicit declaration. Static typing can be expanded through strong typing.

Advantages:

  • Some faults can be detected already at compile time and do not need to be checked at runtime. Thus, errors in seldom-used parts of the program that are often not executed in tests found.
  • The effectiveness of programs is also increased by reducing the computational effort for type checks at run time.
  • Numerous optimizations depend on the existing compile-time information. To allow static typing, for example, to directly insert machine code instead of a method or function call.

Cons:

  • Some of the types are only known at run time, in languages ​​with static typing this then usually means a certain amount of effort, since the type system must be bypassed.
  • The compilers are more complicated, because there arises more effort for analysis.

Examples

By this definition, for example, the following languages ​​are statically typed:

  • Java
  • C #
  • Pascal
  • ML
  • Scala
  • D

Languages ​​such as PHP and Ruby, however, are dynamically typed.

Alternative definition

An alternative definition of static typing considered Type tests: A language is statically typed if and only if it has no dynamic type tests, ie those that occur at runtime. Otherwise, they are called dynamically typed.

According to this definition would be Java, for example, dynamically typed.

746347
de