1/31
Programming Paradigms
what are the drawbacks of assembly language?
lacks abstaction and machine specific
algol
defined standard notation for algorithms
von neumann model
sequentially execute instructions fetched from a memory unit where both programs and data is stored
von neumann bottleneck
CPU must wait for data to be transferred to/from memory which lowers effective processing speed
imperative language
sequential execution of instructions/commands, describes the steps towards the solution
procedural language
imperative language structured into procedures/functions
declarative languages
program describes the solution itself instead of how to get to it
examples of imperative paradigms
python, c, javascript, java
examples of functional paradigms
scheme, haskell, python, javascript
examples of logic paradigms
prolog
examples of object oriented paradigms
java, python, javascript
programming language syntax
sets rules of the language and defines which sequence of characters form valid paradigms
programming language semantics
describes the meaning of a language and the effects of executing the code
Is the following an example of imperative programming:
first = 5;
second = 6;
total = first + second;
first = 7;
print(total);
first = 1;
print(total);
true
The following program is an example of:
more_input = true;
while more_input:
first=get_input();
second = get_input();
total = add(first, second);
report(total);
more_input = false
both imperative and procedural
Which of the following contains a lexical error in Python?
grade?=95
How many tokens in grade = 95?
3
How many tokens in grade=95?
3
How many tokens in grade?=95?
2
What criteria should be used to judge a language?
Efficiency, Regularity, Security, Extensibility
What was the main concern for programming languages in the 60s?
writeability and readability
What was the main concern for programming languages in the 70s & 80s?
simplicity and abstraction
What was the main concern for programming languages in the 80s & 90s?
logical and mathematical precision
What was the main concern for programming languages in the last 25 years?
object oriented abstraction
Design Criteria: Efficiency
traditionally the efficiency of execution, now leans towards programmers efficiency with how quickly and easily a programmer can write/read in a language
Design Criteria: Regularity
how well the features of a language are integrated; greater regularity implies less surprises
Design Criteria: Security
reliability enhanced through imposing restrictions
Design Criteria: Extensibility
ability to add features to the language
What was the primary design concern in the older days when machines were slow and memory was scarce?
efficiency of execution
Which of the following has a more efficient execution?
JAVA
int first, int second;
first = 30;
second = 35;
total = first + second;
Which of the following has better programmers efficiency?
PYTHON
print(“Hello World!”)