Saltar al contenido ForoHackers

Runtimes: start here

Entornos de ejecución
#881 · Ophuscado · · Denunciar

A runtime is the support code that runs alongside your program: it starts it, manages its memory, schedules its threads and connects it to the system. Some languages ship a small one, such as C's library; others a large virtual machine with a garbage collector and a just-in-time compiler. Knowing what the runtime does explains most surprising behaviour.

Key concepts

  • Execution models: native code, bytecode on a virtual machine, or an interpreter reading source.
  • Garbage collection: the runtime finds unreachable objects and reclaims them, trading pauses and memory for safety.
  • Just-in-time compilation: hot code is compiled while the program runs, using what it has observed.
  • Concurrency support: threads, event loops, green threads or lightweight tasks, with their own scheduler.
  • Foreign interfaces: how managed code calls native libraries, and the cost and risk at that border.

Vocabulary

  • Virtual machine: a program that executes a portable instruction format.
  • Bytecode: the compact instruction set a virtual machine runs.
  • Warm-up: the time a runtime needs before just-in-time compilation reaches full speed.
  • Stop-the-world pause: a moment when a collector halts the program.

What to study, in order

  1. Write the same small program in a compiled and in an interpreted language, and compare startup and memory.
  2. Read the bytecode your language produces and run it by hand for a few lines.
  3. Implement a tiny stack-based virtual machine with a loop and a few instructions.
  4. Add a simple mark-and-sweep collector to it.
  5. Measure a program's garbage collection behaviour with the runtime's own tools and change one setting.

Related tags

#interpreters #compilers #memory-management #java #webassembly

Inicia sesión o únete para responder.