Bitpath

Lesson 2 · Unit 03

From source to machine

Compilers, interpreters, bytecode and JITs

12 exercisesabout 3 min

What you practise

  • Compilers, interpreters, bytecode and JITs
  • What python, node and tsc each do with your file
  • Why the same loop is slower in Python

Try a question from this lesson

Pick one

The CPU only understands its own numeric machine instructions. You saved print(1 + 2) in a text file. What has to happen before the CPU can act on it?

The ideas

Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.

Concept

Two ways to translate

A compiler translates the whole program to machine code once, before it runs. Fast to run, but there is a build step.

An interpreter is a program that reads your code and carries it out step by step. No build step, but it does translation work every time the code runs.

compiled (C, Rust, Go):
  source -> compiler -> machine code
  later, the CPU runs that directly

interpreted (Python):
  source -> interpreter, a program
            that performs each step

Concept

JIT: compile while running

A just-in-time compiler starts by interpreting, and watches which functions run most. Those hot functions are compiled to machine code on the spot, specialised for the types seen so far.

That is how JavaScript in V8 gets close to compiled speed without a build step.

9 more exercises in the app

  • 4× multiple choice
  • 1× match the pairs
  • 1× true or false
  • 1× order the lines
  • 1× type the answer
  • 1× fill the blanks

Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.

One email when Bitpath is ready to try. Nothing else. Privacy