Programming Languages Flashcards

1
Q

What is a value?

A

A value is an expression that cannot be simplified any further.

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

What is the term for:

an expression that cannot be simplified any further.

A

Value

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

What term describes:

the types of all preceding bindings in the file.

A

static environment

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

what term describes

the value of all preceding bindings in the file.

A

dynamic environment

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

Give a rough definition of the static environment.

A

The static environment is roughly the types of all preceding bindings in the file.

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

Give a rough definition of the dynamic environment.

A

The dynamic environment is roughly the value of all preceding bindings in the file.

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

What is the term for “how an expression or statement is written”?

A

syntax

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

stack data structure containing a element for each function that hasn’t finished executing.

A

call stack

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

What is the term for “how an expression or statement is interpreted (i.e. how it is evaluated and type checked)”?

A

semantics

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

describes a function call when there are no more pending computation after it is evaluated.

A

Tail call

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

Describes the position of an expression e, when there are no pending computations after e is evaluated.

A

tail position

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

What are the questions we ask when we encounter a new language construct?

A
  1. What is the syntax?
  2. What are the type checking rules?
  3. what are the evaluation rules?
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a “call stack”?

A

stack data structure containing a “stack frames” for each function that hasn’t finished executing.

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

used to refer to a sub-type of an algebraic type.

A

variant

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

In the context of algebraic-types, what does the term “carries” mean?

A

describe when a variant wraps one or more value.

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

within the context of compound types, this is a piece of information that distinguishes one variant of a “one-of” type from the others.

A

tag

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

a function with free variables that have been closed (or bound) by an environment.

A

closure

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

A variable used within a function body that is neither a local variable or a function parameter.

A

free variable

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

What is a “stack frame”?

A

A data structure containing information about a function invocation.

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

What is a “tail call”?

A

A function call that occurs in “tail position”.

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

What is “tail position”?

A

Describes the position of an expression e, when there are no pending computations after e is evaluated.

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

How many kinds of compound types are there?

A

There are 3 types.

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

List the types of compound types.

A
  1. sum-types or “each-of” type
  2. algebraic-types or “one-of” type
  3. self-referential type
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

what is a variant in the context of “compound types”?

A

A variant refers to a sub-type of an algebraic type.

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

What is the term used to describe when a variant wraps one or more value.

A

the variant “carries” one or more values.

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

in the context of the “client/implementer” idom, this is a construct that hides the implementation of a solution, while providing the client with information on how to use the solution.

A

abstraction boundary

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

In the context of compound types, what is a “tag”?

A

within the context of compound types, this is a piece of information that distinguishes one variant of a “one-of” type from the others.

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

What is a closure?

A

a function with free variables that have been closed (or bound) by an environment.

  • A function/expression must be closed before it can be evaluated.
  • pairing an open function with an environment that binds the functions free variables, provides the information needed to evaluated the function (i.e. closes the function)
  • with lexical scoping, functions are closed by the current lexical environment.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

What is a “free variable”?

A

A variable used within a function body that is neither a local variable or a function parameter.

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

What is “parametric polymorphism”?

A

describes the property of a function/datatype when it can accept one or more type parameters.

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

describes the property of a function/data type when it accepts one or more type parameters.

A

parametric polymorphism

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

In the context of parametric polymorphism, what does the term “instantiated” mean?

A

In the context of parametric polymorphism, this is when a type parameter is reduced into a more concrete type (e.g. the type parameter ‘a becomes int)

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

What is the “client-implementer” idiom?

A

Describes a method to separate the knowledge of traversing a complex data structure/problem space, from that of operating on the different components of of the data structure.

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

What is a “closed function”?

A

A function that does not reference any free variables.

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

Define “scope” as it relates to name bindings.

A

The environment in which a binding is valid.

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

What is “lexical scope”?

A

A scope which is determined by the lexical position of the binding. In other words, the environment in which the binding is valid is the current environment at the point in the file where the binding was defined.

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

How could mutually recursive functions be defined in a context where the underlying language does not provide support for mutual recursion?

A
  1. define function-1 to accept an argument that matches function-2’s signature.
  2. Then define function-2 to call function-1, passing itself as an argument.
38
Q

What is an abstraction boundary?

A

construct that hides the implementation of a solution, while providing the client with information on how to use the solution.

39
Q

What is an invariant?

A

guarantee to functions/expression on the implementation side of the abstraction boundary.

40
Q

What is a property?

A

guarantee to functions/expressions on the client side of the abstraction boundary.

41
Q

Polymorphic type

A

a type that can be instantiated by multiple concrete types.

42
Q

What is the definition of:

Parameter passing strategy

A

defines the binding strategy and evaluation order of a function call.

