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

CHAPTER 1- Addtitional Notes

The document provides an overview of programming languages, including their definitions, key concepts, and the importance of studying them. It outlines the five generations of programming languages and various computational paradigms such as imperative, object-oriented, functional, and logic paradigms. Additionally, it discusses language syntax, semantics, and the processes of language translation through interpreters and compilers.

Uploaded by

Putra Hazim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

CHAPTER 1- Addtitional Notes

The document provides an overview of programming languages, including their definitions, key concepts, and the importance of studying them. It outlines the five generations of programming languages and various computational paradigms such as imperative, object-oriented, functional, and logic paradigms. Additionally, it discusses language syntax, semantics, and the processes of language translation through interpreters and compilers.

Uploaded by

Putra Hazim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 27

CHAPTER 1- Additional

Notes

INTRODUCTION
Outline
• Overview of programming languages
• Abstractions in programming languages
• Computational paradigms
• Language definition
• Language translation
• Language design
• A brief history
Overview of programming languages
Overview of programming languages
What is Programming Language?

• It is designed to communicate ideas about algorithms between


people and computers.
• Used to control the behaviour of a machine.
• Have syntax (rules) and semantic (meaning) to define meanings.
• To express algorithm precisely.
3 key concepts
Computation
•Any process that can be carried out by a computer
•Not only mathematical calculation but includes all kinds of computer operation;
data manipulation, text processing & information storage & retrieval

Machine Readability
•It must have simple enough structure to allow an efficient translation
•Is ensured by restricting the structure of a programming language to context-free
language

Human Readability
•It requires a programming language to provide an abstractions of the action of
computer that are easy to understand, even by a person not completely
understand with the underlying details of machines
•Tend to resemble natural languages
Overview of programming languages
Overview of programming languages
Reason for studying Programming Languages:

1. Increase capacity to express ideas


 Available features (control structures, data structures, abstraction, etc) can
limit how programming concepts can be expressed in that language.

2. Improved backgorund for choosing appropriate language


 Experience in many languages can help the programmers to choose more
appropriate languages for new projects

3. Increase ability to learn new languages


 Familiarity with fundamnetals concepts of programming languages makes it
easier to learn new languages

4. Better understanding of the significance of implementation


 Become better programmer by understanding the choices among
programming language constructs and the consequences of those choices.

5. Better use of languages that are already known


6. Overall advancement of computing
Overview of programming languages
5 generations of Programming Languages:

First Generation • Machine language


(1951 – 1957) • Basic language (0 and 1)

Second Generation • Assembly language


• Using abbreviations or easy to
(1958 – 1963) remember words

• High level /Procedural Language


Third Generation
• Fortran, COBOL, Pascal, PL/I,
(1964 – 1969)
Ada, C.

Fourth Generation • Very high level language / problem


(1970 – 1990) oriented

Fifth Generation • Natural languages


(1991 – 2000 and • Can be ordinary human language
beyond) • Can be artificial intelligence field
Programming Paradigm
• A programming paradigm is a paradigmatic style of programming.
• Provides (and determines) the view that the programmer has the
execution of the program.
• Different programming languages advocate different programming
paradigms.
• Some programming languages are designed to support multiple
paradigms.
Programming paradigm
• A programming paradigm is a model for a class of programming
languages that share a set of common characteristics and its
differences.
Computational paradigms
Computational paradigms
• IMPERATIVE PARADIGM

▫ Describes computation in terms of a program state and statements


that change the program state.

▫ Most computer languages are in the imperative style

▫ Key features: stored memory, sequencing, selection, iteration,


array and pointers

▫ Example: FORTRAN, COBOL, Pascal, Algol, BASIC


Computational paradigms
• A programming language is called imperative language if it has the
following properties:

IMPERATIVE LANGUAGE

The sequencial The use of variables The use of


execution of representing the assignment to change
instructions memory locations the values of variables
Computational paradigms
• OBJECT ORIENTED PARADIGM

▫ Based on imperative style with added data + abstraction and


