Differences Between Dynamic, Static, Strongly, and Loosely typed Programming Languages

Evelyn OshomahEvelyn Oshomah
3 min read

When diving into the world of programming, you’ll often hear phrases like “statically typed”, “dynamically typed”, “strongly typed”, and “loosely typed”. These terms describe how a language handles variables and data types and understanding them can save you from a lot of debugging headaches.

1. Dynamic Typing

In dynamically typed languages, you don’t need to declare the type of a variable. The type is decided at runtime. That is, while the program is running. You just assign a value, and the language figures out the type automatically. You can even change the type later!

Examples of Dynamically Typed Languages:

  • Python

  • JavaScript

  • Ruby

  • PHP

Example (Python):

pythonCopyEditx = 5 # x is an integer

x = "hello" # now x is a string!


2. Static Typing

In statically typed languages, you must declare the type of a variable before using it, and it can’t change unless you re-declare it. The type is checked at compile-time. This can help catch errors early.

Example (Java):

javaCopyEditint x = 5;

x = "hello"; // ❌ Error: incompatible types

Examples of Statically Typed Languages:

  • Java

  • C

  • C++

  • TypeScript (a statically typed superset of JavaScript)


3. Strong Typing

A strongly typed language does not let you mix types freely. You have to explicitly convert between incompatible types. These languages protect you from accidental type mistakes. If something doesn’t match, it won’t work unless you convert it.

Example (Python):

pythonCopyEditx = "5" y = 2

z = x + y # ❌ Error: can’t add string and integer

You’d have to convert it like this:

pythonCopyEditz = int(x) + y # ✅ 7

Examples of Strongly Typed Languages:

  • Python

  • Java

  • Ruby


4. Loosely Typing (Weak Typing)

Loosely typed (or weakly typed) languages automatically convert between types when needed—even if you didn’t ask for it. They’re more flexible, but can sometimes behave in unexpected ways.

Example (JavaScript):

javascriptCopyEditlet x = "5";

let y = 2;

let z = x + y; // ➡️ "52" (string + number = string)

Examples of Loosely Typed Languages:

  • JavaScript

  • PHP

  • Perl


🔁 Summary Table

FeatureDynamic TypingStatic TypingStrong TypingLoose Typing
When is type checked?RuntimeCompile-timeEither, but strictEither, but loose
Can types change?YesNoNo (without conversion)Yes (automatically)
Needs declaration?NoYesDependsNo
Common LanguagesPython, JSJava, CJava, PythonJS, PHP
1
Subscribe to my newsletter

Read articles from Evelyn Oshomah directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Evelyn Oshomah
Evelyn Oshomah