43
Q

What is the term for:

defines the binding strategy and evaluation order of a function call.

A

parameter passing strategy

44
Q

What is the definition of:

binding strategy

within the context of parameter passing strategy

A

defines the type of values bound to a functions parameters.

In other words, is the parameter given a reference or a copy of a value.

45
Q

What is the term for:

the strategy used to defines the type of values passed to a function for each parameter.

Within the context of parameter pasing strategy

A

binding strategy

46
Q

What is the definition of:

evaluation order

Within the context of parameter pasing strategy

A

defines whether the parameters of a expression or function call are evaluated, and if so in what order.

is the first parameter evaluated first, or the last parameter?

47
Q

What is the term for:

the strategy that defines whether the parameters of a expression or function call are evaluated, and if so in what order.

Within the context of parameter passing strategy

A

Evaluation order

48
Q

What is the definition of:

strict evaluation order

within the context of parameter passing strategy

A

describes an evaluation order that results in strict functions.

49
Q

What is the term for:

describes an evaluation order that results in strict functions.

within the context of parameter passing strategy

A

strict evaluation order

AKA “applicative order”, “greedy evaluation”, or “eager evaluation”

50
Q

What is the definition of:

Strict function

A

a function is strict if it never terminates whenever applied to a non-terminating expression.

a non-terminating expression is an expression that does not terminate, either because it throws an error, loops infinately, etc.

51
Q

fill in the blank:

a function f is said to be ____ if f applied to an non-terminating expression results in f not terminating.

A

strict function

52
Q

What is the definition of:

Non-strict Evaluation order

within the context of evaluation strategy

A

describes An evaluation order that results in non-strict functions.

some or none of the arguments can be fully or even partially evaluated

53
Q

What is the term for:

describes an evaluation order that results in non-strict functions

withing the context of evaluation strategy

A

non-strict evaluation order

54
Q

What is the definition of:

normal-order evaluation

within the context of evaluation strategy

A

an evaluation strategy that first applies functions, then evaluates arguments.

55
Q

what is the term for:

an evaluation strategy that reduces an expression to normal form by applying functions before evaluating the arguments.

A

normal-order evaluation

56
Q

what is the definition of:

applicative-order evaluation

A

an evaluation strategy that reduces an expression to normal form by evaluating function arguments before applying the function.

this has the effect of making functions strict.

57
Q

What is the term for:

an evaluation strategy that reduces an expression to normal form by evaluating function arguments before applying the function.

A

applicative-order evaluation

58
Q

lazy evaluation

A

describes a form of normal-order evaluation strategy that prevents repeated evaluation of a “function invocation” by memoizing the result after the first evaluation.

59
Q

normal form

A

an expression that has no more function applications.

60
Q

What is the evaluation order and binding strategy for:

call-by-value

A

evaluation-order: applicative-order
binding-strategy: parameters bound to a value.

Call-by-value is an applicative-order evaluation strategy that binds functions parameters to a value (resulting from the complete evaluation of the arguments.)

61
Q

What is the evaluation order and binding strategy for:

call-by-reference

A

evaluation-order: applicative-order
binding-strategy: parameters bound to implicit reference to a variable used by the caller.

call-by-reference is a applicative-order evaluation strategy that binds function parameters to an implicit reference to a variable.

The function defines a parameter that takes a variable. When the function is called, the function can modify the contents of the variable, meaning the caller would be able to see the modification.

62
Q

What is the evaluation order and binding strategy for:

call-by-sharing

A

evaluation-order: applicative-order
binding-strategy: parameters bound to a boxed-value.

boxed-value is a value wrapped in an object to allow using as reference

call-by-sharing is a applicative-order evaluation strategy where the value is implemented as a reference, and the parameters are bound to the values.

this means that any modification made to the value is observable by the caller, but the callee cannot modify the content of any of the callers variables.

Think javascript objects, and functions.

63
Q

What is the evaluation order and binding strategy for:

call-by-name

A

evaluation-order: normal-order
binding-strategy: parameters bound to an implicit thunk wrapping the expression

call-by-name is a normal-order evaluation strategy that binds the parameters to a thunk.

64
Q

What is the evaluation order and binding strategy for:

call-by-need

A

evaluation-order: normal-order
binding-strategy: parameters bound to an implicit memoized-thunk wrapping the expression

call-by-name is a normal-order evaluation strategy that binds the parameters to a memoized-thunk.

65
Q

what is the main disadvantage of call-by-name?

A

When a parameter is only needed once, call-by-name is ideal. However, if the parameter is needed in multiple locations:
1. the wrapped expression is evaluated multiple times. This is undesireable because of possible performance implications.
2. any side-effects in the wrapped expression will also be executed multiple times. This is undesireable because it could cause duplicate data in storage, unneeded network a calls etc.

