static typing
A language rule that every variable has one fixed type, known when the program is compiled, so type mistakes are caught before it runs.
In more detail
The compiler checks every assignment and call, catching many bugs at build time instead of in production. A statically typed variable declared as a number can never hold text. Many statically typed languages still infer types, so you rarely have to write them yourself.
Examples
C# is statically typed.Go: var retries int64 = 3Related terms
- nominal typing — A type system in which two types are compatible only if one is declared to inherit or implement the other, not merely because they have the same members.
- var — The C# keyword that asks the compiler to infer a local variable's type from its initial value and then fix it there.
- C# — A statically typed, object-oriented programming language from Microsoft and the main language used to write .NET applications.
- type inference — The compiler working out a type from the code itself, so you do not have to write it out by hand.
- compiler — A program that translates source code a person wrote into a form a machine or runtime can execute, checking it for errors on the way.
- type conversion — Turning a value of one type into another, such as the string "23" into the integer 23.
Taught in
- The C# Language: Types, Variables, and Flow Control — Modern .NET Core, C# & Enterprise Microservices
- Collections, Generics, and LINQ — Modern .NET Core, C# & Enterprise Microservices
- Variables, Typing, and Zero Values — Concurrent Systems Programming with Go
- Type Assertions and the Empty Interface — Concurrent Systems Programming with Go