encapsulation.
▫ allowing the programmers to write reusable, extensible code that
operates in a way that mimics the real world, thus allowing
programmer to use their natural intuition about the world to
understand the behavior of a program and construct appropriate
code
▫ Key features: Abstraction, Encapsulation, Polymorphism,
Inheritance
▫ Example: Smalltalk, Java
Computational paradigms
• FUNCTIONAL PARADIGM

▫ Functional programming emphasizes the definition of functions.


▫ Alternative paradigms for describing computation come from
mathematics
▫ Sometimes called applicative language
▫ Involve of actual evaluation of function, passing values as
parameter and return value.
▫ Lambda calculus forms the basis of almost all functional
programming languages.
▫ Key features: no notion, no iteration, no assignment variable but
function and expression and recursive.
▫ Example: Haskell, Miranda, LISP, Scheme
Programming Paradigms
EXAMPLE: SCHEME
Computational paradigms
• LOGIC PARADIGM

▫ Based on symbolic logic


▫ The point of logic programming is to bring the style of
mathematical logic to computer programming
▫ Logic provides way to prove whether the question is true or false.
▫ No need for control abtracttion
▫ Sometimes called declarative programming.
▫ Example: PROLOG
Programming Paradigms
• EXAMPLE: PROLOG
Language definition

Language Syntax Language Semantic


• is like grammar of a natural • Represent only the surface
language structure of a language and thus
is only a small part of a
• Is the description of the ways language definition
different parts of the language
may be combined to form other • It shows the meaning of the
parts language that is more complex
and difficult to describe
• The syntax of almost all precisely
languages is now given using
context-free grammars.
Language Syntax
Example:
An if-statement consists of the word “if” followed by an expression
inside parentheses, followed by a statement, followed by an optional
else part consisting of the word “else” and another statement

<if –statement> ::=


if(<expression>)<statement>
[else<statement>]

The semantic:

An if statement is execute by first evaluating its expression, which must have


arithmetic or pointer type, including all side effects and if it compares unequal
to 0 (false) , the statement following the expression is executed. If there is an else
part, and the expression is 0, the statement following the “else” is executed.
Language Syntax
LEXICAL STRUCTURE

• The structure of the words of the language


• Similar to spelling in a natural language
• Usually called tokens
• Examples of token:

Special
Symbol for
“if” and Identifiers punctuation
operations
“else” / names symbols
(+ and <=)
(; and .)
Language translation

• A programming language must have a translator that accept other


programs written in the language in question and that either
execute them directly or transform them to a form suitable for
execution.

INTERPRETE TRANSLATO
R COMPILER
R
The Interpreter
• The interpreter is a translator that executes a program directly.

• Interpretation is a one step process, which both the program and the
input are provided to the interpreter and the output is obtained.

• An interpreter can be view as a simulator for a machine whose


“machine language” is the language being translated.
The compiler
• Compiler is a translator that produce an equivalent program in a form
suitable for execution.

• Is at least a two-step process
▫ The original program (source program) is the input to the compiler.
▫ A new program (target program) is output from the compiler.
▫ This target program may then be executed

• The target program is a assembly language and must be translated by


assembler into an object program and then linked with other object
programs and loaded into appropriate memory location before it can
be executed.

• sometime the target language is even another programming language.


Compilation process

Target Executabl
Source
Code Further e code
code Compil
e translatio
n

Executab
le code

Processo
Input Output
r
Compilation process

That is possible to have translator that are intermediate between


interpreter and compiler :-

PSEUDOINTERPRETER

Pseudointerpreter: Execute the program without producing a target


program, but they process the entire source program before
execution begin
TRANSLATION PROCESS
• Both compiler and interpreter must perform a similar operations when
translating a source program:-
Lexical Syntax
Semantic
Analyzer analyzer
Analyzer
(scanner) (parser)
Convert the textual
representation of
Determine the Determine the
the program as a
structure of the meaning of a
sequence of
sequence of token program to allow
characters into a
provided to it by the execution or
form that is easier
scanner generation of a
to process
target program to
•Grouping
take place.
character into
tokens , keyword,
identifier,
constant)

You might also like