Lecture 1 Flashcards

1
Q

Why are different programming languages written?

A

To solve different problems. Different tools for different reasons.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are some general purpose languages?

A

C++, C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the characteristics of abstraction?

A
  1. Encapsulation

2. Information Hiding

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the types of abstraction?

A
  1. Data

2. Procedural

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does an optimizer do?

A

Places statements pertaining to the same data close to one another in memory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the three language constructs?

A

Repetition, sequence, condition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What percentage of a company’s budget is spent on maintenance vs. on development?

A

80 % on maintenance.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a unit of work?

A

Do the entire unit of work or do nothing. Ex: ATM. Attempts transaction and backs everything out if there is an issue.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is aliasing?

A

Referring to memory addresses using different types and different symbolic names

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is perfective maintenance?

A

Enhancements

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is protective maintenance?

A

Security

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is adaptive maintenance?

A

Changing technology without changing functionality

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is corrective maintenance?

A

Fixing bugs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Why is compiling programs a cost?

A

Separation of duties. You have individual employees dealing with the build process.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is reliability?

A

Conformance to specifications

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does overall simplicity mean?

A

A manageable set of features and constructs, minimal feature multiplicity, minimal operator overloading

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is orthogonality?

A

A relatively small set of primitive constructs can be combined in a relatively small number of ways. Optimally, every possible combination is legal.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is abstraction?

A

The ability to define and use complex structures or operations in ways that allow details to be ignored.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is expressivity?

A

The breadth of ideas that can be represented and communicated in the language.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What is portability?

A

The ease with which programs can be moved from one implementation to another.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What is generality?

A

The applicability to a wide range of applications.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What computer architecture are programming languages developed around?

A

The Von Neumann architecture

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

When did the Von Neumann architecture come into ues?

A

1940-1950

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What are the characteristics of the Von Neumann architecture?

A
  1. Data and programs stored in memory
  2. Memory is separate from CPU
  3. Instructions and data are piped from memory to CPU
  4. Imperative languages match Von Neumann architecture best.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Why do imperative languages match Von Neumann architecture best?
