Title: Chapter 15 Programming Languages
1Chapter 15 Programming Languages
- 15.1 Roles of a Programming Language 81
- 15.2 Development of Programming Languages 81
- 15.3 High-level Programming Languages 86
- 15.4 Translator 88
215.1 The Roles of a Programming Language
Chapter 15 Programming Languages
- Programming Language
- Interface between machine and programmer
- Computer handles bits and bytes
- Has its own words and syntax
- Syntax
- is a set of rules that govern how the words are
put together to form a Statement - Programmers must obey syntax
- Algorithms
- ordered steps recorded on paper
- Programming
- realises algorithm
315.2 Development of Programming Languages
Chapter 15 Programming Languages
- A. Low level Programming Language
- 1. First Generation Language
- 2. Second Generation Language
- B. High level Programming Language
- 1. Third Generation Language (3GL)
- 2. Fourth Generation Language (4GL)
- C. Comparison High Low Level languages
415.2.1 Low-level programming languages
15.2 Development of Programming Languages
- Low-level programming languages
- include
- Machine languages and
- Assembly languages
- Machine dependent
- e.g. programs written in low-level languages for
IBM PC cannot be run in a Macintosh computer - Control hardware
- e.g. Driver programs are written in low-level
languages. - Programs written in low-level languages are
usually - small in size and
- efficient.
515.2.1.1 First generation languages (1)
15.2 Development of Programming Languages
- The first generation programming languages
- Machine languages
- Defined by the hardware design of the computer
- Machine dependent.
- Instruction formed by binary digits (0or 1)
- Corresponding to an ON or OFF state of an
electric circuit
615.2.1.1 First generation languages (2)
15.2 Development of Programming Languages
- Machine Instruction has two parts
- op code operation to be performed
- a verb
- (e.g. increment, add, copy, etc)
- operand data to be acted on
- a noun
- (e.g. In incrementing the value of A, A is the
operand) - Operand may be a value or
- an address of memory location
715.2.1.2 Second generation languages
15.2 Development of Programming Languages
- Second generation language
- Assembly languages
- Instructions are 11 with machine instructions
- Symbolic instruction code (or mnemonics)
- Using symbolic instruction code to replace binary
digits. - Meaningful abbreviations that substitute the op
code - e.g. JMP A means jump to address represented by
A. - Low-level languages
- Machine languages and assembly languages
815.2.2 High-Level Programming Languages
15.2 Development of Programming Languages
- High-level languages
- Machine-independent
- Third generation languages or above
- More like human languages
- Let programmers concentrate on the logic
- Rather than machine architecture
915.2.2.1 Third generation language (3GL)
15.2 Development of Programming Languages
- More human like than assembly language
- Meet demand of efficiency and effectiveness
- Examples
- C, Fortran, COBOL, BASIC, PASCAL etc.
- Each high-level language statement is translated
into many machine instructions
1015.2.2.2 Fourth generation language (4GL)
15.2 Development of Programming Languages
- Each 4GL instruction represents many 3GL
statements - Typical example SQL (Structured Query Language)
- e.g.
- SELECT FROM student ORDER BY class,
class_no - will display all the records in table Student
in ascending order of class and class_no. - If the same task is written in a 3GL,
instructions have to be written - Sort the records in ascending order of class and
class_no - Get each record, test for end of file, put each
item on screen - Go back and repeat the operation until no more
records to process
1115.2.3 Comparing Low High-level Languages (1)
15.2 Development of Programming Languages
- 1. Advantages of high-level language
1215.2.3 Comparing Low High-level Languages (2)
15.2 Development of Programming Languages
- 2. Advantages of low-level language
1315.3 Examples of High Level Languages (1)
Chapter 15 Programming Languages
- High Level Languages
- Designed to solve different problems
- Ranging from business to games
- Some common programming languages
- 1. PASCAL
- Designed for teaching structured programming
- Popular in schools
1415.3 Examples of High Level Languages (2)
Chapter 15 Programming Languages
- 2. C
- Designed to operate computer at low-level using
high level language - More readable and better structured than Assembly
language - 3. Java
- Includes some syntax of C
- Java programs can be called from HTML document or
run directly - Computer needs Java Virtual Machine to execute
Java Programs
1515.3 Examples of High Level Languages (3)
Chapter 15 Programming Languages
- 4. COBOL
- Designed for business applications
- Wordy language
- Readable for beginners
- e.g.
- multiply hourly-rate by hours-worked
giving gross-pay - But, can be clumsy for long programs
1615.3 Examples of High Level Languages (4)
Chapter 15 Programming Languages
- 5. BASIC
- Designed to provide students with an
easy-to-learn language. - Visual Basic
- A version of BASIC
- Specialised for developing Windows applications
- Belong to Rapid Application Development (RAD)
- Programming can be done by drag-and-drop
- Programmers can quickly build an application
- Visual Basic.NET
- Newest version of Visual Basic
- Supports all Web-based features
1715.3 Examples of High Level Languages (5)
Chapter 15 Programming Languages
- 6. Script Languages
- Interpreted and processed by a software (e.g.
Browser) - Rather than a computer
- e.g.
- VBScript and JavaScript
- have similar syntax as Visual Basic and Java
respectively - Interpreted and processed by Web browser
- Instructions are embedded in HTML documents
- Increasing the function of HTML
- Making Web pages more interactive
1815.4 Translators (1)
Chapter 15 Programming Languages
- Source program
- Text file
- Storing source code
- Must be translated into machine instructions
before execution - Translator
- A software
- to convert source code into machine instructions
- Discover syntax errors of a program
1915.4 Translators (2)
Chapter 15 Programming Languages
- Object program
- Binary file
- Storing machine instructions
- During execution, needs the object program only
- A. Assembler
- B. Compiler
- C. Interpreter
- D. Trend in Translators
- E. Comparison of Translators
2015.4.1 Assemblers
15.4 Translators
- A. Assembler
- A software
- Translate assembly language program into machine
instructions - Producing one machine instruction for each
assembly language statement - Translate the whole source program before
execution - Storing the results in an object program
- During execution, need the object program only
2115.4.2 Compilers
15.4 Translators
- B. Compiler
- A software
- Translate high-level language program into
machine instructions - Translate the whole source program before
execution - Storing the results in an object program
- During execution, need the object program only
2215.4.3 Interpreters
15.4 Translators
- C. Interpreter
- A software for
- translating ONE high-level language program
statement at a time - send to the computer for execution
- then proceed to the NEXT statement
- No object program is produced
- When program is run, the following must be
present - interpreter and source code.
- Interpreted program runs slower than compiled
ones - Because time is spent on translation
- Like by programmers
- more convenient in testing
2315.4.4 Trend in translators
15.4 Translators
- Portability of programs
- The same program can be run on different OS
without re-compilation - Java
- Portable
- Source code of a Java program are not compiled
into machine instructions - But, compiled into intermediate code (bytecode)
- The object programs with bytecode are interpreted
by an interpreter (called Java Virtual Machine,
JVM) - Users have to install JVM before use
- Microsofts Visual Studio.net use similar
approache
2415.4.5 Comparison of Translators
15.4 Translators