PWL Jan 2024: AST vs Bytecode - Interpreters in the Age of Meta-Compilation
Read by Tushar Sadhwani
Jan 2024
15 Mon
16 Tue
17 Wed
18 Thu 05:30 PM – 07:30 PM IST
19 Fri
20 Sat
21 Sun
Interpteters are the most common way to implement a programming language today, and many of the most used languages today, such as Java, JavaScript and Python, are interpreted languages. Interpreted languages are easier to implement, and can be fast, versatile, and powerful.
This whitepaper discusses the common notion of making an efficient interpreted language: creating a “bytecode compiler” for the language. All the popular interpreted programming languages today have a “compiler” which turns the language’s syntax tree into a simpler set of low level instructions, which can be executed in a virtual machine. Implementing the compiler and the virtual machine is more work, but it results in a much faster interpreted language.
But today, certain “meta-compilation” frameworks such as Graal and RPython exist, which allow you to implement a simple (AST based, or bytecode based) interpreter for your language, and then the framework will implement all the optimizations to make your interpreter faster.
Is this approach practical? How efficient are these metacompilers?
The paper can be found here:
https://stefan-marr.de/downloads/oopsla23-larose-et-al-ast-vs-bytecode-interpreters-in-the-age-of-meta-compilation.pdf
Tushar Sadhwani is a PSF contributor and Language Engineer at DeepSource, working on various code tooling projects, such as black and mypy.
Having worked with Python for close to 10 years, he enjoys writing and speaking about its features, internals of the compiler, and how and when things break in interesting ways.
You can find his blogs on https://tushar.lol
Hosted by
Interpteters are the most common way to implement a programming language today, and many of the most used languages today, such as Java, JavaScript and Python, are interpreted languages. Interpreted languages are easier to implement, and can be fast, versatile, and powerful.
This whitepaper discusses the common notion of making an efficient interpreted language: creating a “bytecode compiler” for the language. All the popular interpreted programming languages today have a “compiler” which turns the language’s syntax tree into a simpler set of low level instructions, which can be executed in a virtual machine. Implementing the compiler and the virtual machine is more work, but it results in a much faster interpreted language.
But today, certain “meta-compilation” frameworks such as Graal and RPython exist, which allow you to implement a simple (AST based, or bytecode based) interpreter for your language, and then the framework will implement all the optimizations to make your interpreter faster.
Is this approach practical? How efficient are these metacompilers?
The paper can be found here:
https://stefan-marr.de/downloads/oopsla23-larose-et-al-ast-vs-bytecode-interpreters-in-the-age-of-meta-compilation.pdf
Tushar Sadhwani is a PSF contributor and Language Engineer at DeepSource, working on various code tooling projects, such as black and mypy.
Having worked with Python for close to 10 years, he enjoys writing and speaking about its features, internals of the compiler, and how and when things break in interesting ways.
You can find his blogs on https://tushar.lol
Hosted by