1. Variables model memory cells 2. Assignment statements model piping 3. Iteration is efficient
26
What is the fetch-execute-cycle on Von Neumann architecture computer?
1. Initialize program counter 2. Repeat forever: 3. Fetch instruction pointed to by counter 4. Increment counter 5. Decode instruction 6. Execute instruction
27
What was the programming paradigm in the 1950s/60s?
Simple applications, worry about machine efficiency.
28
What was the program paradigm in the late 60s?
People efficiency became important; requiring better readability and control structures.
29
What was the program paradigm in the late 70s?
Went from process oriented to data oriented
30
What was the programming paradigm in the mid-1980s?
Object oriented programming: Data abstraction + inheritance + polymorphism
31
What are the categories of languages?
1. Imperative 2. Functional 3. Logic 4. Markup/Programming Hybrid
32
What are imperative languages?
- Variables - Assignment statements - Iteration - Object Oriented Programming
33
What are functional languages?
Primary means of making computations is by applying functions to given parameters
34
What is object oriented programming?
Simplification of data and procedural abstraction and building it into languages.
35
What is range checking?
A compiler feature that will prevent you from referencing an element that is out of range of the defined size of an array.
36
What are the language design tradeoffs?
1. Reliability vs. cost of execution 2. Readability vs. writability 3. Writability (flexibility) vs. reliability
37
What are the methods of implementation of programming languages?
1. Compilation 2. Pure interpretation 3. Hybrid Implementation Systems
38
What are hybrid implementation systems?
A compromise between compilers and pure interpreters. High level language translated to intermediate language that allows easy interpretation.
39
What is pure interpretation?
Where every line is translated one at a time. It uses more memory and is slower than compilation.
40
What is an example of a hybrid implementation system?
Java Bytecode
41
What are the phases of compilation?
1. Lexical Analysis 2. Syntax Analysis 3. Semantics Analysis 4. Code Generation
42
What is lexical analysis?
A process that converts characters in the source program into lexical units. This is where the symbol table gets created.
43
What is syntax analysis?
Transforms lexical units into parse trees, which represent syntax.
44
What is semantics analysis?
Attempts to understand the intention of the programmer, generates intermediate code.
45
How many passes are most compilers?
2: 1. Symbol Table (sometimes Syntax) 2. (sometiems Syntax), Intermediate Code, uses symbol table for code generation
46
During which phase in the compilation process can optimization be applied?
Semantic Analysis
47
What is a load module?
An executable image, the user and system code together
48
What is linking and loading?
The process of collecting system program units and linking them to a user program.
49
What is an unresolved reference?
When the compiler marks in the symbol table when it is unable to find something
50
What is a linkage editor?
Looks in libraries to find reference and updates symbol table with module if found. Otherwise, error out and fail compilation.
51
What is the Von Neumann bottleneck?
The connection speed between a computer's memory and its processor determines the speed of a computer. Since instructions can be executed faster than the speed of the connection, a bottleneck is created.
52
What is a way to get around the Von Neumann bottleneck?
Use multiple processors
53
What are the characteristics of Pure Interpretation?
1. No translation (no .exe output) 2. Easier implementation of programs 3. Slower execution 4. Usually requires more space
54
What are the characteristics of hybrid implementation systems?
1. Mix of interpreted/compiled 2. High level program translated to intermediate language that allows easy interpretation 3. Faster than pure interpretation
55
What are some examples of Hybrid Implementation Systems?
Initial implementations of Java, Perl.
56
What is the Hybrid Implementation Process?
1. Source Program 2. Lexical Analyzer 3. Syntax Analyzer 4. Intermediate code generator 5. Interpreter
57
What is the Pure Interpretation Process?
1. Source Program 2. Interpreter 3. Results
58
Where does the descriptor reside?
The symbol table
59
What is a data type?
A collection of data objects and a set of predefined operations on those objects
60
What is a descriptor?
A collection of the attributes of a variable
61
What is an object?
An instance of a user-defined (abstract) data type
62
What are primitive data types?
Data types not defined in terms of another set of types
63
T/F - Integer is almost always an exact reflection of the hardware so mapping is trivial
True
64
What is the IEEE standard for floating point types?
754
65
What happens to the sign of the exponent in floating point data types?
It is eliminated to save space
66
What are complex data types?
Representation of complex numbers where two floats represent the real and imaginary parts
67
What is packing?
In terms of CS, storing information using less memory than designated.
68
What are the attributes of the decimal data type?
- Store a fixed number of decimal digits in BCD - Adv: Allow a high degree of accuracy - Disadv: Has limited range and wastes memory
69
How are boolean types usually implemented?
As bytes
70
What are the attributes of the character data type?
- Stored as numeric coding | - Common codings include ASCII, UCS2 and UCS4. Less common EBCDIC.
71
How are strings stored?
As sequences of characters
72
What are the design issues to consider about strings?
Static vs dynamic, primitive type or special array
73
How are static strings implemented for processing by a language?
As a compile time descriptor
74
Do limited dynamic strings need a runtime descriptor?
They may in certain cases, C and C++ don't
75
Do dynamic length strings need a runtime descriptor?
Yes
76
What are the components of a static string descriptor?
String, Length, Address
77
What are the components of a runtime descriptor for limited dynamic strings?
String, Maximum Length, Current Length, Address
78
What is an ordinal type?
A type in which the range of possible values can be easily associated with the set of positive integers. Are always discrete.
79
What is the maximum number of subscripts in C++?
255
80
What are the reasons arrays moved from static to heap?
1 Dynamic arrays became more useful and viable 2 More heap memory available in total 3 Better hardware, so heap access is faster 4 Able to reference by address
81
What are the advantages and disadvantages of range checking?
Adv - Reliability. Prevents you from going out of bounds. | Disadv - Performance hit (lots of if statement / branching)
82
When are subscript ranges bound?
Compile time, generally
83
When does allocation take place?
It depends. Declaration is not executable unless initialization is associated with it.
84
What are two ways you can make rectangular multidimensional arrays jagged?
1- Array of arrays | 2- Allocate as rectangular, keep track of used cells
85
What is array slicing?
Using a referencing mechanism to represent a substructure of an array
86
What is array indexing?
Mapping from indices to elements
87
When should allocation be performed?
Only when you have to. (lazy allocation)
88
In static array binding, how are subscript ranges bound, and what type of allocation is used?
Bound statically, and allocation is static
89
What is the advantage to static subscript binding?
More efficient - no indirect addressing.
90
In fixed stack-dynamic array binding, how are subscript ranges bound, and what type of allocation is used?
Bound statically, allocation done at declaration time (dynamic)
91
What is the advantage to fixed stack-dynamic subscript binding?
Space efficiency
92
In fixed heap-dynamic array binding, how are subscript ranges bound, and what type of allocation is used?
Bound when requested, dynamic but fixed after allocation, allocated from heap.
93
In heap-dynamic array binding, how are subscript ranges bound, and what type of allocation is used?
Bound dynamically, allocation is dynamic, can change any number of times.
94
What is the advantage to fixed stack-dynamic subscript binding?
Flexibility (grow or shrink during program execution)
95
How does C/C++ treat arrays declared with static modifier?
Makes them static
96
How does C/C++ treat arrays declared without static modifier?
Makes them fixed stack-dynamic
97
What type of array other than static and fixed stack-dynamic do C/C++ provide?
Fixed heap-dynamic
98
How are heterogeneous arrays implemented?
By making every element the same size
99
What is happening behind the scenes when you declare an array of strings?
It is declaring an array of addresses that point to strongs
100
What is the base address of an array?
The address that refers to the first element.
101
How is data accessed in an array behind the scenes?
An access function maps subscript expressions to an address in the array.
102
Is row major order or column major order more commonly used to access array elements/
Row Major
103
How does a compiler/interpreter tell the computer to access a specific array element?
Offset calculations are used, typically taking into account subscript, row and column lower bound, number of elements and element size
104
What are the elements of a compile-time descriptor for a single dimensioned array?
``` 1 Element Type 2 Index Type 3 Index lower bound 4 Index upper bound 5 Address ```
105
What are the elements of a compile-time descriptor for a multidimensional array?
``` 1 Element Type 2 Index Type 3 Number of Dimensions 4 Index range 1 5 Index range n 6 Address ```
106
What is an associative array?
An unordered collection of data elements indexed by keys
107
Why is hashing more useful than associative arrays?
Associate arrays require extra steps due to indirect processing
108
What is a record?
A potentially heterogeneous aggregate of data elements in which the individual elements are identified by names
109
What is a good analogy for records?
Structure
110
When are records used instead of an array?
When data is heterogeneous
111
Is access to array elements faster than record fields? Why or why not?
No, because subscripts are dynamic and field names are static.
112
How are records spaced out in memory?
An offset address relative to the beginning of the records is associated with each field
113
Where are record layouts stored?
In the symbol table
114
What is a union?
A type whose variables are allowed to store different type values at different times during execution
115
Can union type checking be performed by a compiler? An interpreter?
No. | Yes.
116
In what language are unions safe?
Ada
117
In what languages are unions unsafe?
Almost all except Ada
118
What is a set?
Unordered collections of distinct values of an ordinal type
119
How are sets stored?
As bit strings
120
How are set operations defined?
Usually as logical operations
121
How do arrays compare to sets?
They are more flexible but slower.
122
What values can pointers contain?
Memory addresses, and nil
123
What are reference types?
A special kind of pointer type used primarily for formal parameters
124
What are examples of heap management algorithms?
First fit, best fit, largest fit (worst fit)
125
What is BNF?
Backus-Naur form, a formal description of the syntax of source language
126
What are the two components in syntax analysis?
1. Lexical Analyzer | 2. Syntax Analyzer (Parser)
127
What is a lexical analyzer, mathematically?
A finite automaton based on a regular grammar
128
What is a syntax analyzer, mathematically?
A push down automaton based on a context free grammar (BNF)
129
How do compilers and intepreters display syntax errors differently?
Compilers show all syntax errors at once, while interpreters show syntax errors one at a time
130
Why is BNF used for parsers?
It usually results in easy translation back and forth between the BNF and parse tree.
131
Why is lexical and syntax analysis often separated?
Simplicity - Enables simplification of the parser Efficiency - Enables optimization of the lexical analyzer Portability - Parser always portable, parts of lexer may not be
132
Why is the parser always portable?
Because it is just matching lexed input up to a parse tree.
133
What are lexemes?
Substrings of a source program that belong together. They match a character pattern and fit into a lexical category called a token.
134
How do a parser and lexer fit together functionally?
The lexer generates strings, identifies tokens of lexemes and passes information to parser.
135
How is a lexical analyzer usually implemented?
As a function called by the parser when it needs the next token
136
What are the three approaches to building a lexer?
1. Write formal description of tokens and use software tool to create a table-driven lexer from description 2. Design state diagram that describes tokens and write program that implements state diagram 3. Design state diagram that describes tokens and hard-construct a table implementation of state diagram
137
What are the goals of the parser?
1. Find syntax errors, output error message, recover quickly | 2. Produce parse tree or trace of parse tree
138
What does a top down parser do?
Produces parse tree beginning at root. Uses leftmost derivation & builds tree in preorder.
139
What does a bottom up parser do?
Produces parse tree beginning at leaves, uses reverse of rightmost derivation.
140
How does recursive descent parsing work?
There is a subprogram for each NT in grammar, which can parse sentences generated by NT.
141
Why is EBNF ideally suited for being basis for an RD parser?
EBNF minimizes number of nonterminals.
142
What is coding process when only one RHS?
1 For each terminal symbol, compare to next input token. Continue if match, else error. 2 For each nonterminal call associated parsing subprogram
143
How is the correct RHS chosen?
On basis of the next token of input (lookahead)
144
What are the phases of a hybrid implementation process?
``` 1 Source 2 Lexer 3 Parser 4 Intermediate code gen 5 Interpreter ```
145
How does just in time work?
1. Translate programs into intermediate language 2. Compile intermediate language into machine code WHEN PROGRAMS ARE CALLED 3 Machine code version kept for subsequent calls
146
What does a preprocessor do?
Processes a program immediately before program is compiled to expand embedded preprocessor macros. Allows you to embed code from one language inside another.
147
What language was the basis for most current commonly used programming languages?
FORTRAN
148
What are the issues with using machine code to program?
1 Poor readability 2 Poor modifiability 3 Tedious coding 4 Machine deficiencies (indexing/ floating point)
149
What language led to the idea of compiled programming languages?
FORTRAN
150
When is a grammar ambiguous?
When two parse trees can be produced from the same input. It occurs when a rule has the same nonterminal multiple times in the same RHS.
151
What is the difference between a keyword and a reserved word?
A keyword is only special in certain contexts. A reserved word is always special and cannot be used in user-defined names. It is a subset of keyword.