Programming Languages

Execution models

Execution models for programming languages fall into the following categories (Conference 2021) (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. (Conference 2021) (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.

Thoughts

TODO Following template for short notes on programming languages: Hello world example containing sing and multi-line comment examples, Common types (includes pointers), variables, operators over them, Control flow (if statements, switch statements, loops), functions (normal functions, lambdas), paradigm specific details (e.g. classes or typeclasses, multiple inheritance in C++ etc), language specific details (e.g. goroutines and channels in Go etc). Specific libraries, including the standard libraries should go into their own nodes, with parentheses for context, e.g. Numpy (Python).

Author: Nazaal

Created: 2022-03-13 Sun 21:44

Validate