Language translators and IDEs
From source code to running program
- You write source code; the computer runs machine code.
- A translator bridges the gap — and there are three kinds.
- An IDE puts all the tools to write, run and debug code in one place.
Assembler, compiler, interpreter
- An assembler translates assembly language to machine code, one instruction per instruction.
- A compiler translates a high-level program to machine code once, before it runs: it reports all errors at compile time, then produces a stand-alone executable that runs without the compiler and is fast at run time (but tied to one CPU/OS).
- An interpreter translates and runs one line at a time, producing no executable: it reports an error when it reaches that line, needs to be installed to run the program, and is generally slower but easy to port.
A compiler differs from an interpreter because it:
A compiler translates all at once into an executable that runs without the compiler. An interpreter runs line by line.
When does an interpreter report an error?
An interpreter runs line by line, so it reports an error at the moment it reaches that line — handy during development.
Match each translator to what it does.
Assembler: assembly→machine code; compiler: all-at-once to an executable; interpreter: line by line at run time.
Choosing between them
| Use a compiler when… | Use an interpreter when… |
|---|---|
| you need maximum run-time speed | you want a fast edit-run-debug cycle |
| distributing to users without dev tools | writing cross-platform scripts |
| the program runs many times | the program is small or run-once |
You should choose a compiler when:
Compiled executables are fast and stand-alone. Interpreters suit quick development and portable scripts.
Hybrid: Java bytecode
- Java is compiled to bytecode — a platform-independent intermediate form.
- A virtual machine (JVM) then interprets it, or uses just-in-time (JIT) compilation to turn hot parts into native code.
- So errors are caught early, the bytecode runs anywhere with a JVM ("write once, run anywhere"), and long-running programs reach near-native speed.
Java compiles to bytecode that runs on a JVM. The main benefit is:
Bytecode is platform-independent; any JVM can run it (with JIT giving near-native speed for hot code).
Integrated Development Environments (IDEs)
- An IDE brings writing, testing and debugging into one application:
- a code editor with syntax highlighting and auto-complete;
- one-key compile/run with errors shown inline;
- a debugger — set breakpoints, step line by line, and inspect variables;
- plus version control, refactoring and unit-test integration.
Which feature is part of an IDE's debugger?
A debugger lets you set breakpoints, step through code line by line, and inspect variable values.
You've got it
- compiler = translate all at once → stand-alone executable, fast, platform-specific
- interpreter = translate line by line → needs the interpreter, slower, portable, errors found at the line
- Java compiles to bytecode run by a JVM → "write once, run anywhere" (+ JIT for speed)
- an IDE = editor + debugger (breakpoints) + tools in one app