Trusted answers to developer questions

Statically v. dynamically v. strongly v. weakly typed languages

Get the Learn to Code Starter Pack

Break into tech with the logic & computer science skills you’d learn in a bootcamp or university — at a fraction of the cost. Educative's hand-on curriculum is perfect for new learners hoping to launch a career.

Statically vs. dynamically typed

Statically-typed programming languages do type checking (i.e., the process of verifying and enforcing the constraints of types on values) at compile-time, whereas dynamically-typed languages do type checks at runtime.

Examples

Statically-typed: C, C++, Java.

Dynamically-typed: Perl, Ruby, Python, PHP, JavaScript.

The Language Cloud. Image Source : Mayank Bhatnagar
The Language Cloud. Image Source : Mayank Bhatnagar

Strongly vs. weakly typed

Weakly-typed languages make conversions between unrelated types implicitly; whereas, strongly-typed languages don’t allow implicit conversions between unrelated types.

Python is a strongly-typed language:

var = 21; #type assigned as int at runtime.
var = var + "dot"; #type-error, string and int cannot be concatenated.
print(var);

JavaScript is a weakly-typed language:

value = 21;
value = value + "dot";
console.log(value);
/*
This code will run without any error. As Javascript
is a weakly-typed language, it allows implicit conversion
between unrelated types.
*/

RELATED TAGS

strongly-typed
weakly-typed
statically-typed
dynamically-typed
Did you find this helpful?