Static typing
Static typing ( English static typing ) refers to a scheme of typing of programming languages .
With static typing, in contrast to dynamic typing, the data type of variables and other program blocks is already specified during compilation . This can be done by type inference or by explicit declaration . Static typing can be expanded with strong typing .
Advantages:
- Certain errors can already be detected at compile time and do not have to be checked at runtime . In this way, errors are found even in seldom used program parts that are often not run through during tests.
- The efficiency of programs is also increased by reducing the computational effort for type checks during runtime.
- Numerous optimizations depend on the information available at compile time. For example, static typing enables machine code to be inserted directly instead of a method or function call.
Disadvantage:
- In some cases, the types are only known at runtime; for languages with static typing, this usually means a certain amount of effort, since the type system has to be bypassed.
- The compilers are more complex because they require more analysis .
Examples
According to this definition, the following languages, for example, are statically typed:
Languages like PHP , Python , Ruby and JavaScript, on the other hand, are dynamically typed.
Alternative definition
An alternative definition of the term static typing considers type tests: A language is statically typed if and only if it does not have any dynamic type tests, i.e. those that happen at runtime. Otherwise they are called dynamically typed . According to this definition, Java, for example, would be dynamically typed.
See also
Individual evidence
- ↑ Data Types - The Rust Programming Language. Retrieved November 2, 2018 .