Course contentsShow
← Computer Science
Lesson 2035 of 2,87246. Compilation and InterpretationFree lesson

Platform Dependency and Portability

Explore how compiled programs are platform-specific while interpreted code can run on any system with the interpreter.

Platform Dependency and Portability

You'll learn why compiled programs are tied to specific hardware while interpreted code can run anywhere the interpreter exists.


When you compile a program, the compiler translates your source code directly into machine code—the binary instructions your specific CPU understands. This machine code is like a recipe written in a language only one chef (CPU) can read. An Intel x86 processor cannot execute ARM instructions, and vice versa. The compiled binary is platform-dependent: it only runs on the operating system and hardware architecture it was built for.

Interpreted code, on the other hand, remains in a form closer to source code (or bytecode). The interpreter itself is platform-dependent—there's one version for Windows, another for Linux, another for macOS—but your program code stays the same. Think of it like a play script: the script doesn't change, but you need a different theater (interpreter) in each city. As long as that city has a theater that can perform your play, you're good to go.

This is why Python, JavaScript, or Java bytecode programs are considered portable: write once, run anywhere there's an interpreter or virtual machine. You don't recompile for each platform.

Compiled programs offer speed but sacrifice portability. If you compile a C program on Linux for x86-64, you cannot run that binary on Windows or a Raspberry Pi without recompiling specifically for those targets.

Bytecode systems like Java's JVM split the difference: compile to an intermediate bytecode once, then run on any platform with a JVM. The JVM itself is platform-specific, but your .class files are not.

Key Takeaway: Compiled programs are fast but platform-specific (tied to the target OS and CPU); interpreted code is portable across any system that has the interpreter installed.