Download High-level programming languages

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Falcon (programming language) wikipedia , lookup

Functional programming wikipedia , lookup

Abstraction (computer science) wikipedia , lookup

Compiler wikipedia , lookup

Object-oriented programming wikipedia , lookup

Reactive programming wikipedia , lookup

Assembly language wikipedia , lookup

Structured programming wikipedia , lookup

Programming language wikipedia , lookup

Go (programming language) wikipedia , lookup

Domain-specific language wikipedia , lookup

C Sharp (programming language) wikipedia , lookup

Transcript
5.0 PROGRAMMING
Duration: 10 weeks
Prepared by Ong Lay Peng
Copyright © 2007
Activity 1: Turtle Graphics
•
•
•
•
Hold the pencil upright.
Place the pencil tip on a paper.
Keep the pencil tip on the paper at all times during the drawing process.
Perform a task based on the following instructions.
move forward 3cm.
rotate 135o to the right.
move forward 3.5cm.
rotate 135o to the left.
move forward 3cm.
**Note: Turtle graphics in one of the feature in a programming language called LOGO.
WHAT IS IN
YOUR
DRAWING
???
5.1 Basic Programming Concepts
Learning outcomes:
– Define Program and Programming Language
• State the definition of program.
• State the definition of programming language.
– Identify the levels and generations Of Programming Languages
• Identify the generations of low-level programming languages with examples.
• Identify the generations of high-level programming languages with examples.
Duration: 2 periods
Definition of Program
Task
A series of
instructions
A series of
instructions
Definition of Program
A series of instructions that directs a computer to
perform task.
Private Sub cmdCalculate_Click()
Dim area As Double
area = Val(Text1.Text) * Val(Text2.Text)
lblarea.Caption = FormatNumber(area, 2)
End Sub
Private Sub cmdClear_Click()
Text1.Text = ""
Text2.Text = ""
lblarea.Caption = ""
Text1.SetFocus
End Sub
Private Sub cmdExit_Click()
End
End Sub
Figure B
Figure A
Definition of Program
A person who writes and modifies a computer program is called ______________ ,
sometimes called developer.
A developer uses a __________________________ to write a computer program.
Definition of Programming Language
A set of words, symbols, and codes that enables a programmer to
communicate instructions to a computer.
Several hundreds of
programming languages
exist today.
Visual Basic
Java
C
C++
COBOL
J++
C#
BASIC
PASCAL
Prolog
SQL
Logo
Definition of Programming Language
Each instruction causes computer to carry out one step of the task
Definition of Programming Language
• Each programming language has its own rules for writing the
instructions.
Java Programming
Language
public class HelloWorld {
public static void main (String[] args) {
System.out.println("Hello, world!\n");
}
}
Visual Basic 6 Programming
Language
Private Sub cmd_Click()
Text1.Text=“Hello, World!”
End Sub
You cannot apply the rules of Visual Basic Programming Language
in C or Java .
Definition of Programming Language
Language used to instruct a computer to
perform a specific task called __________.
Definition of Programming Language
Languages often are designed for specific purposes, such as
scientific applications, business solutions or web page
development
Definition of Programming Language
Answer all the questions
What is computer program ? Give two examples of computer programs.
What is programming Language ?
Explain the function of programming language.
Levels and Generations Of
Programming Languages
2 levels of programming languages
•
•
Low-level language
High-level language
Low-level language
– A language that is machine-dependent.
– A machine-dependent language runs on only one particular type of machine.
These programs are not easily portable to other types of computers.
– Each language instruction in low-level language usually equates to a single
machine instruction.
Levels and Generations Of
Programming Languages
High-level language
– A language that is machine-independent.
– A machine-independent language runs on different types of machines and
operating system.
– Each language instruction in high-level language usually equates to multiple
machine instructions.
Levels and Generations Of
Programming Languages
• Based on the text in slide 11 & 12, complete the table below.
The differences between low-level language and high-level language
Low-level language
High-level language
Examples Of Programming
Languages
Levels and Generations Of
Programming Languages
Low-level languages
•
2 types:
– Machine Language
– Assembly Language
High-level languages
•
3 types:
– Third-generation language (3GL)
– Fourth-generation language (4GL)
– Fifth-generation language (5GL)
Levels and Generations Of
Programming Languages
Machine Language
– First generation programming language
– The only language the computer directly
recognizes. Therefore, a machine
language program does not require a
translator.
Levels and Generations Of
Programming Languages
Machine Language
– The instructions in machine language
use a series of binary digits (1s and 0s)
or a combination of numbers and letters
that represents binary digits.
– Readily understood by computers; less
intelligible by humans
– Coding in machine language is tedious
and time-consuming.
Levels and Generations Of
Programming Languages
Assembly Language
– 2nd generation programming language
The instructions use :
Symbolic address (meaningful name)
to identify the storage location
symbolic instruction codes
(meaningful abbreviations).
Example:
Example:
Use the name RATE to refer to the storage
location that contains a pay rate.
A for addition, C for Compare, L for
Load and M for multiply.
Levels and Generations Of
Programming Languages
Assembly Language
Low-level Programming Languages
Assembly Language
– The assembly language is not the
native language of computer. Thus,
the program must be converted into
machine language using a translator
called assembler, before a
computer can execute/run it .
– Easier to code as compared to
machine language. But it can still be
difficult to learn.
“The computer cannot directly run the assembly
source program.”
High-level Programming Languages
Third-Generation Language
– Procedural language
– The instructions in 3GL use a series of
English-like words.
– Many 3GLs also use arithmetic
operators such as * for multiplication
and + for addition.
Programmers writes the
instructions that tell the
computer what to
accomplish and how to
do it.
The program is based on
a logical step-by-step
process for solving a
problem.
High-level Programming Languages
Third-Generation Language
– The 3GL is not the native language of computer. Thus, the program
must be converted into machine language using a translator either
compiler or interpreter, before a computer can execute/run it .
3GL
Compiler /
Interpreter
Machine
language
– Simplify the program development process for programmers. Easier
to code and maintain a program as compared to low-level language.
– Examples:
COBOL, Pascal, C, Fortran, BASIC, C++, Java, ALGOL, Delphi
High-level Programming Languages
Fourth-Generation Language
– Non-procedural language
– Allow people to develop program
with fewer commands
Non-procedural programming
languages allow users and
programmers to specify the
results they want without
specifying how to solve the
problem.
High-level Programming Languages
Fourth-Generation Language
– The instructions in 4GL use English-like words or graphical
environment to retrieve data from files or database.
– Examples
SQL ,Progress 4GL, ColdFusion (web development),
GEMBase, BuildProfessional, FOCUS, Informix-4GL.
High-level Programming Languages
3GL Vs 4GL
Example:
In dBASE, the command List displays all the records in a data file. In secondand third-generation languages, instructions would have to be written to read
each record, test for end of file, place each item of data on screen and go back
and repeat the operation until there are no more records to process.
dBASE 3GL
dBASE 4GL
use customer
do while .not. eof()
list name, address
? name, address
skip
enddo
use customer
list name, address
High-level Programming Languages
Fifth-Generation Language
– 5GLs are designed to make the computer solve the problem for you.
– The programmer only needs to worry about what problems need to
be solved and what conditions need to be met, without worrying
about how to implement a routine or algorithm to solve them.
– mainly used in artificial intelligence research.
– Examples: Prolog, Mercury, OPS5
Assessment
•
Draw a hierarchy chart to classify the generations of each level of programming language.
Programming Language
Example
Self - assessment
Example
Example
Example
Example
Summary
Programming Languages
Generation
Low-level programming languages:
• More technical
• not portable
• less user-friendly
• Run faster
• Lengthy
1GL
Machine Language
High-level programming languages:
• Less technical
• Portable
• More user-friendly
• Run slower
• shorter than 1GL and 2GL
3GLs
Procedural language
2GL
Assembly Language
4GLs
Non-procedural language
5GLs
mainly used in artificial
intelligence research