FeatureDynamicStatic
Type CheckingAt runtimeAt compile time
Variable typesDetermined when code runsDeclared before running
FlexibilityMore flexible, less boilerplateStricter, but safer
ErrorsMay fail at runtime (type errors)Type errors caught early (before running)
PerformanceUsually slowerUsually faster
ScopeBetter for fast, small personal projectsBetter for big projects that needs lots of collaboration
ExamplesPython, JavaScriptC++, ☕Java

Dynamic Typing

A language is dynamically typed if the type is associated with run-time values, and not named variables/fields/etc

  • You don’t declare variable types explicitly.
  • The type is inferred at runtime based on the assigned value.
  • Convenience and readability - easier to understand
  • The computer decides, so efficiency is low
  • Better suited

Static Typing

A language is statically typed if the type of a variable is known at compile time.

  • You explicitly declare variable types, or the compiler infers them at compile time.
  • Detailedness, lots of safety devices
  • Prevents mistakes