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
Q

Why do imperative languages match Von Neumann architecture best?

A
  1. Variables model memory cells
  2. Assignment statements model piping
  3. Iteration is efficient
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

What is the fetch-execute-cycle on Von Neumann architecture computer?

A
  1. Initialize program counter
  2. Repeat forever:
  3. Fetch instruction pointed to by counter
  4. Increment counter
  5. Decode instruction
  6. Execute instruction
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

What was the programming paradigm in the 1950s/60s?

A

Simple applications, worry about machine efficiency.

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

What was the program paradigm in the late 60s?

A

People efficiency became important; requiring better readability and control structures.

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

What was the program paradigm in the late 70s?

A

Went from process oriented to data oriented

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

What was the programming paradigm in the mid-1980s?

A

Object oriented programming: Data abstraction + inheritance + polymorphism

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

What are the categories of languages?

A
  1. Imperative
  2. Functional
  3. Logic
  4. Markup/Programming Hybrid
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

What are imperative languages?

A
  • Variables
  • Assignment statements
  • Iteration
  • Object Oriented Programming
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

What are functional languages?

A

Primary means of making computations is by applying functions to given parameters

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

What is object oriented programming?

A

Simplification of data and procedural abstraction and building it into languages.

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

What is range checking?

A

A compiler feature that will prevent you from referencing an element that is out of range of the defined size of an array.

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

What are the language design tradeoffs?

A
  1. Reliability vs. cost of execution
  2. Readability vs. writability
  3. Writability (flexibility) vs. reliability
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

What are the methods of implementation of programming languages?

A
  1. Compilation
  2. Pure interpretation
  3. Hybrid Implementation Systems
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

What are hybrid implementation systems?

A

A compromise between compilers and pure interpreters. High level language translated to intermediate language that allows easy interpretation.

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

What is pure interpretation?

A

Where every line is translated one at a time. It uses more memory and is slower than compilation.

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

What is an example of a hybrid implementation system?

A

Java Bytecode

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

What are the phases of compilation?

A
  1. Lexical Analysis
  2. Syntax Analysis
  3. Semantics Analysis
  4. Code Generation
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
42
Q

What is lexical analysis?

A

A process that converts characters in the source program into lexical units. This is where the symbol table gets created.

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

What is syntax analysis?

A

Transforms lexical units into parse trees, which represent syntax.

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

What is semantics analysis?

A

Attempts to understand the intention of the programmer, generates intermediate code.

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

How many passes are most compilers?

A

2:

  1. Symbol Table (sometimes Syntax)
  2. (sometiems Syntax), Intermediate Code, uses symbol table for code generation
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
46
Q

During which phase in the compilation process can optimization be applied?

A

Semantic Analysis

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

What is a load module?

A

An executable image, the user and system code together

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

What is linking and loading?

A

The process of collecting system program units and linking them to a user program.

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

What is an unresolved reference?

A

When the compiler marks in the symbol table when it is unable to find something

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

What is a linkage editor?

A

Looks in libraries to find reference and updates symbol table with module if found. Otherwise, error out and fail compilation.

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

What is the Von Neumann bottleneck?

A

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.

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

What is a way to get around the Von Neumann bottleneck?

A

Use multiple processors

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

What are the characteristics of Pure Interpretation?

A
  1. No translation (no .exe output)
  2. Easier implementation of programs
  3. Slower execution
  4. Usually requires more space
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
54
Q

What are the characteristics of hybrid implementation systems?

A
  1. Mix of interpreted/compiled
  2. High level program translated to intermediate language that allows easy interpretation
  3. Faster than pure interpretation
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
55
Q

What are some examples of Hybrid Implementation Systems?

A

Initial implementations of Java, Perl.

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

What is the Hybrid Implementation Process?

A
  1. Source Program
  2. Lexical Analyzer
  3. Syntax Analyzer
  4. Intermediate code generator
  5. Interpreter
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
57
Q

What is the Pure Interpretation Process?

A
  1. Source Program
  2. Interpreter
  3. Results
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
58
Q

Where does the descriptor reside?

A

The symbol table

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

What is a data type?

A

A collection of data objects and a set of predefined operations on those objects

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

What is a descriptor?

A

A collection of the attributes of a variable

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

What is an object?

A

An instance of a user-defined (abstract) data type

62
Q

What are primitive data types?

A

Data types not defined in terms of another set of types

63
Q

T/F - Integer is almost always an exact reflection of the hardware so mapping is trivial

A

True

64
Q

What is the IEEE standard for floating point types?

A

754

65
Q

What happens to the sign of the exponent in floating point data types?

