Questions: Interpreter Design and Execution Models

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A tree-walking interpreter executes a loop body 100,000 times. Why is this significantly slower than a bytecode interpreter running the same loop, even though both compute the same result?

AThe tree-walking interpreter must re-parse the source code on every loop iteration
BThe tree-walking interpreter re-traverses the same AST nodes on every iteration, with pointer-chasing through heap-allocated tree structures on each pass
CThe tree-walking interpreter cannot optimize loop bodies and must treat each iteration as independent
DThe bytecode interpreter performs native code compilation during the loop
Question 2 Multiple Choice

A language designer needs to choose an execution model for a new scripting language. Performance matters but the team has limited resources, and the language must run portably across many platforms. Which execution model is the best fit?

ATree-walking interpretation — it is the simplest to implement and portability requires simplicity
BBytecode interpretation — it provides a significant performance improvement over tree-walking while remaining portable and far simpler to implement than a JIT
CJIT compilation — any production language needs near-native performance
DAhead-of-time compilation to native code — it is faster than bytecode and eliminates warmup
Question 3 True / False

A JIT compiler introduces warmup time because the program initially runs in interpreted mode while the JIT identifies which code paths are hot enough to compile.

TTrue
FFalse
Question 4 True / False

Bytecode interpreters are slower than tree-walking interpreters because they require an additional compilation step (AST → bytecode) before execution can begin.

TTrue
FFalse
Question 5 Short Answer

Explain why bytecode interpretation is faster than tree-walking interpretation, despite requiring an additional compilation step before execution begins.

Think about your answer, then reveal below.