Comp Lang Midterm Prep

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/120

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

121 Terms

1
New cards

Why do we study programming languages

More ways to express idea, more information when choosing a language for a problem, easier to learn the next language, better idea of how languages work under the hood.

2
New cards

What are the programming domains?

Scientific computing, business computing, AI, Systems programming, web programming, entertainment.

3
New cards

What are the 4 language criteria and how are they related?

Readability, writability, reliability, cost

4
New cards

What are the influences on language design?

System Architecture and programming needs.

5
New cards

What are the language design trade-offs?

•Reliability vs. cost of execution

•Readability vs. writability

•Writability (flexibility) vs. reliability

6
New cards

What are the main implementation methods for programming languages?

Compiled

Interpreted

Hybrid

7
New cards

What are the major paradigms of programming?

Procedural

Functional

Logical/declarative

Object Oriented

8
New cards

What is the general timeline for programming languages?

fortran -> algol -> C -> java/python

9
New cards

What languages broadly influence what other language

1) C influences Python, as python is just scripted C

10
New cards

What are some early pre-cursors of programming languages?

Plankalkul

Pseudocodes

FORTRAN

LISP

ALGOL

11
New cards

What was the first compiling system?

UNIVAC

12
New cards

Fortran...what were it's major additions to programming languages?

First compiled language

Accessibility

Portability

13
New cards

Functional programming...why was it created and what language came first?

Created to handle list processing and AI. Lisp was first

14
New cards

Algol...why is it such an important language?

It was the first attempt at a universal programming langauge

First use of BNF

15
New cards

Cobol...what is it's purpose and what did it add to programming languages?

Used for business computing, has executable operations and data definition

16
New cards

Why is Basic an important language?

First widely adopted programming language for home computers, and it was easy to learn.

17
New cards

What did PL/I get wrong?

Many new features were poorly designed

Too large and too complex

18
New cards

Why was ADA successful?

Because it was used in the defense industry for a long time due to gov requirements.

19
New cards

What was the first OO language?

Simula, smalltalk was also early

20
New cards

What is syntax?

The arrangement of words and phrases to create well-formed sentences in a language.

21
New cards

What is semantics?

Meaning of words and sentences

22
New cards

How do we describe sentences?

A finite set of symbols

23
New cards

What are lexemes?

lowest level syntactic unit of a language

24
New cards

What are tokens

A category of lexemes

25
New cards

What is the test for language ambiguity?

If you can create more than one unique parse tree for a sentence, then the language is ambiguous

26
New cards

When analyzing a program for syntactical correctness, what are the two major steps? Why are these two steps usually separated?

Lexical analysis, then parsing. Separating them makes designing the compiler simple.

27
New cards

What are the two major approaches to syntax analysis?

Top down parsing and bottom up parsing.

28
New cards

What is the most common top-down parsing method? What is the shortcoming of this method?

Recursive descent parser. It is bad at handling ambiguity.

29
New cards

What is the most common bottom-up parsing algorithm?

shift reduce parsing

30
New cards

What are the design issues related to names?

Are names case sensitive?

Are special words reserved words or keywords?

31
New cards

What is the sextuple of attributes for a variable?

1) Name

2) address

3) value

4) type

5) lifetime

6) scope

32
New cards

When considering the address of a variable, what is an alias?

When multiple variable names or expressions can be used to access the same location in memory.

33
New cards

What is a data type?

indicates the type of data a memory location (variable or named constant) can store

34
New cards

What are the two broad categories of binding?

Static, dynamic

35
New cards

What is scope?

Where a variable is legal to reference in code

36
New cards

What is lifetime?

How long a variable stays in memory

37
New cards

How is static scope used to determine the value of a variable?

Value of a variable is determined at definition

38
New cards

How is dynamic scope used to determine the value of a variable?

Value of a variable is determined at execution

39
New cards

What is a referencing environment and how is it used to determine the value of a variable?

the collection of all variables that are "visible" and accessible at a specific point in a program

40
New cards

What is a variables descriptor?

the collection of the attributes of a variable

41
New cards

What is a primitive data type?

A data type not made up of any other data types

42
New cards

What are some examples of primitive data types?

Int, boolean, char, float

43
New cards

How are primitive data types stored or represented?

Binary encodings

44
New cards

For character/string data types, what are the major design issues?

Static vs dynamic length

Character array vs primitive type

45
New cards

What is an array?

A data structure with one, or more, elements of the same type

46
New cards