66
Q

What is the definition of:

interpreter

within the context of language implementation

A

a program that evaluates a source-language program and produces a value in the same source-language.

67
Q

What is the term for

a program that evaluates a source-language program and produce a value in the same source-language.

within the context of language implementation

A

interpreter

68
Q

what is the definition of:

compiler

within the context of language implementation

A

a program that takes a source-language program and produces an equivalent target-language program.

69
Q

what is the term for:

a program that converts a source-language program into an equivalent target-language program.

within the context of language implementation.

A

compiler

70
Q

what is the term for:

the language used to implement the interpreter/compiler.

within the context of language implementation

A

meta-language

71
Q

what is the definition of:

meta-language

within the context of language implementation

A

the language used to implement the compiler/interpreter.

72
Q

define:

static checking

within the context of language implementation

A

anything done to reject successfully parsed programs before they run.

73
Q

what is the term for

checks made to reject successfully parsed programs before they run.

A

static checking

74
Q

define

soundness

within the context of language design

A

a property of a type-system that means it will never allow a program that does something the language declares should not occur.

no false negatives.

lets say you have a shuttle to marse. A lot of people don’t want the ship to take off (damn eco-terrorists). The organization in charge declares publicly that it will never be possible for a bomber to be on the ship at take-off.

The walls around the ship are absolute, so no one can pass except through the gates. The guards at the gate (type-checker) has a list of properties that would constitute a bomber. The guards must ask themselves for each person “is this person gonna blow up the ship”? if the answer is positive, they kick him out. If the answer is negative they allow him.

The security system (i.e. the static-checker) is said to be sound if, the checks at the gate are 100% effective at identifying a bomber. Notice that while they may be effective at identifying bombers, they may also mistake an engineer as a bomber, since they may have some of the same characteristics. This is a question of correctness.

75
Q

what is the term for

a property of a type system such that, given a property X that the language has declared should never exist in a running program, it never allows any program that has the property X.

every program with property X, will always be flagged

A

soundness

76
Q

define

correctness

within the context of language design

A

a property of a type-system such that, it will never reject a program that <b>never</b> does something the language has declared should not occur.

no false positives

given a sound security system as described in soundness card. Whenever a person is identified who match the criteria of a bomber, the guards at the gate have an additional checklist, that enumerates the properties that would identity an engineer, or mechanic etc.

<b>The security system (i.e. type-check) is said to be correct if, it never rejects persons who could/would never blow up the shuttle under any circumstance, even if they share properties with potential bombers</b> (i.e. engineers, mechanics, miners, bomb experts etc.)

77
Q

what is the term for

a property of a type system such that it would never reject a program that would never under any circumstance do something the language has declared would never occur.

within the context of language design

A

correctness

78
Q

how many rules are their to class-based object oriented programming

A

5

79
Q

what are the rules to class-based OOP

A
  1. all values (i.e. the result of evaluating expressions) are references to objects.
  2. given an object, code (i.e. clients) communicate with it by sending messages (i.e. calling methods) on it.
  3. each object has its own private state that can only be directly accessed from within methods of the object.
  4. every object is an instance of a class.
  5. an objects behaviour is determined by its class.
80
Q

explain:

method call semantics

within the context of Ruby programming

A

Given a method call e0.m(e1, e2, … en):
1. evaluate e0 - en to objects
2. searches for and calls the method m, passing the results of e1-en as arguments.

81
Q

What is the definition for:

message send

within the context OOP

A

describes when a client calls a method on an object.

82
Q

what is client code

within the context of OOP

A

an code that interacts with an object is a client of that object.

83
Q

what is a

reciever

within the context of OOP

A

the reciever is the object “recieving the message” sent by the client code. In other words the object on which a method is called.

84
Q

what is the definition of:

instance variable

A

a variable that belongs to an instance-object and is only valid within methods called on that object.

85
Q

what is the definition of

class variable

A

a variable that belongs to a class that is only visible by instances of that class.

class variable modification by any instance is visible by all instances

86
Q

what is

class constant

within the context of OOP

A

like a class variable, belongs to a class, but is visible by any object of any class.

87
Q

what is

public method

A

a method who’s client can be any object of any class.

88
Q

what is

protected method

A

a method who’s client can only be instances of the recievers class or sub-class.

89
Q

what is

private method

A

a method who’s clients can only be methods of the recieving object.

90
Q

what is

duck typing

A

refers to the idea that the client only needs the object to be able to handle a given message, not that the object be instance of a given class.

it can be a dog, but since I only need the sound of a duck, as long as that dog can quack i can use it.