Week 1 Flashcards
When was the invention of the Diffrence Engine
1822
How many stages have the computer languages of the last fifty years come to
Two: The first major language and the second major languages
What is a programming language
A programming language is an artificial
language designed to express computations or
algorithms that can be performed by a
computer
What is a program
A program is computer coding of
an algorithm that
– Takes input
– Performs some calculations on
the input
– Generates output
factorial program in C
int fact(int n) {
int sofar = 1;
while (n>0) sofar *= n–;
return sofar;
}
Master the von Neumann Architecture
Key Features of von Neumann Architecture
- Data and programs stored in memory
– Instructions and data are piped from memory to CPU
– Fetch-execute-cycle for each machine instruction
Describe the fetch-execute cycle
initialize the program counter (PC)
repeat forever
fetch the instruction pointed by PC
increment the counter
decode the instruction
execute the instruction
end repeat
Mention some programmnig languages that mimic von neumann architecture
C, C++ Java
How do these programming languages micmic the von neumman architecture
– Variables → memory cells
– Assignment statements → data piping between
memory and CPU
– Operations and expressions → CPU executions
– Explicit control of execution flows → prog. counter
The architecture is limited by?
Allow efficient mapping between language and
hardware for good execution performance, but
limited by von Neumann bottleneck
How old is LISP
LISP is the second oldest general programming language
that is still in use since 1958
Give a summary of imperative langauge
– Variables, assignment statements, and iteration
– Include languages that support object-oriented
programming, scripting languages, visual languages
– Ex.: C, Java, Perl, JavaScript, Visual BASIC .NE
Give a summary of functional language
– Computing by applying functions to given parameters
– Ex.: LISP, Scheme, ML
Give a sumary of logic language
– Rule-based (rules are specified in no particular order)
– Ex.: Prolog
Mention the Programming Design Methodology
- 1950s and early 1960s: simple applications; worry
about machine efficiency (FORTRAN) - Late 1960s: people efficiency important;
readability, better control structures (ALGOL)
– Structured programming, free format lexical
– Top-down design and step-wise refinement - Late 1970s: process-oriented to data-oriented
– Data abstraction - Middle 1980s: object-oriented programming
– Data abstraction + inheritance + dynamic binding
What makes a good PL
- Readability: the ease with which programs can
be read and understood - Writability: the ease with which a language
can be used to create programs - Reliability: a program performs to its
specifications under all conditions - Cost
Mention features related to readablity
Overall Simplicity
Orthogonality
Control Statements
Data types and structures
Syntax consideration
Mention features related to writability
Simplicity and orthogonality
Support for abstraction
Expressivity
Mention features related to reliablity
Type checking
Exception handling
Aliasing
Readability and writability
Mention features related to cost
Training programmers to use language
Compiling programs
Executing programs: runtime type checking
Language implementation system
reliability: poor reliability leads to high cost
Maintaining programs
Mention other things that make a good PL
- Portability
– The ease with which programs can be moved from
one implementation to another - Generality
– The applicability to a wide range of applications - Well-definedness
– The completeness and precision of the language’s
official definition - Power efficiency?
Describe compilation
Translate a high-level program into equivalent
machine code automatically by another program
(compiler)
Mention the phase of compilation
Lexical analysis: converts characters in the source
program into lexical units
– Syntax analysis: transforms lexical units into parse
trees which represent syntactic structure of program
– Semantics analysis: generate intermediate code
– Code generation: machine code is generated
– Link and load
Describe interprtation
- Program interpreted by another program
(interpreter) without translation
– Interpreter acts a simulator or virtual machine - Easier implementation of programs (run-time
errors can easily and immediately displayed) - Slower execution (10 to 100 times slower than
compiled programs) - Often requires more space
- Popular with some Web scripting languages (e.g.,
JavaScript)