What are the design issues associated with arrays?

fixed size, inflexible memory management, inefficient manipulation of elements

47
New cards

What is a rectangular array?

An array where all rows are the same length

48
New cards

What is a jagged array?

An array where all rows are different lengths

49
New cards

What is a slice?

a subset of an array or other data structure

50
New cards

What is an associative array?

An array that stores data in key value pairs

51
New cards

What is a record type?

a composite data structure that groups related data fields into a single, named unit

52
New cards

how does C implement a record?

As a struct

53
New cards

What is a tuple?

An immutable, ordered set of values of any type.

54
New cards

What is a list?

An ordered collection of elements of a single data type

55
New cards

What is a pointer?

A variable that stores the memory address of another variable.

56
New cards

What are the major design issues when dealing with pointers?

Dangling pointers, null pointers, memory leakage

57
New cards

What is a dangling pointer?

A pointer initially holding a valid address, but later the held address is released.

58
New cards

What is a lost pointer?

a pointer that no longer reliably leads to intended data

59
New cards

What is a solution to the issues with pointers

Tombstones, locks and keys

60
New cards

What is type checking?

process in programming languages to verify and enforce constraints on the data types of variables, expressions, and function arguments

61
New cards

What languages enforce type checking?

C, C++, Java, C#, Rust, Haskell, Go, Pascal, Swift, Kotlin

62
New cards

What languages don't enforce type checking?

Python, Assembly, JavaScript

63
New cards

What is strong typing?

a language's strict enforcement of data type rules, which prevents or discourages the mixing of incompatible types and limits implicit type conversions

64
New cards

What is type equivalence?

rules for determining if two types are the same

65
New cards

What is an expression?

An expression is a combination of literals, operators, variables, and parentheses used to calculate a value.

66
New cards

What is an operator?

a symbol or keyword that performs a specific operation on one or more operands

67
New cards

What are the three types of operators

arithmetic, relational, logical

68
New cards

How is order of operation determined?

precedence and associativity

69
New cards

What can be used to change the default order of operation?

Parenthesis

70
New cards

What is a conditional expression?

An expression that evaluates to true or false.

71
New cards

What is a side-effect?

when a function changes a parameter or a global variable

72
New cards

How can side-effects complicate expression evaluation

If the changed parameter is merged with the function return

73
New cards

What is an overloaded operator?

Using the same symbol to mean two different things

74
New cards

What is type conversion?

the process of converting data of one type into another

75
New cards

When does type conversion typically take place?

implicitly and explicitly

76
New cards

What is a relational expression?

a statement that compares two or more values or operands using a relational operator

77
New cards

What is a Boolean expression?

True or false

78
New cards

What is short-circuit evaluation

Only evaluate as much as needed to determine truth of statement

79
New cards

How can short-circuit evaluation be used to protect an expression?

To prevent errors and unnecessary work

80
New cards

What is an assignment statement?

Central concept of imperative languages

81
New cards

How is assignment handled in various languages?

with a special symbol(s) such as = :=

82
New cards

What is a control statement

Statements that alter the normal sequential flow of a program

83
New cards

What is a control structure?

a conditional or loop.

84
New cards

What is a two-way selection statement?

allows a program to choose between two distinct paths based on a conditional

85
New cards

What are the design issues related to two-way selection statements?

The dangling else statement

86
New cards

How are nested selection statements handled in various languages?

braces, brackets, switch statements

87
New cards

What is a multiple selection branch?

classic switch statement

88
New cards

What are the design issues related to multiple selection branches?

readability and writeability

89
New cards

What are two different implementations of multiple selection branches?

cond, switch

90
New cards

What is an iterative structure?

a repeating selection statement

91
New cards

What are the 3 main types of iterative structures?

for, while, do

92
New cards

What are the design decisions for these main types of iterative structures?

control flow, the timing of condition checks, and the intended use case

93
New cards

What is an unconditional branch command?

a jump

94
New cards

Why is an unconditional branch command so dangerous?

control hazards

95
New cards

are subprograms process abstraction or data abstraction?

process abstraction

96
New cards

What are the general characteristics of subprograms?

Single entry point.

Caller is suspended until subprogram finishes

Control always returns to caller when finished

97
New cards

What are parameters?

Special variables used to pass values into a sub programme

98
New cards

What are formal parameters?

the parameters listed with the function definition

99
New cards

What are actual parameters?

the variables used when calling the function

100
New cards

What are positional parameters?

Value is determined by how they are listed