bytecode
A compact, portable instruction format that a virtual machine or interpreter executes, instead of instructions for one particular processor.
In more detail
Languages such as Python, Java and C# compile source code to bytecode, which then runs anywhere the matching virtual machine or interpreter is installed. The virtual machine may interpret the bytecode or compile frequently used parts into native code while the program runs. Bytecode is not machine code: the processor cannot run it directly.
Examples
Python's dis module shows a function's bytecode; the course's instruction evaluator mimics its stack with a list.Java: javac writes bytecode into class files for the JVM; javap -c shows it, such as 0: aload_0.0: aload_01: invokespecial #1 // Method java/lang/Object."<init>":()VV8's Ignition interpreter runs bytecode, and when optimised code is thrown away execution falls back to it.Related terms
- stack — A collection where the last item added is the first one removed, like a pile of plates.
- class file — The file javac writes for each class, holding that class's bytecode plus a description of its fields and methods.
- JVM — The program that loads class files and runs their bytecode, turning hot code into native machine instructions while it runs.
- JIT compiler — A compiler inside a runtime that turns intermediate code into native machine code while the program runs.
- javap — The JDK tool that prints what a class file contains, including its bytecode with -c and its class file version with -v.
- native code — Instructions in the language of a specific processor, which the processor can execute directly.
- Ignition — V8's interpreter, which turns the abstract syntax tree into bytecode and runs it so code starts quickly.
- interpreter — A program that reads source code and carries it out at run time, instead of translating it into machine code in advance.
- machine code — The binary instructions a specific processor executes directly, such as arm64 or x64 instructions.
- CPython — The standard implementation of Python, written in the C language, which is what you get from python.org.
- .gitignore — A text file of patterns naming untracked files Git should not report or add, such as build output and logs.
Taught in
- Stacks And Queues: Last In Or First In — Algorithms & Data Structures for Working Engineers
- The Virtual Machine, The Kit And The Runtime — Modern Java: Virtual Threads & High-Throughput Services
- The Lifecycle Of A Java Program — Modern Java: Virtual Threads & High-Throughput Services
- Jars, Automatic Modules And Runtime Images — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- V8 Engine & JIT Pipeline: Bytecode & Turbofan — Node.js Internals & Backend Services
- Virtual Environments — Hands-on Python: Complete Video Course & Book
- Shipping: scripts, entry points and git — Hands-on Python: Complete Video Course & Book
- Interpreter, Compiler, And What Counts As Syntax — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- Fundamentals Sprint — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- Your Own Modules And Packages — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Modules Sprint — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
References
- Python dis: disassembler for Python bytecode
- Python glossary: bytecode
- JVM Specification, chapter 6: The Java Virtual Machine Instruction Set
- The javap command (Java SE 21)
- V8: Ignition
- Python tutorial: compiled Python files