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

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
Feature | Dynamic Typing | Static Typing | Strong Typing | Loose Typing |
When is type checked? | Runtime | Compile-time | Either, but strict | Either, but loose |
Can types change? | Yes | No | No (without conversion) | Yes (automatically) |
Needs declaration? | No | Yes | Depends | No |
Common Languages | Python, JS | Java, C | Java, Python | JS, PHP |
Subscribe to my newsletter
Read articles from Evelyn Oshomah directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
