CS4080 Final

5.0(1)
studied byStudied by 87 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/65

flashcard set

Earn XP

Description and Tags

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

66 Terms

1
New cards
Name 3 of the most important domain areas that have historically driven the design of programming language, and name one such language for each area.
Scientific Computation - Fortran

AI - Lisp python

Enterprise - Java Cobalt

Systems programming - C Pearl

Web applications - Javascript, Typescript, PHP
2
New cards
Describe how computer architecture can affect the design of programming languages.
languages that follow the designed of a computer’s architecture can be followed easily, while languages that use abstractions are harder to translate. This is why early languages followed computer architecture.
3
New cards
Describe the different ways in which a programming language may be implemented.
compiler: take source code and turns it into machine code

interpreter: program that reads source code and executes it

virtual machine: code is compiled into byte code, instructions are simulated in software
4
New cards
Describe the two components of a programming language.
syntax: rules to write valid words in the language

semantics: the meaning of sentences within the language
5
New cards
What is the alphabet of a programming language?
set of all valid symbols in the language
6
New cards
What is the difference between reserved words and keywords?
reserve words: words that may or may not be used by the language (could be used in future updates)

key words: reserved words with functionality in the language
7
New cards
What does it mean for a language to be Case Sensitive? Give an example.
keywords, variables, function names, and other identifiers must always be typed with a constant capitalization of letters

EX:

“while” != “While”
8
New cards
What does it mean for a language to be Case Insensitive? Give an example.
the language can ignore the differences between upper and lowercase letters

EX:

“while” = “WHILE”
9
New cards
What are the stages of a compiler?
LSSTOT

Lexical analysis

Syntax analysis

Semantic analysis

Translation

Optimization

Transcription
10
New cards
What is a variable?
a name for memory location that holds a value of a particular data type that can be destructively updated
11
New cards
What is the difference between L-values and R-values?
L-value: value of memory location that holds the value you are storing in the variable

R-value: the actual value you are storing in the location
12
New cards
Describe the phenomenon known as memory aliasing.
when a memory location can be accessed through more than one name (when 2 or more variable have the same L)
13
New cards
What is name binding?
the associating of a name with a specific value/property (memory, type, scope)
14
New cards
What is Static Binding?
when a name is connected to a property before execution
15
New cards
What is Dynamic Binding?
when a name is connected to a property during exection
16
New cards
Describe static allocation.
when memory is allocated before execution, typically done by the compiler
17
New cards
Where is the data placed when allocated statically?
the .data section / segment
18
New cards
Describe Dynamic Allocation.
when memory is allocated during execution, usually incurs overhead
19
New cards
Where is data placed when allocated dynamically?
the .heap section / segment
20
New cards
Describe static typing.
name is assigned a type before execution
21
New cards
Describe dynamic typing.
name is assigned a type during execution
22
New cards
What is the difference between Explicit and Implicit typing?
if the language requires the use to explicitly specify the type of an element with a syntactic feature the it has explicitly typing, otherwise it is implicit
23
New cards
Describe Static Scoping.
(lexical scoping) when the scope of a name is defined at programming / writing time with lexical features
24
New cards
Describe Dynamic Scoping.
The scope of a name is defined while the program is run by looking at the current state of the stack of activation records.
25
New cards
Give a list of 5 primitive data types and their typical sizes.
(all in bytes)

int - 4

long - 8

char - 1-4

float - 4

short - 2

boolean - 1

byte - 1
26
New cards
what is a constant size string?
can be implemented with arrays and may or may not be immutable, these are very fast to access and travers. modifying it may involve allocating a new string which is expensive
27
New cards
what is a dynamic size string?
can be implemented with buffered arrays or linked-lists, these are slower to read (not so much if buffered array is used)
28
New cards
Why must the elements of an array be all of the same type?
in order to iterate though an array all elements must be the same type and size in terms of bits
29
New cards
Why must the size of an array be immutable?
arrays are usually stored in contiguous blocks of memory, once the block of memory is allocates it is hard to iterate though is you want to add more space
30
New cards
What are associative arrays?
arrays where the subscript is not an integer, but a string or some other type, these are maps in which a string is a key that must be unique for every element that it is mapping.
31
New cards
Describe array-of-arrays implementation of multi-dimensional arrays.
array is stored in an array, which allows for contiguous allocation which is fast since it is all in one block.

