[Avg. reading time: 3 minutes]

Strongly Typed vs Weakly Typed

Strongly Typed

  • Strongly typed languages do not allow implicit conversion between unrelated types

  • Operations on incompatible types require explicit conversion

  • Strong typing is about type safety, not when types are checked

  • Strong vs weak typing is independent of static vs dynamic typing

  • A language can be dynamically typed and still strongly typed Example: Python is strongly typed

#Python

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

Weakly Typed

  • Weakly typed languages allow implicit conversions between unrelated types
  • The runtime guesses what you meant and proceeds
  • This can be convenient and dangerous

Example: JavaScript is weakly typed

/*
As Javascript is a weakly-typed language, it allows implicit conversion
between unrelated types.
*/

a = 21;             
a = a + "dot";
console.log(a);
  • JavaScript silently converts 21 to “21”
  • Result is “21dot”
  • No error, no warning

#strongly #weakly #python #javascriptVer 2.0.8

Last change: 2026-01-28