Type checking and its types


Type checking is the process of checking proper data type i.e., constraints during program execution. It can be checked during runtime (dynamically typed language) or compile time (statically typed language).

Type checking ensure your code to certain guarantees. It helps in production environment by eliminating the bugs earlier.


There are two types of type checking.

  • Static type checking
  • Dynamic type checking

Static type checking

Static type checking is done at compile time. It checks every variable and constants to make sure they’re being used as per declared data type. This type of type checking helps programmer to caught errors early in the development cycle.

Some examples of statically typed languages include C, C++, Java, Fortran, Pascal, Scala etc.

Advantages:

  1. A large number of errors are caught earlier in the development phase.
  2. It removes complex error handling.
  3. It reduces a number of unit test.

Dynamic type checking

Dynamic type checking is done at run time. It provides less interruption every time you want to check your results of some change. In order to check the result correctly, it has to be able to determine the type of every value at run-time. Some examples of dynamically typed language include PHP, Python, Ruby etc.

Advantages:

  1. In this type of type checking, language need not to use type declaration.
  2. Programmers are free from data type declaration.

Trending Topics

Wordpress Social Share Plugin powered by Ultimatelysocial
Wordpress Social Share Plugin powered by Ultimatelysocial