EX:

Array \[ref1, ref2\]

Ref1 = \[2,3\]

Ref2 = \[4,6\]
32
New cards
Describe sequential-allocation implementation of multi-dimensional arrays.
array is stored all in one block, the first element tells where to jump to and the second tells which element is implemented

EX:

Array\[\[1,2\]\[4,6\]\]
33
New cards
What are jagged arrays?
arrays in which at least one dimension is variable instead of constant
34
New cards
List the different kind of expressions in a programming language.
relational expression

logical expression
35
New cards
What is the arity of an operator?
the number of operands in which an operator operates.
36
New cards
what is prefix
operator is placed before the operand (+3,4)
37
New cards
what is infix
operator is placed between the operands (3+4)
38
New cards
what is suffix
operator is placed after the operand (x++)
39
New cards
what is left to right evaluation
when evaluation happens starting from the left reading to the right

EX:

x + 3 - 2 = (x+3)-2
40
New cards
what is right to left evaluation
when evaluation happens starting from the right reading to the left

EX:

x + 3 - 2 = x+(3-2)
41
New cards
Describe precedence.
a mechanism to sort ambiguous expressions by creating a hierarchy of operators where the position of the hierarchy determines the binding strength
42
New cards
What does it mean for the evaluation of an expression to have a side-effect?
the evaluation results in a visual change or destructive update of memory
43
New cards
What does it mean for an expression to be pure?
when an expression is side effect free
44
New cards
What is Referential Transparency?
if the substation of the expression by the value it yields results in a program with the same semantics
45
New cards
What are mixed-mode expressions?
and expression with more than one type of operand
46
New cards
what is type coercion?
the conversion is implicit / automatic
47
New cards
what is type casting?
the conversion is explicit and performed with some syntactic feature in the language
48
New cards
Describe short-circuit of logical expressions.
a form of lazy evaluation given a binary operation, is the evaluation of the first operand is enough to determine a value, the second is not evaluated
49
New cards
What is an assignment?
the cornerstone of imperative languages since they are used to perform destructive updates
50
New cards
List the different kinds of assignments and provide examples.
simple: x=e

parallel: x,y = 1,2

multiple: x,y,z=42

compound: x+=1

unary: x++

conditional: x=if b then E1, else E2
51
New cards
What is a restricted-unconditional jump? Provide an example.
similar to goto, it allows one to jump unconditionally to a target instruction

EX:

(i) x=y+1

Goto (i+j)



(i+j) z=42
52
New cards
what is pass by value copy?
when you make a copy of the value and pass it, this does not affect the original value
53
New cards
what is pass by reference?
when you pass the memory location of the value, this will change the original value even outside the function
54
New cards
what are formal parameters?
variables that are defined when the function is declared

EX:

func int x: {}
55
New cards
what are arguments?
variables that are declared when the function is called

EX:

number(12)
56
New cards
what is the difference between formal parameters and arguments?
arguments are passed into the function and parameters are what the function takes in as an argument
57
New cards
what is positional parameter?
arguments bind to the parameter according to the position

EX:

int f(x,y,z)

return x,y,z

int r call f(1,2,3) //x=1,y=2,z=3)
58
New cards
what is keyword parameter?
arguments binding is explicitly specified using the name of the parameter

EX:

s = call f(y=2, x=1, z=3)
59
New cards
What are default parameters?
when the language allows you to specify default values for the parameters

EX:

fun int f(x,y=2,z)

int t = call f(x=1, z=3)
60
New cards
name the main evaluation criteria for programming language design.
simplicity

orthogonality

lv of abstraction

portability

cost

expressivity
61
New cards
simplicity
language with minimal set of features with rules on how to apply them and combine them as simply and clearly as possible
62
New cards
orthogonality
the way different constructs can be combined, and how simple these combinations are to understand
63
New cards
lv of abstraction
the features provided to create abstraction
64
New cards
portability
how easy it is for a program to be created in the language can be moved from one system to another
65
New cards
cost
cost of using language in a project (development, maintenance, execution)
66
New cards
what are the 3 paradigms of programming languages
function

imperative

logical