• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/115

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

115 Cards in this Set

  • Front
  • Back
What are the advantages and disadvantages of using a native word size for integers?
Efficient, but easy to make portability errors
What are the advantages and disadvantage of using a standardized word size for integers?
Portable, but possible inefficient
What is full Unicode codepoint support?
You require 32bit integers, not 16-bit as a java char, or 8-bit like a C char
How do you ensure meaning is “preserved” across platforms, runtimes, etc?
Type-checking.
When can't types be intermixed?
Strong typing
Which languages are weakly typed?
Perl, PHP (typing)
What is the difference between pointers and references?
The first refers to abstractions of addresses and the second refers to abstraction of object
location
When must references be exposed in Haskell?
To construct cyclical data structures
What does a type system consist of?
A mechanism to define types, and a set of rules for type equivalence, compatibility, and
inference.
What are some examples of strongly typed languages?
ADA, Java, Python, Haskell (typing)
What are some examples of weakly typed languages?
C, C++, Javascript
What are some examples of statically typed languages?
Haskell, Miranda
What are some examples of dynamically typed languages?
Python, Ruby
What sort of languages always detect type errors?
Strongly typed languages.
What is a potential fault of weakly typed langauges?
When you add two references that results in a nonsensical sum of the object's addresses.
What is an advantage of strong typing?
This is essential for secure execution of untrusted code.
What is static type checking?
When all checks are performed at compile time, and each variable/expression has a
fixed type.
What is dynamic checking?
When checks performed at run time, and only values have type, whereas expressions
may yield values of different types.
What is an exception to pure static type checking?
Disjoint union types in strongly typed languages require tag checks at run-time.
What is type equivalence?
When the the types of two values are the same.
What is type compatibility?
When the value of A can be used when the type of B is expected.
What is type inference?
When the type of expression is determined even if there is no explicit info provided, or
when the actual expression's type matches the type info provided by the programmer.
When are two ways in which type equivalence occurs?
Structural equivalence, and name equivalence.
When are two types structurally equivalent?
When two types have equivalent components.
What is name equivalence?
Structural equivalence + When two definitions with different names are not the same. Solves “student-school”
problem.
What is an alias?
Under name equivalence, introduce an alternate name, a derived type.
When is there strict name equivalence?
When the derived type is different from the main type.
When is there loose name equivalence?
When the derived type is equivalent to the original type.
What is a converting type cast?
This occurs when underlying bits are changed during type conversion.
What is a non-converting type cast?
This occurs when underlying bits are not changed during type conversion.
What is type coercion?
This occurs when compiler has rules to automatically cast values in certain situations. This makes code performing arithmetic more natural, if also more prone to error.
What is a neat feature of a functional language?
Functions are first-class citizens.
What is a neat feature of a functional language?
Structured function return such that functions return tuples
What is a neat feature of a functional language?
List types are primitive to the language.
What is a neat feature of a functional language?
Polymorphism is implicit, and there is a natural expressiveness for symbolic and
algebraic computations.
What did John Backus say when he received the Turing Award?
Title of talk 'Can Programming be liberated from the von Neumann Style?', where there
was a call for increased abstraction.
What is a neat feature of Haskell and Miranda?
Purely functional (referential transparency enforced), there is no room for side effects.
What is referential transparency?
Bindings are immutable → “no side effects” to running a function.
When is there semantic equivalence?
This happens when there is referential transparency
When is a functional called referentially transparent?
A function, if given some argument, always returns same result
What is a problem of referential transparency?
It is difficult to integrate I/O into purely functional mode.
What is an advantage of referential transparency?
Lack of explicit evaluation offers possibility for parallel execution
When does every entity have a specific type?
Static typing
What is easy in dynamically typed languages but not in basic statically typed languages?
Extracting the first element of a 2-tuple
How do you implement generic programming in Haskell?
Type variables which are lowercase.
What are two types of overloading?
Context-independent and context-dependent.
What is context-independent overloading?
Only parameter types are used for disambiguation.
What is context-dependent overloading?
Parameter types may be ambiguous if return type is unambiguous.
What is Haskell's way of controlling overloading?
A function can only be overloaded if it is defined by a type class.
What are the advantages of Encapsulation?
Reduced complexity, reduced likelihood of errors, information hiding.
What is an advantage of inheritance?
Increased productivity and code-reuse
What is an advantage of abstraction by means of clean interfaces?
Enables large teams to develop in parallel.
What is coupling?
The degree to which one module relies on the internal workings of another module.
What flavor of OO is adopted by Ruby, Python, etc?
Very dynamic, late binding OO pioneered by Smalltalk. Pure OO where everything is an
object even numbers, functions.
What flavor of OO is adopted by C++, Java, C#, Eiffel, etc?
Type of OO where all objects of class must have same structure (memory layout). This
is pioneered by Simula 67.
When does the compiler determine at compile time which code will be called?
Early Binding.
When is a name resolved at runtime with regards to OO?
Late binding. Cost: small overhead.
When does the type of object (rhs) determine the method?
Late binding.
When does the type of reference (lhs) determine the method call?
Early binding
What is the difference between inheritance and modification?
The first leaves the superclass unchanged, while as the second affects all modules using
the class.
What are the advantages of runtime patches in Python and Ruby?
They add functionality, they fix bugs, and add convenience methods.
What type of languages avoid classes completely?
This type was pioneered by Self, and is gaining in popularity especially via Javascript.
What is the RTS?
Everything not part of the OS and not explicitly provided by the user.
What are examples of the RTS?
Memory allocator, garbage collector, support for runtime casts, exception handling
infrastructure, just-in-time (JIT) compiler
What is the RTS?
The infrastructure required (to transparently) realize higher-level language abstractions
at runtime.
What are problems with explicit heap management?
Dangling pointers, memory leaks
When was Garbage collection first developed?
Lisp in 1958
What is the root set?
The set of objects that are immediately available to a program without following any
pointers/references.
In the object graph of reachable objects, how are the objects represented?
Vertices
In the object graph of reachable objects, how are the references/pointers represented?
Edges
What happens when there is a false positive with detecting garbage?
Program crashes
What happens when there is a false negative with detecting garbage?
Memory leak
What is the efficiency problem with ref counting?
It increases the number of (slow) writes.
What is the first accuracy problem with ref counting?
Problematic with disjoint union types. What if one variant contains a reference and
another doesn't. <X> must count variant tags.
What is an accuracy problem with ref counting related to C?
You can't reliably tell pointers from integers.
What is a second accuracy problem with ref counting?
Cannot detect circular garbage.
How is there direct reachability with a Mark and Sweep GC?
Instead of using a counter to track possible incoming paths, actually discover all paths at
run-time by traversing the object graph.
What flag do objects carry in a Mark and Sweep GC?
They carry an “in-use” flag.
How does Mark and Sweep GC handle the potential issue that the object graph might be
changed during traversal?
“Stop the world.” Program execution is halted during GC.
What are two ways to deal with the “Stop the World Problem”?
Concurrent Garbage Collector: Have the garbage Collector and program run
concurrently
2. Incremental Garbage Collector: GC does not process whole object graph at once.
Instead, it is invoked more frequently.
What is the first way a Mark and Sweep GC identifies objects in the heap?
Objects must carry size/type tags or have uniform size.
What is the second way a Mark and Sweep GC identifies objects in the heap?
You can allocate objects of equal size/type from specific address ranges. This is also
known as the “Big Bag of Pages” approach.
What issues arise with discerning arbitrary values from pointers in a Mark and Sweep?
You could have a number that “points” to a garbage object. You could have a number
that now “points” outside of heap bounds. So both positives.
What is a precise garbage collector?
This Garbage Collector can unambiguously determine whether a given value is a
pointer/reference.
What is a conservative garbage collector?
This garbage collector works without discerning pointers/reference from other values
with certainty.
Why is it difficult to implement Mark & Sweep efficiently?
Problem of avoiding the world.
What are the costs with ref counting?
Since it occurs continuously there are no pauses, but overheads are incurred
continuously as well.
What is the Mark&Sweep execution and allocation system like?
It pauses, but other than that is fast.
Why is there a need for copying garbage collection?
Simply identifying and freeing garbage doesn't solve fragmentation.
What is the limitation of basic copying garbage collection?
Well well half the heap is unused.
How does basic copying garbage collection work?
Have two arenas, one live arena, one free arena. Allocate onto live arena until full. Then
mark and sweep to find all live objects, move them to free arena. Then switch roles, so
live arena is now free.
Why is there a security flaw with basic copying garbage collection?
Garbage does not need to be explicitly reclaimed.
Why is basic copying garbage collection very fast?
There is no need to search for available space.
What is the Generational hypothesis premised upon?
In many programs there is high “infant mortality.” Most objects don't last long. Thus old
objects are less likely to become garbage.
How does the generational hypothesis work?
You have multiple allocation arenas. All objects begin in the “nursery” (stage 0).
“Survivors” move onto next arena, which is also gc'ed at some point. In other words,
generation 1 objects then move onto generation 2.
What do finalizers do?
Languages such as Java use finalizers to free non-memory resources such as file
handlers when the object is freed.
What is the problem with finalizers?
You may run out of non-memory resources before the GC kicks in.
Why is pure interpretation slow?
The interpreter evaluates syntax tree directly.
What is ahead of time compilation?
It is static compilation. Compiler produces machine code once; resulting program is
executed many times.
What is JIT essentially?
Compile byte code at run time to speed up overall program execution.
What is the general concept of advantage associated with JIT?
Combine the efficiency of compilation with flexibility of interpretation. “There is late
binding of machine code.”
What is the overhead associated with a basic JIT?
After a program starts, parts must be compiled before output is produced, which
manifests in a noticeable delay.
How do you mitigate the Startup delay with JIT?
You run the interpreter and the JIT compiler in parallel, or you avoid compiling the
whole program at once.
What is the tradeoff associated with piecewise JIT compilation? What does this mean?
The compilation takes considerable time, but compiled code is faster. So this code must
be executed many times to make tradeoff worthwhile. Thus there emerges concept of
threshold: trigger compilation only for code-fragments executed more than say 100
times
What does the JIT piecewise compilation threshold determined upon?
The efficiency of the byte code interpreter and the JIT compilation speed.
What sort of transformations are done in the JIT?
Simple transformations; fast non-optimal algorithms chosen over slower, provably better
algorithms.
How can the JIT outperform the AOT?
You can re-optimize at run-time by tracing. You have access to additional information
like specific types. You can have accurate branch prediction. You can generate
specialized code. There are more in-lining possibilities.
Where the JIT-AOT tradeoff come into play?
Trade off is between long-running vs. short running processes. Because JIT can't reoptimize
with a short running process, there will be a performance blow.
How does JIT work with prototype languages where there are no classes?
It derives “implicit” classes that are based on source code location where object was
created.
When must you re-JIT an object?
If the object's prototype is changed, or a new prototype is assigned. (Most prototypes are
not changed).
What is binary translation?
It is basically a compiler without source code. Compiling machine code to machine
code.
What can you do with binary translation?
Debugging, logging (add invariant checking), Virtualization, Performance analysis,
adding security hooks.
What is a security issue with binary translation?
Untrusted code might be malicious.
What is byte code validation?
It is when you prove arbitrary properties of arbitrary source code is impossible.
What is an alternative to byte code validation?
Code signing – when there is an attestation by a trusted third party : this is okay.