Programming Languages
Execution models
Execution models for programming languages fall into the following categories (, ) (3:24).
- Interpreted source code, where source code is parsed into an Abstract Syntax Tree (AST) and interpreted on the fly. E.g. Python, Ruby, Javascript. Could have Just-In-Time (JIT) Compilation which can improve speed.
- Intepreted bytecode, where the source code is converted to bytecode which is run on a Virtual Machine (VM). E.g. Java, C#, Elixir.
- Compiled to binary. E.g. Swift, Go,
- LLVM compiled to binary, E.g. C++, Rust.
Memory management
- Individual allocation and deallocation. E.g. C++, Rust.
- Tracing garbage collection. This however results in garbage collection pauses, where the program locks up until it does garbage collection. E.g. Go, Javascript, Haskell.
- Automatic Reference Counting (ARC). This does not result in garbage collection pauses but introduces extra overheard. E.g. Python, Swift.
Effects
- A program has side-effects if this modifies state that is not meant to be the return value of it.
Programming Optimization
Compiler Optimization
- Allocating things on the heap, referred to as boxing, is a lot slower than allocating things on a stack or in registers. E.g. Numbers are boxed in Python, where packages like Numpy exist (, ) (4:30).
- To reduce the overhead of ARC, one can use static reference counting where runtime reference checks are reduced based on compile time reference checks.