COMPILING &
INTERPRETING
COMPILATION
The compiler takes the entire
source code (written in a high-level
language like C++, Java, or Go) and
translates it into machine code (or
an intermediate representation like
bytecode in Java's case) that the
computer's processor can
understand directly. This
translation process creates an
executable file.
HOW IT WORKS
The compiler performs lexical analysis
(breaking the code into tokens), syntax
analysis (checking the code's structure),
semantic analysis (ensuring meaning and type
correctness), and code generation (creating
the machine code).
ADVANTAGES
Performance: Compiled programs
generally run faster because the
translation is done only once. The
executable can be run repeatedly
without needing the compiler again.
Early Error Detection: The
compiler catches many errors
(syntax, type mismatches) before
runtime, preventing crashes during
execution. Page 04
DISADVANTAGES
Time-Consuming Compilation: The
compilation process can take a significant
amount of time, especially for large
projects.
Platform Dependence: Compiled code is
often platform-specific. You might need to
recompile the code for different operating
systems (Windows, macOS, Linux).
Page 05
INTERPRETATION
The interpreter reads the
source code line by line
and executes each
instruction immediately.
Languages like Python,
JavaScript, and Ruby are
typically interpreted. Page 07
ADVANTAGES
Faster Development Cycle: Changes
to the code can be tested immediately
without a separate compilation step.
This speeds up development.
Platform Independence: Interpreted
code can often run on different
platforms without modification, as long
as an interpreter is available for that
platform.
Page 08
DISADVANTAGES
Slower Execution: Interpreted
programs generally run slower than
compiled programs because each
line of code is translated and
executed at runtime.
Runtime Errors: Some errors might
not be detected until runtime, which
can lead to unexpected crashes.
Page 09
THANK YOU
Page 10