Programming Languages - Compilers and Runtimes

Last Updated: 2023-02-23
  • runtime: some languages have big runtimes, or full virtual machines, like Java (JVM); some languages have small runtimes, just a library to provide critical functions, like libc for C, and runtime lib for Go.
  • GC refers to runtime GC; Swift has Automatic Reference Counting but at the compile time.
  • In Go, GC is provided by the runtime library; while in Java / JavaScript, GC is provided by the virtual machine (JVM / V8).


  • JVM (Java Virtual Machine): Java, Scala, Groovy, Kotlin
    • Why Groovy is more Popular than Scala: Groovy is 100% Java compatible because it IS Java; take any Java class, change the extension to from '.java' to '.groovy' and it WILL compile (NOTE: one must have groovy library installed).
  • CLR (Common Language Runtime): C#
  • HHVM (HipHop Virtual Machine): PHP/Hack. HHVM JIT compilation, executed PHP or Hack code is first transformed into intermediate HipHop bytecode (HHBC), which is then dynamically translated into x86-64 machine code, optimized, and natively executed. This contrasts with PHP's usual interpreted execution, in which the Zend Engine transforms PHP source code into opcodes that serve as a form of bytecode, and executes the opcodes directly on the Zend Engine's virtual CPU.


  • LLVM is the backend AND the umbrella project name.
  • LLVM is NOT a traditional virtual machine.
  • It is NOT an acronym (though originally it stands for Low Level Virtual Machine).
  • It contains modularized compiler components and tool chains.
  • Clang: frontend for C/C++/Object-C/Object-C++.
  • Backend converts the LLVM Intermediate Representation (IR) to code for a specified machine or other languages (hardware OR software target)
  • https://llvm.org


  • static compiler, or ahead-of-time(AOT) compiler: at compile-time, e.g. from .java to bytecode .class.
  • dynamic compiler, or just-in-time(JIT) compiler: at run-time, e.g. in Java, compiles bytecode to native instructions.

bytecode is portable, but native code is not.

Java JIT 2 flavors:

  • client-side compiler(with -client option): fewer resources, sensitive to startup time.
  • server-side compiler(with -server option): long running, more advanced optimizations.

Besides Java, PyPy provides JIT for Python, V8 compiles javascript directly to native machine code.

Compiler vs Interpreter

A script is program code that doesn’t need pre-processing (e.g. compiling) before being run.

  • compiled to standalone executables: C/C++, COBOL
  • ran in an interpreter: Perl, Tcl
  • Java need for both a bytecode compiler and a runtime interpreter.
  • Python and R have no compile-time type-safety,
  • Compiled-to-JavaScript language: dart, typescript, flow