Theme
Primary Color
Lesson 4

Statically vs Dynamically Typed Languages

Compare.txt
Statically Typed Language Like [Rust, C, C++]
- Variables Types Are Static, Once You Declare It You Cannot Change
- Type Of A Variable Is Known At Compile Time "Do Type Checking At Compile-Time"
--- Have Better Performance At Run-Time Due To Not Needing To Check Types Dynamically
- Error Detected Earlier

Dynamically Typed Language Like [PHP, Python, JavaScript]
- Variables Types Are Dynamic, You Can Always Change It
- "Type Checking At Execution-Time"
- Error Can Be Detected After Execution
index.php
<?php
$num = 10;
$num = "Elzero";
echo $num;
main.js
// let num = 10;
// num = "Elzero";
// console.log(num);

let age = 30;

if (age > 30) {
  console.log("Good");
} else {
  console.log(age.repeat(3));
}
solve.py
# num = 10
# num = "Elzero"
# print(num)

age = 30
if (age > 30):
  print("Good")
else:
  print(age + "Bad")
index.ts
// let num = 10;
// num = "Elzero";
// console.log(num);

let age = 40;
if (age > 30) {
  console.log("Good");
} else {
  console.log(age.repeat(3));
}