You are on page 1of 12

Language Translators

Syntax vs Semantics
Syntax: rules that govern how statements in a
computer programming language must be
constructed.

Incorrect spelling
Wrong brackets
Leave off matching brackets
Leave off end statements

Semantics: meaning conveyed by collection


of statements.
Computers (compilers) detect SYNTAX
errors, but they cannot determine the purpose
of programs or semantic meaning (yet!!).

Low Level Languages


Inside the RAM programs are represented in
binary form (000101000111100110, machine
code language)
First step: created codes that stand for binary
instructions (ADD 2310, Assembly Language:
each line corresponds to one machine code
instruction). They are machine specific.
As this was still difficult to handle High
Level Languages

High Level Languages


Portable: can run in different machines
English-like
One instruction = many machine code
instructions
More than 2000 languages developed
Early: FORTRAN (FORmula TRANslation
lang), COBOL (COmmon Business Oriented
Language, ALGOL (ALGorithic Lang: first
structured lang which led to C and PASCAL),
BASIC (Beginners All-purpose Symbolic
Code)
Object Oriented Languages: SAMLLTALK,
C++ and JAVA.

Compiler
Translation program that converts source code into
object code format (from HLL to machine code to be
executed)
Checks for syntax errors and reports to programmer.
Programmer corrects source code and compiles
again.
If syntactically correct compiler links modules and
generates required object code.
Compiled code usually executes faster than an
interpreted version and can be moved to other
computers.

IDE
Integrated Development Environment
Integrates editor (to create the code) +
debugger (allows programmer to
remove bugs from source code)

Compiler

Interpreter

Translation Process
(Summary)

Converts source code into object code


that can be executed
Compiled code:
completely separate prg
Can stand alone
Does not need the compiler to run

Code run via an interpreter can be


usually viewed.

Compiler
Creates a completely
new prg to be executed.
Does not stop at the
first error and continues
reporting syntax errors
found.
No need to load into
memory to execute a
compiled prg
The object code cannot
be modified

Interpreter
Analyses and executes
each line of source
code in succession
Does not look first to
the entire prg
Runs slower than
compiled prg
Line being interpreted is
executed straight away
(good for large prg)
Need to be loaded each
time memory usage

Compiling & Running Java


Compiles to an intermediate stage: Java
bytecode
Java bytecode:

Stage found in in a java .class file produced by


running the javac program on a Java source code
file.
compressed version then passed to an interpreter
(JavaVirtual Machine)

JVM actually produces the machine code


from the bytecode file and pre-compiled
library units needed by the Op System.

Java Source file

javac compiler

.java extension

Java bytecode file


with .class
extension

Java library files


(.class files) for
local platform

Java interpreter (Java


Virtual Machine)

Java machine code

You might also like