What Does Statically Typed Mean?
Statically typed is a programming language characteristic in which variable types are explicitly declared and thus are determined at compile time. This lets the compiler decide whether a given variable can perform the actions requested from it or not.
Static typing associates types with variables, not with values. Some examples of statically typed programming languages include:
- Haskell
- FORTRAN
- Java
- C
- C#
- C++
- Ada
- Jade
- Pascal
- ML
- Perl
- Scala
Techopedia Explains Statically Typed
In static typing, there is no need to perform additional checks during run time to confirm that an object can perform some actions. Statically typed programming languages perform type checking during the course of compilation rather than during run time, which makes programs written in these languages run much faster.
In addition, tooling and refactoring are better in statically typed languages since the tools can find out the variable types as the program is coded. This helps to instantly understand the parameters for a given function and also the methods available for a specific object. This makes the refactoring process much more straightforward as well.
With just a few exceptions, once a method or object is refactored, it is easy to immediately understand which other codes depend on it. However, this comes at a cost. With a few exceptions, statically typed languages call for additional annotations to notify the compiler regarding the intended objectives of the author.
When it comes to object structure, statically typed languages tend to be less flexible when compared to their dynamic counterparts. It is not possible to add fields and methods to a given object during run time. This can be complicated when handling less structured data; for instance, parsing JSON, XML or database queries leads to less-than-ideal object mappings.