Programming Languages

advertisement
Programming Languages
Low-level Languages
High-level Languages
Advantages & Disadvantages
Translators
Trends in Programming Languages
1
Introduction
u program
– a series of instructions make a computer
‘works’
– can be written in a variety of programming
languages
u programming
lang. - later generations:
– fewer instructions
– provide a more sophisticated
programmer/computer interaction
2
Fourth
Fourth
generation
generation
languages
languages
(4GLs)
(4GLs)
4th
gen.
High-level
languages
are
problem
oriented
Procedural languages
3rd
gen.
Multipurpose
Multipurpose
BASIC
BASIC(1965)
(1965)
Pascal
(1968)
Pascal (1968)
Business
Business
COBOL
COBOL(1959)
(1959)
2nd
gen.
Assembler
Assembler
1st
gen.
Machine
Machine
Scientific
Scientific
FORTRAN
FORTRAN(1955)
(1955)
The hierarchy of programming languages
More
sophistication
in programmer/
computer
interaction
Low-level
languages
are
machine
oriented
3
Low-level Languages
u Machine
language
– a programming language that is interpreted &
executed directly by the computer
u Assembly
language
– a symbolic language with an instruction set that
is basically one-to-one with the machine
language
4
Machine language (ML)
u each
computer can only understand
programs that are written in its own ML
u is provided by the computer manufacturer
u translation is needed when executing
programs written in Pascal or BASIC
u written at the most basic level of computer
operation
– coded as a series of 0’s and 1’s, e.g., 10111010
5
Machine language (ML)
u Disadvantages:
– very difficult to write, because:
• binary system - not ‘user friendly’ to human
• it requires excellent memorising power
– programmer has to keep track of storage
locations of data & instruction
ASSEMBLY LANGUAGE
6
Assembly language
u also
provided by the manufacturer
u one instruction for each computer operation
u instruction codes are represented by
mnemonics (a set of letters)
u the code must be assembled into machine
language for execution
assembly language
[refer to Fig 13.2]
7
Assembly language
u Disadvantages:
(similar to that of ML)
– machine dependent
– the program is usually long
– hard to learn & slow to write
HIGH LEVEL LANGUAGES
8
High-level Languages
u made
programming much more convenient
u written using common names & words
more like human languages
u problem-oriented languages
– designed to solve specific problems
u e.g.,
FORTRAN, COBOL, BASIC, Pascal
& C language
[refer to Fig 13.4 - 13.8]
9
Advantages of
High-level Languages
u easier
to write, to read & to modify
– written in English-like format
u programs
- faster & shorter to code
– one statement for several computer operations
u more
portable, i.e., can be executed by
different computers
– machine independent
10
Advantages of
Low-level Languages
u take
up less storage space
u run faster
u useful for writing system programs
– e.g., operating systems (require fast & efficient
use of CPU)
u sometimes
an operation can only be
performed in a low-level language
11
Translators
u programs
must be translated into machine
codes before execution
Source
Source
program
program
Translator
Translator
Object
Object
program
program
Execution
A simplified translation process
12
Translators - 3 types
Source
Sourceprogram
program
Translator
Translator
assembly
assembly
language
language
programs
programs
assembler
assembler
Object
Objectprogram
program
machine
machine
codes
codes
compiler
compiler
high-level
high-level
language
language
programs
programs
interpreter
interpreter
Execution
Execution
The functions of the three types of translators
13
Similarities between
compilers & interpreters
u both
translate high-level languages to
machine codes
u both
direct errors in the programs & print
error messages
u both
work out where to store the object
program & its data in the memory
14
Differences between
compilers & interpreters
Translation of
source program
Freqrency of
translation
Compilers
Interpreters
the whole program
before execution
each line is translated
once
one line at a time
when it is run
has to be translated
every time it is
executed - slower
no object program is
generated, so, source
program must be
present for execution
Object program can be saved for
future exeution
without the source
program
15
Trends in
Programming Languages
u fewer
instructions
u more user-friendly
u towards using 4GLs
– non-procedural language
– users only have to state what needs doing, but
not how to do it
– designed for users with minimal programming
knowledge & training
16
Trends in
Programming Languages
u Logic
programming (e.g., Prolog)
– 5th-generation computer language
– declarative language
– expert systems & artificial intelligence app.
u Object-oriented
techniques
– e.g., Borland C++
u Visual
development environments
– e.g., Microsoft Visual Basic
17
Download