A

It is eliminated to save space

66
Q

What are complex data types?

A

Representation of complex numbers where two floats represent the real and imaginary parts

67
Q

What is packing?

A

In terms of CS, storing information using less memory than designated.

68
Q

What are the attributes of the decimal data type?

A
  • Store a fixed number of decimal digits in BCD
  • Adv: Allow a high degree of accuracy
  • Disadv: Has limited range and wastes memory
69
Q

How are boolean types usually implemented?

A

As bytes

70
Q

What are the attributes of the character data type?

A
  • Stored as numeric coding

- Common codings include ASCII, UCS2 and UCS4. Less common EBCDIC.

71
Q

How are strings stored?

A

As sequences of characters

72
Q

What are the design issues to consider about strings?

A

Static vs dynamic, primitive type or special array

73
Q

How are static strings implemented for processing by a language?

A

As a compile time descriptor

74
Q

Do limited dynamic strings need a runtime descriptor?

A

They may in certain cases, C and C++ don’t

75
Q

Do dynamic length strings need a runtime descriptor?

A

Yes

76
Q

What are the components of a static string descriptor?

A

String, Length, Address

77
Q

What are the components of a runtime descriptor for limited dynamic strings?

A

String, Maximum Length, Current Length, Address

78
Q

What is an ordinal type?

A

A type in which the range of possible values can be easily associated with the set of positive integers. Are always discrete.

79
Q

What is the maximum number of subscripts in C++?

A

255

80
Q

What are the reasons arrays moved from static to heap?

A

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
Q

What are the advantages and disadvantages of range checking?

A

Adv - Reliability. Prevents you from going out of bounds.

Disadv - Performance hit (lots of if statement / branching)

82
Q

When are subscript ranges bound?

A

Compile time, generally

83
Q

When does allocation take place?

A

It depends. Declaration is not executable unless initialization is associated with it.

84
Q

What are two ways you can make rectangular multidimensional arrays jagged?

A

1- Array of arrays

2- Allocate as rectangular, keep track of used cells

85
Q

What is array slicing?

A

Using a referencing mechanism to represent a substructure of an array

86
Q

What is array indexing?

A

Mapping from indices to elements

87
Q

When should allocation be performed?

A

Only when you have to. (lazy allocation)

88
Q

In static array binding, how are subscript ranges bound, and what type of allocation is used?

A

Bound statically, and allocation is static

89
Q

What is the advantage to static subscript binding?

A

More efficient - no indirect addressing.

90
Q

In fixed stack-dynamic array binding, how are subscript ranges bound, and what type of allocation is used?

A

Bound statically, allocation done at declaration time (dynamic)

91
Q

What is the advantage to fixed stack-dynamic subscript binding?

A

Space efficiency

92
Q

In fixed heap-dynamic array binding, how are subscript ranges bound, and what type of allocation is used?

A

Bound when requested, dynamic but fixed after allocation, allocated from heap.

93
Q

In heap-dynamic array binding, how are subscript ranges bound, and what type of allocation is used?

A

Bound dynamically, allocation is dynamic, can change any number of times.

94
Q

What is the advantage to fixed stack-dynamic subscript binding?

A

Flexibility (grow or shrink during program execution)

95
Q

How does C/C++ treat arrays declared with static modifier?

A

Makes them static

96
Q

How does C/C++ treat arrays declared without static modifier?

A

Makes them fixed stack-dynamic

97
Q

What type of array other than static and fixed stack-dynamic do C/C++ provide?

A

Fixed heap-dynamic

98
Q

How are heterogeneous arrays implemented?

A

By making every element the same size

99
Q

What is happening behind the scenes when you declare an array of strings?

A

It is declaring an array of addresses that point to strongs

100
Q

What is the base address of an array?

A

The address that refers to the first element.

101
Q

How is data accessed in an array behind the scenes?

A

An access function maps subscript expressions to an address in the array.

102
Q

Is row major order or column major order more commonly used to access array elements/

A

Row Major

103
Q

How does a compiler/interpreter tell the computer to access a specific array element?

A

Offset calculations are used, typically taking into account subscript, row and column lower bound, number of elements and element size

104
Q

What are the elements of a compile-time descriptor for a single dimensioned array?

A
1 Element Type
2 Index Type
3 Index lower bound
4 Index upper bound
5 Address
105
Q

What are the elements of a compile-time descriptor for a multidimensional array?

A
1 Element Type
2 Index Type
3 Number of Dimensions
4 Index range 1
5 Index range n
6 Address
106
Q

What is an associative array?

A

An unordered collection of data elements indexed by keys

