0% found this document useful (0 votes)
49 views

Fundamental Programming - Lecture 2 - Language Evolution

The document discusses the evolution of computer programming languages from machine languages to modern high-level languages. It distinguishes between machine, assembly, and high-level languages. It also categorizes languages as procedural, object-oriented, functional, declarative, and special purpose languages. Key steps in creating and running a program including writing/editing code, compiling, and linking are outlined. Examples of languages from each category are provided.

Uploaded by

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

Fundamental Programming - Lecture 2 - Language Evolution

The document discusses the evolution of computer programming languages from machine languages to modern high-level languages. It distinguishes between machine, assembly, and high-level languages. It also categorizes languages as procedural, object-oriented, functional, declarative, and special purpose languages. Key steps in creating and running a program including writing/editing code, compiling, and linking are outlined. Examples of languages from each category are provided.

Uploaded by

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

Fundamental Programming

Language Evolution
OBJECTIVES
After reading this chapter, the reader should be able to:
• Have a vision of computer language evolution.
• Distinguish between machine, assembly, and high-level languages.
• Understand the process of creating and running a program.
• Distinguish between the different categories of languages: procedural,
object-oriented, functional, declarative, and special.
Evolution of computer languages
Program in machine language
1 00000000 00000100 0000000000000000
2 01011110 00001100110000100000000000000010
3 11101111 000101100000000000000101
4 11101111 10011110 0000000000001011
5 11111000 10101101 11011111 0000000000010010
6 0110001011011111 0000000000010101
7 11101111 00000010 11111011 0000000000010111
8 11110100 1010110111011111 0000000000011110
9 0000001110100010 11011111 0000000000100001
10 11101111 00000010 11111011 0000000000100100
11 01111110 11110100 10101101
12 11111000 10101110 110001010000000000101011
13 0000011010100010 11111011 0000000000110001
14 11101111 00000010 11111011 0000000000110100
15 00000100 0000000000111101
16 00000100 0000000000111101
Note:

The only language understood by


a computer is machine language.
Program in Symbolic Language
1 Entry main, ^m<r2>
2 subl2 #12,sp
3 jsb C$MAIN_ARGS
4 movab $CHAR_STRING_CON
5
6 pushal -8(fp)
7 pushal (r2)
8 calls #2,read
9 pushal -12(fp)
10 pushal 3(r2)
11 calls #2,read
12 mull3 -8(fp),-12(fp),-
13 pushal 6(r2)
14 calls #2,print
15 clrl r0
16 ret
Symbolic languages
• Assembly language is a symbolic language.
• An assembler is used to translate symbolic code into machine
language.
Program in C++ language
1 /* This program reads two integer numbers from the
2 keyboard and prints their product.
3 */
4 #include <iostream.h>
5
6 int main (void)
7 {
8 // Local Declarations
9 int number1;
10 int number2;
11 int result;
12 // Statements
13 cin >> number1;
14 cin >> number2;
15 result = number1 * number2;
16 cout << result;
17 return 0;
18 } // main
Building a program
Building a program
• Three steps to building a program:
• Writing an editing the program
• Using text editor to edit the source file
• Compiling the program
• Two programs: the preprocessor and the translator
• Linking the program with the required library modules
• The linker assembles all of the subprograms into the final executable program
Program Execution

disk

monitor
computer
CATEGORIES OF LANGUAGES
Categories of languages
Procedural language
• A procedural (imperative 命令) language is a set of instructions that
are executed one by one from beginning to end unless an instruction
forces the control elsewhere.
• FORTRAN
• COBOL
• Pascal
• C
• Ada
Object-Oriented languages
• In object-oriented programming, the objects and the operations to be
applied to them are tied together.
• The objects in object-oriented programming are active.
• C++
• Java
C++
• C++: developed by Bjarne Stroustrup at Bell Lab
• Three principles:
• Encapsulation (封裝)
• The user knows what to do with the data without knowing how it is
done.
• Inheritance (繼承)
• When a general class is defined, you can define a more specific class
that inherits some of the characteristics of the general class but also
has some new characteristics.
• Polymorphism (多型)
• You can define several operations with the same name that can do
different things in related classes.
Java
• Java:
• Developed at Sun Microsystems,, Inc.
• The language is totally class oriented.
• Every data item belongs to a class.
• The browser can download the applet (小小的應用程式) and run it locally.
• Features:
• Class library
• Multithreading
Functional languages
• A functional language:
• Predefines a set of primitive functions
• Allow the programmer to combine primitive functions to create new function

Function in a functional language


Declarative language
• A declarative language uses the principle of logical reasoning to
answer queries.
• Logical reasoning is based on deduction (歸納).
• For example:
If (A is B) and (B is C), then (A is C)
• Problem:
• Collecting all the facts into one program make the program huge.
Special languages
• HTML (Hypertext Markup Language)
• An HTML file is stored on the server and can be downloaded by a browser.
• The instructions are stored with the text.
• Any browser can read the instructions and format the text according to the
workstation being used.
• HTML lets you use only ASCII characters for both the main text and formatting
instructions.
• Head, Body, and Tags

You might also like