The following is one of a series of bite-sized lessons on useful programming terminology. Understanding these things can eventually help you learn new languages very quickly by making educated assumptions about how they work.
You may have heard of the concept of strongly or weakly typed programming languages. Although these concepts are not rigidly defined, the following is a mostly agreed upon definition of the differences between them.
Strongly typed
- must define the type (integer, string, float, etc.)
- For example, in C++ you declare a type inline or before you use a variable int myInteger = 1;
- may produce errors if the data passed is not exactly, or close to the expected type
int myInteger = “string”; //ERROR
Weakly typed
(also called ‘dynamically typed’, 'loosely-typed' or 'type-fluid')
- don’t need to define type
- For example, in Javascript
- may perform implicit type conversions
- more likely to produce undefined behavior than errors, but variables are not limited to a single data-type in their lifecycle
var myVariable = 5;
myVariable = “string”;