Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
31 views

Lesson 3 - Computer Programming Languages and Language Translators

Uploaded by

cjchrys23
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

Lesson 3 - Computer Programming Languages and Language Translators

Uploaded by

cjchrys23
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Lesson 3: Computer Programming Languages and

Language Translators
Programming language: - This is a program with a special
role i.e. it enables us to come up with other programs. Has
instructions that enable us to write programs or modify an
existing program. C, C++, JAVA, PHP, JSP, C#, JAVASCRIPT
etc.
They have features of language
Grammar : SYNTAX
Vocabulary
Interpretation/ meaning: SEMANTICS
There are many different languages that can be used to
program a computer and they are categorized as follows:

i) Machine language
ii)Assembly /Low-level language
iii) High-level languages

Machine language

 The most basic of these is machine language.

 The very lowest possible level at which you can program


a computer is in its own native machine code, consisting
of strings of 1's and 0's and stored as binary numbers.

Disadvantages

 It is very easy to make a mistake, and very hard to find it


once you realize the mistake has been made.

 Because each machine has its own instruction set, a


program written for one machine cannot be ported to
another machine

Assembly /Low-level language

 After machine language we have assembly languages.


Here we have symbolic representation of machine code.

1
 The assembly language program must be converted to
machine language for the machine to understand it.

High-level languages

 Usually, a computer program is written in high level


language, whose instruction set is more compatible with
the human languages e.g. English and the human thought
process.

 A single instruction in a high level language will translate


to several instructions in machine language.

Advantages

 This greatly simplifies the task of writing complete,


correct programs.

 The rules for programming in a particular high level


language are much the same for all computers

Language Translators

Any program written in a high-level language is known


as source code. However, computers cannot understand
source code. Before it can be run, source code must first be
translated into a form which a computer understands.

A translator is a program that converts source code into


machine code.

Language translators allow computer programmers to write


sets of instructions in specific programming languages. These
instructions are converted by the language translator into
machine code. The computer system then reads these machine
code instructions and executes them.

A program that is written in a high-level language must be


translated into machine language. This is a process called
compilation or interpretation, depending on how it is done.
Compilation is done by a compiler while interpretation is done
by an interpreter.

2
A compiler or interpreter is itself a computer program that
accepts a program written in a high-level language as input
(source program), and generates a corresponding machine
language program as output (object program

There are three main translators:

1. Compilers: Change high-level language into machine


language.

2. Interpreters: Read and run high-level code one line at a


time.

3. Assemblers: Turn assembly language (a low-level


language closer to machine code) into machine code.

Compilers

A compiler takes the source code as a whole and


translates it into machine code all in one go. Once
converted, the object code can be run unassisted at any
time. This process is called compilation.

Compilers have several advantages:

 Compiled programs run quickly, since they have already


been translated.

 A compiled program can be supplied as


an executable file. An executable file is a file that is ready
to run. Since an executable file cannot be easily modified,
programmers prefer to supply executables rather than
source code.

 Compilers optimise code. Optimised code can run quicker


and take up less memory space.

Compilers also have disadvantages:

 The source code must be re-compiled every time the


programmer changes the program.

3
 Source code compiled on one platform will not run on
another - the machine code is specific to the processor's
architecture.

Interpreters

An interpreter translates source code into machine code


one instruction at a time. It is similar to a human translator
translating what a person says into another language,
sentence by sentence, as they speak. The resulting machine
code is then executed immediately. The process is
called interpretation.

Interpreters have several advantages:

 Instructions are executed as soon as they are translated.

 Errors can be quickly spotted - once an error is found, the


program stops running and the user is notified at which
part of the program the interpretation has failed. This
makes interpreters extremely useful when developing
programs.

Interpreters also have several disadvantages:

 Interpreted programs run slowly as the processor has to


wait for each instruction to be translated before it can be
executed.

 Additionally, the program has to be translated every time


it is run.

 Interpreters do not produce an executable file that can be


distributed. As a result, the source code program has to
be supplied, and this could be modified without
permission.

 Interpreters do not optimise code - the translated code is


executed as it is.

Assemblers

4
Assemblers are a third type of translator. The purpose of an
assembler is to translate assembly language into machine
code.

Whereas compilers and interpreters generate many machine


code instructions for each high-level instruction, assemblers
create one machine code instruction for each assembly
instruction.

The final compiled code runs faster and may be run as


many times as desired. A drawback occurs where correction
of errors must be done on the source code that must then be
re-compiled.

The compilation process produces the object code that is


then linked to produce the executable code.

Program execution process (summary)

Integrated development environment

This is a development environment in which Compilers,


debuggers and editors are available to the developer from one
central point, usually an opening window or menu. The
developer simply selects the software tool needed.

5
Examples of integrated environments include Borland or
Microsoft Visual Studio Development environments,
CodeBlocks.

Debuggers

• These are programs that are used to assist the process of


error correction in an environment where the compiler is
used.

• Debuggers behave like interpreters allowing the testing


of the program as it is being developed.

Text Editors/Word processors

• Text editors are computer software that allow the user to


create and maintain ASCII texts. They are the most
suitable means of writing programs. Most programming
environments will therefore have their own text editors.

• Word processors are computer software that allow users


to create and maintain highly formatted texts. These texts
may also contain images and specially shaped characters.
If they are used to create a program source code then the
code must be save as plain text or ASCII text.

You might also like