computer systems nat 4/5 computing science translator programs

10
Computer Computer Systems Systems Nat 4/5 Computing Nat 4/5 Computing Science Science Translator Programs Translator Programs

Upload: suzan-french

Post on 23-Dec-2015

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Computer Systems Nat 4/5 Computing Science Translator Programs

Computer Computer SystemsSystems

Nat 4/5 Computing Nat 4/5 Computing ScienceScience

Translator ProgramsTranslator Programs

Page 2: Computer Systems Nat 4/5 Computing Science Translator Programs

Lesson AimsLesson Aims By the end of this lesson: All pupils will be able to:

Describe and compare the following types of languages:

Machine Code High Level Languages Describe why High Level Languages require

translation. Describe how interpreters and compilers

function.

Page 3: Computer Systems Nat 4/5 Computing Science Translator Programs

Types Of LanguagesTypes Of Languages Machine Code is made up of only 2

symbols. 1 and 0 (On and Off)

High Level Languages such as Visual Basic are written using some English words. They are not written IN english!

Nat 4/5

Page 4: Computer Systems Nat 4/5 Computing Science Translator Programs

High Level LanguagesHigh Level Languages

Nat 4/5

Page 5: Computer Systems Nat 4/5 Computing Science Translator Programs

Why do we need them?Why do we need them? The source code you write is instructions

for the computer They are in a High Level Language

The computer needs these instructions translated into machine code It’s the only language it understands!

Nat 4/5

Page 6: Computer Systems Nat 4/5 Computing Science Translator Programs

Types of TranslatorsTypes of Translators These programs convert High Level

Language Source code into machine code (binary)

Interpreter Translates and executes one line at a time

Compiler Translates and executes the entire program

at once This program can then be ran repeatedly

Nat 4/5

Think complete!

Page 7: Computer Systems Nat 4/5 Computing Science Translator Programs

InterpreterInterpreter Functions like a spoken language interpreter.

Translates and executes a single line at a time

The interpreter is ALWAYS loaded in memory

Error feedback is provided line by line Like in Smallbasic

Interpreted programs have to be re-interpreted every single execution

Nat 4/5

Page 8: Computer Systems Nat 4/5 Computing Science Translator Programs

How an interpreter worksHow an interpreter works

Nat 4/5

Original Source Code

Pctoutput.print “Hello”

Pctoutput.isible = true

Interpreter

1001 1000 1100 1110 00111001 1000 1100 1110 0011Syntax Error

Page 9: Computer Systems Nat 4/5 Computing Science Translator Programs

How the compiler worksHow the compiler works

Nat 4/5

Original Source Code

Pctoutput.print “Hello”

Pctoutput.isible = true

Compiler 1010 1010 1010 0111 00111001 1000 1100 1110 0011

Syntax Error

Object Code

Can be saved and ran later

Page 10: Computer Systems Nat 4/5 Computing Science Translator Programs

SummarySummary Compilers translate source code once into

an executable program Only has to be translated once! Cannot see the source code in a compiled

program

Interpreters translate source code line by line Always has to be re-interpreted Spots errors line by line

Nat 4/5