ITEC102 Chapter 2 Compiled - VS - Interpreted

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 24

ITEC102-

INTEGRATIVE
PROGRAMMING
TECHNOLOGIES
COMPILED,
INTERPRETED and
ASSEMBLY
LANGUAGE
• Translator takes a program
written in source language as
input and converts it into a
program in target language
as output
• Compiler and Interpreter are
two different ways to execute
a program written in a
programming or scripting
language.
COMPILER
• A compiler takes entire program
and converts it into object code
which is typically stored in a file.
• The object code is also refereed as
binary code and can be directly
executed by the machine after
linking.
INTERPRETER
• An Interpreter directly
executes instructions written in
a programming or scripting
language without previously
converting them to an object
code or machine code.
ASSEMBLER
• Assembler is a translator which is used
to translate the assembly language
code into machine language code.
• A compiled language is one where the
program, once compiled, is expressed in
the instructions of the target machine; This
machine code is undecipherable by
humans. An interpreted language is one
where the instructions are not directly
executed by the target machine, but
instead read and executed by some other
program (which normally is written in the
language of the native machine).
COMPILED LANGAUGE

INTERPRETED LANGAUGE
COMPILED LANGUAGE
• Compiled languages are
converted directly into machine
code that the processor can
execute. As a result, they tend to
be faster and more efficient to
execute than interpreted
languages.
COMPILED LANGUAGE
• Compiled languages need a
“build” step - they need to be
manually compiled first. You
need to “rebuild” the
program every time you need
to make a change.
COMPILED LANGUAGE
• Examples of pure compiled
languages are C, C++, Erlang,
Haskell, Rust, and Go.
INTERPRETED LANGUAGE
• Interpreters will run through a
program line by line and execute
each command.
• Interpreted languages were once
known to be significantly slower
than compiled languages. But, with
the development of just-in-time
compilation, that gap is shrinking.
INTERPRETED LANGUAGE
• Examples of common
interpreted languages are
PHP, Ruby, Python, and
JavaScript.
ADVANTAGE AND
DISADVANTAGE
ADVANTAGE OF COMPILED
LANGUAGE
• Programs compiled into
native code at compile time
usually tend to be faster than
those translated at run time,
due to the overhead of the
translation process.
DISADVANTAGE OF COMPILED
LANGUAGE
• The most notable
disadvantages are :-
(1) Additional time needed to
complete the entire compilation
step before testing, and
(2) Platform dependence of the
generated binary code.
ADVANTAGE OF INTERPRETED
LANGUAGE
• An Interpreted language
gives implementations some
additional flexibility over
compiled implementations.
ADVANTAGE OF INTERPRETED
LANGUAGE
(Because interpreters execute
the source program code
themselves, the code itself is
platform independent (Java’s
byte code, for example).
DISADVANTAGE OF INTERPRETED
LANGUAGE
• The most notable
disadvantage is typical
execution speed compared
to compiled languages.
BYTECODE LANGUAGE
• Bytecode languages are a type
of programming language that
fall under the categories of both
compiled and interpreted
languages because they
employ both compilation and
interpretation to execute code.
BYTECODE LANGUAGE
• Java and the .Net framework are easily
the most common examples of bytecode
languages (dubbed Common
Intermediate Language in .Net). In fact,
the Java Virtual Machine (JVM) is such a
common virtual machine to interpret
bytecode that several languages have
implementations built to run on the JVM.
BYTECODE LANGUAGE
• In a bytecode language, the
first step is to compile the
current program from its
human-readable language
into bytecode.
BYTECODE LANGUAGE
• Bytecode is a form of instruction set that is
designed to be efficiently executed by an
interpreter and is composed of compact
numeric codes, constants, and memory
references. From this point, the bytecode is
passed to a virtual machine which acts as
the interpreter, which then proceeds to
interpret the code as a standard
interpreter would.
ITEC102 – INTEGRATIVE
PROGRAMMING TECHNOLOGIES

You might also like