General Coding Flashcards
Statically Typed Languages
The type of variable is known at compile time.
- You must declare the type of each variable explicitly and the type info is checked during compilation
Ex: Java, C++, C#, Swift, Rust, Go
Pros: Static Typed Languages
- Type checking: reduces runtime errors and improves code reliability
- Performance: Leads to optimizations during compilation
- Clarity
Dynamically Typed Languages
The type of variable is determined at runtime.
- You don’t need to declare types explicitly. The language inverse the type based on value assigned
Ex: Python, JS, Ruby
Pros: Dynamic Typed Languages
- Flexibility: variable types can at runtime
- Less boilerplate
- Ease of use
Weakly Typed Languages
More flexible approach to type conversions, often performing implicit conversions between types
Languages: JS, PHP
Ex: implicit conversion of number to string
Let number = 10
let text = “the number is “ + number
Compile Time
A programs source code is translated into machine code/executable code
- Before the program is executed
Compiler checks for
1. Syntax and type checking which must be resolved before the program can run
2. Optimization
3. Code generation (executable code or byte code from the source code which is then ready to be executed by computer)
Runtime
When a compiled program is actually executed by the computer
- When a programs code is run and the program interacts with user
Key Characteristics
1. Programs instructions are executed by the CPU
2. Dynamic behavior occurs like memory allocation, dynamic typing, user input handling. Errors not caught at compile time are found here
Source file
Contains human readable code written in a programming language
- The starting point for creating executable programs or other outputs