Module 1 - Background Concepts Lecture Notes
Module 1 - Background Concepts Lecture Notes
Concepts
IS 214 - Principles of Programming Languages - 1st Sem AY
2020-2021
Objectives
2
What is a Programming Language?
https://files.virgool.io/upload/users/8875/posts/mrh9yu1k0r
wf/kp0gsnfhzmp7.jpeg
3
Hello World in Assembly
dosseg
.model small
.stack 100h
.data
hello_message db 'Hello, World!',0dh,0ah,'$’
.code
main proc
mov ax,@data
mov ds,ax
mov ah,9
mov dx, offset hello_message
int 21h
mov ax,4C00h
int 21h
main endp
end main 4
Hello World in COBOL
IDENTIFICATION DIVISION.
PROGRAM-ID. Hello.
ENVIRONMENT DIVISION.
DATA DIVISION.
PROCEDURE DIVISION.
Display 'Hello, World'.
STOP RUN.
5
Hello World in Java and Python
Java: Python:
public class Hello print("Hello World")
{
public static void main(String args[])
{
System.out.println("Hello World");
}
}
6
Hello World in Scheme and LOLCODE
Scheme: LOLCODE:
7
Hello World in brainf*ck
/e+++++++++++++++++++++++++++++.\
./\/\/\ /+++\!>.+++o.l.+++++++l/
#/?\
$H!\++++++\ + \comma.------------
.<w++++++++.\ /?\<!\-/
/++++++/ +/\ /.--------o/ \-
/!.++++++++++/?\n
/=\++++++\ +\\!=++++++\
.d--------.>+.!\-/ \r+++.l------
\!\/\/\/\/ \++++++++++/
8
Reasons for Studying PL’s
9
Programming Languages
1950-1970
● Numerically-based languages
● Business languages
● Artificial intelligence languages
● System languages
10
Numerically-based Languages
Examples:
11
Business Languages
Examples:
12
Artificial Intelligence Languages
Examples:
• LISP
➔ First major language to support list
processing.
➔ First major language to support recursion.
➔ First functional language.
13
Systems Languages
14
Programming Languages
1971-1990
15
Programming Languages (1971-1990)
16
Programming Languages (1971-1990)
17
Ancestry Chart
18
Programming Domains
● Scientific applications
● Business application
● Artificial intelligence
● Systems programming
● Scripting languages
● Special-purpose languages
19
Language Evaluation
Criteria
20
Language Evaluation Criteria
1. Readability
○ Is it easy to read and understand a program or a portion of it in a written in the
language?
2. Writability
○ Is it easy to write programs in the language?
3. Reliability
○ Does the program help prevent errors?
4. Cost
○ How expensive is it to develop, use, and maintain programs written in the
language?
21
Readability Factors
● Overall simplicity
○ Too many features are bad
○ Multiplicity of features is bad
● Orthogonality
○ A relatively small set of primitive constructs can be combined in a relatively small
number of ways to build the control and data structures of the language
○ Makes the language easy to learn and read.
○ Meaning is context independent.
○ Every possible combination is legal.
○ Lack of orthogonality leads to exception to rules.
22
Readability Factors
● Control statements
● Defining data types and structures
● Syntax considerations
○ Identifier forms
○ Special words
○ Form and meaning
23
Writability Factors
24
Reliability Factors
● Type checking
● Exception handling
● Aliasing
● Readability and writability
25
Cost Factors
26
● When writability is enhanced,
readability suffers.
● When the program helps prevent
errors, what does that mean?
27
Classifying Programming
Languages
28
Classifying PL’s according to...
1. Levels of abstraction
2. Generations
3. Programming paradigms
4. Methods of implementation
29
1. Levels of Abstraction
Memory Handling Direct memory Memory access and Fully hidden memory
access and allocation allocation through access and
operations automatic allocation
31
3. Programming Paradigms
1. Imperative
○ “How is it to be achieved”
○ To solve a problem, we specify the step-by-step procedure.
○ Central features are variables, assignment statements, and iteration.
a. Block-structured
■ The procedure is the principal building block of the program
■ Represented by stack
■ Examples: Pascal, C
b. Object-oriented
■ Languages that employ objects.
■ An object is a group of procedures that share a state.
■ Examples: Java, Modula
32
3. Programming Paradigms
2. Declarative
○ “What is to be achieved”
○ Program requires specification of a relation or function.
○ Mainly based on math concepts on logic, theory on functions and relational calculus.
a. Logic
■ Based on a subset of predicate calculus.
■ Axioms and rules are used to deduce new facts.
■ Example: Prolog
b. Functional
■ Operate only through functions that return one value given a list of parameters
■ Example: LISP
33
4. Methods of Implementation
1. Compilation - method where a high level language is translated into another implemented language.
Approaches:
34
● Why were programming
languages born?
● Why are there so many
programming languages out
there?
35