107
Q

Why is hashing more useful than associative arrays?

A

Associate arrays require extra steps due to indirect processing

108
Q

What is a record?

A

A potentially heterogeneous aggregate of data elements in which the individual elements are identified by names

109
Q

What is a good analogy for records?

A

Structure

110
Q

When are records used instead of an array?

A

When data is heterogeneous

111
Q

Is access to array elements faster than record fields? Why or why not?

A

No, because subscripts are dynamic and field names are static.

112
Q

How are records spaced out in memory?

A

An offset address relative to the beginning of the records is associated with each field

113
Q

Where are record layouts stored?

A

In the symbol table

114
Q

What is a union?

A

A type whose variables are allowed to store different type values at different times during execution

115
Q

Can union type checking be performed by a compiler? An interpreter?

A

No.

Yes.

116
Q

In what language are unions safe?

A

Ada

117
Q

In what languages are unions unsafe?

A

Almost all except Ada

118
Q

What is a set?

A

Unordered collections of distinct values of an ordinal type

119
Q

How are sets stored?

A

As bit strings

120
Q

How are set operations defined?

A

Usually as logical operations

121
Q

How do arrays compare to sets?

A

They are more flexible but slower.

122
Q

What values can pointers contain?

A

Memory addresses, and nil

123
Q

What are reference types?

A

A special kind of pointer type used primarily for formal parameters

124
Q

What are examples of heap management algorithms?

A

First fit, best fit, largest fit (worst fit)

125
Q

What is BNF?

A

Backus-Naur form, a formal description of the syntax of source language

126
Q

What are the two components in syntax analysis?

A
  1. Lexical Analyzer

2. Syntax Analyzer (Parser)

127
Q

What is a lexical analyzer, mathematically?

A

A finite automaton based on a regular grammar

128
Q

What is a syntax analyzer, mathematically?

A

A push down automaton based on a context free grammar (BNF)

129
Q

How do compilers and intepreters display syntax errors differently?

A

Compilers show all syntax errors at once, while interpreters show syntax errors one at a time

130
Q

Why is BNF used for parsers?

A

It usually results in easy translation back and forth between the BNF and parse tree.

131
Q

Why is lexical and syntax analysis often separated?

A

Simplicity - Enables simplification of the parser
Efficiency - Enables optimization of the lexical analyzer
Portability - Parser always portable, parts of lexer may not be

132
Q

Why is the parser always portable?

A

Because it is just matching lexed input up to a parse tree.

133
Q

What are lexemes?

A

Substrings of a source program that belong together. They match a character pattern and fit into a lexical category called a token.

134
Q

How do a parser and lexer fit together functionally?

A

The lexer generates strings, identifies tokens of lexemes and passes information to parser.

135
Q

How is a lexical analyzer usually implemented?

A

As a function called by the parser when it needs the next token

136
Q

What are the three approaches to building a lexer?

A
  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
Q

What are the goals of the parser?

A
  1. Find syntax errors, output error message, recover quickly

2. Produce parse tree or trace of parse tree

138
Q

What does a top down parser do?

A

Produces parse tree beginning at root. Uses leftmost derivation & builds tree in preorder.

139
Q

What does a bottom up parser do?

A

Produces parse tree beginning at leaves, uses reverse of rightmost derivation.

140
Q

How does recursive descent parsing work?

A

There is a subprogram for each NT in grammar, which can parse sentences generated by NT.

141
Q

Why is EBNF ideally suited for being basis for an RD parser?

A

EBNF minimizes number of nonterminals.

142
Q

What is coding process when only one RHS?

A

1 For each terminal symbol, compare to next input token. Continue if match, else error.
2 For each nonterminal call associated parsing subprogram

143
Q

How is the correct RHS chosen?

A

On basis of the next token of input (lookahead)

144
Q

What are the phases of a hybrid implementation process?

A
1 Source
2 Lexer
3 Parser
4 Intermediate code gen
5 Interpreter
145
Q

How does just in time work?

A
  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
Q

What does a preprocessor do?

A

Processes a program immediately before program is compiled to expand embedded preprocessor macros. Allows you to embed code from one language inside another.

147
Q

What language was the basis for most current commonly used programming languages?

A

FORTRAN

148
Q

What are the issues with using machine code to program?

A

1 Poor readability
2 Poor modifiability
3 Tedious coding
4 Machine deficiencies (indexing/ floating point)

149
Q

What language led to the idea of compiled programming languages?

A

FORTRAN

150
Q

When is a grammar ambiguous?

A

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
Q

What is the difference between a keyword and a reserved word?

A

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.