# Static and Dynamic Typing

> When a language checks the type of each value, before the code runs or while it runs. What strong typing adds, and why the two are not the same.

**Course:** [Programming Languages](https://learn.benibix.com/learn/development-languages)  
**Time:** 12 min

**After this lesson you can:**

- Tell static typing from dynamic typing
- Explain what a strongly typed language refuses
- Place a language on both scales

## When a language checks the type of each value

Every language checks that values are used the right way, but not at the same moment. A statically typed language checks types before the program runs. A dynamically typed one checks them while it runs, at the line that uses the value. Java, C# and Go check first. Python, JavaScript and Ruby check as they go.

In a static language, the type is part of the code. You write int count = 0 in Java, and count can only ever hold a whole number. Try to put text in it, and the compiler refuses to build the program. The mistake is caught on your screen, before any user sees it.

In a dynamic language, a name can hold any type, and the type travels with the value. In Python, count = 0 and then count = "zero" is fine. The check happens only when a line tries to use the value, such as adding it to a number. A mistake shows up as an error at that line, perhaps weeks later.

Static types cost some typing up front and catch a whole class of bugs early. Editors can also use them to suggest names and spot mistakes as you type. Dynamic types make short programs quicker to write. That is why scripts are often dynamic, and big systems built by large teams are often static.

A separate question is how strict a language is. A strongly typed language will not quietly mix types. Python refuses "1" + 1 with a TypeError. A weakly typed language converts one value to make it work. JavaScript turns the 1 into text and gives "11", with no error at all.

So static or dynamic says when types are checked. Strong or weak says how strict the check is. Python is dynamic and strong. JavaScript is dynamic and weak. Java is static and strong. C is static, but it lets a letter be used as a number, so it counts as weak.

People often mix the two scales up and call Python weakly typed because it has no type names in the code. It is strongly typed. It just checks while it runs.

```python
count = 0
count = "zero"      # fine: Python is dynamically typed
print("1" + 1)      # TypeError: Python is strongly typed

# The same line in JavaScript gives "11", with no error.
```
A name can change type in Python. Mixing text and a number still fails, because Python will not guess.

![A grid of two questions. Across the top, checked before it runs (static) and checked while it runs (dynamic). Down the side, strong, which refuses to mix, and weak, which converts quietly. Java sits at static and strong, with an error before it starts. Python sits at dynamic and strong, with a TypeError when the line runs. C sits at static and weak. JavaScript sits at dynamic and weak, where "1" + 1 gives "11".](https://learn.benibix.com/diagrams/dev4-typing.svg)

### Example: Lucy's bug waits three weeks

Lucy's Python app stores an order count as text by mistake. Nothing breaks until, 3 weeks later, a monthly report adds the counts and crashes.

Her team's Java app has a similar field. There, the same mistake stopped the build on the day it was typed, and it was fixed in 5 minutes.

**Words in this lesson:** [Statically Typed Language](https://learn.benibix.com/term/development/statically-typed-language), [Dynamically Typed Language](https://learn.benibix.com/term/development/dynamically-typed-language), [Strongly Typed Language](https://learn.benibix.com/term/development/strongly-typed-language)

**Question:** Python has no type names in its code. Is it weakly typed?

**Answer:** No, it is dynamic but strong, so it refuses to mix types. Python checks types while it runs, which makes it dynamic. It also refuses "1" + 1 rather than guessing, which makes it strong.

---

Source: https://learn.benibix.com/learn/development-languages/static-and-dynamic-typing
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
