Exam 1 Study Guide

Things to know for Exam 1

PL Concepts

  • What are the differences between compiled and interpreted languages? Can you name advantages and disadvantages for both?
  • What is a Hybrid Intepreter?
  • What are the 4 evaluation metrics we use for programming languages?
    • What impacts does simplicity have on the metrics?
    • What is orthogonality? Can you give an example of something not very orthogonal in a programming language you know? What impacts does orthogonality have on our evaluation metrics?
    • What is a programming-language level abstraction? Can you give an example?
    • What features impact reliability?
  • What is a binding?
  • What is static typing? Dynamic typing? Untyped system? What are the advantages and disadvantages of each?
  • What is type safety?
  • What is an implicit type conversion?
  • What is strong vs. weak typing? How is this different from static and dynamic typing? How is an untyped system weakly typed by definition?
  • In your own words, what is expressivity?
  • What is a pointer? How is it different from (and similar to) a reference?
  • In C or C++, why is BASE[OFFSET] equivalent to OFFSET[BASE]?
  • What is an object lifetime?
  • What is a static lifetime? What are the advantages? Disadvantages?
  • How does static lifetimes allow for direct addressing?
  • What is a stack dynamic lifetime? What are the advantages? Disadvantages?
  • What is an explicit dynamic lifetime? What are the advantages? Disadvantages?
  • Name the 3 dangers of explicit dynamic lifetimes. Be sure you could identify which danger is demonstrated in a simple piece of C or C++ code.
  • What is an implicit dynamic lifetime? What are the advantages? Disadvantages?
  • What is garbage collection? Given a diagram like presented in lecture of the visible and working variables and the heap, could you identify which nodes on the heap can be garbage collected?
  • What is the difference between eager evaluation and lazy evaluation? Could you create a case where they would produce different results?
  • What is referential transparency?
  • What is a prefix operator? Postfix? Infix?
  • What is a cons cell? What are the left and right sides called? How can we use cons cells to build lists?

Haskell

  • What is currying?
  • Be able to intepret and use currying!!!
  • What are each of the following lists? [1..10] and [5..]
  • How does lazy evaluation allow for lists of infinite length?
  • List operations: head, tail, init, last, take, drop, cycle, repeat, elem, : (cons), ++ (concatenation)
  • Be able to write a list comprehension!!! Maybe it will have mutiple predicates or draw from multiple lists. It could be nested.
  • What is a tuple? Could you use the operations fst, snd, and zip?
  • Be able to write a type declaration. It might need you to make use of a type class.
  • How does a type class differ from a type?
  • How can we query GHCi for the implied type of a function?
  • Know the Integral, Num, Eq, Ord and Show type classes
  • Be able to write a recursive function using pattern matching!!!
  • What is the meaning of (x:xs) in pattern matching? (x:y:ys)? Could you use an as-pattern?
  • How can we use pattern matching to obtain the elements of a tuple as different variables?
  • Be able to interpret or write a let or where statement.
  • How can we use pattern matching inside of a where statement?
  • Be able to interpret or write a function using guards.
  • Explain how guards can reduce the amount of if/else you will need on conditionally dependent expressions.
  • Why do we have both guards and pattern matching? When might one be more expressive than another?
  • Be able to interpret or write a case statement. By the definition of an if/else statement, how can we rewrite any if/else using case?
  • How can we write a function that takes a function? Give an example of what the type declaration might look like.
  • What is a partially applied function? How does it relate to currying?
  • How can we partially apply an infix function?
  • Be able to interpret or write a function using zipWith.
  • Be able to interpret or write an anonymous (lambda) function.
  • Under what case might a lambda function be clearer than writing a named function in a where clause?
  • $ and .
  • What is a reduction function? Can you name a few built in to Haskell?
  • How do foldl and foldr act as general-case reduction functions?
  • Be able to write a simple reduction function (such as sum or product) using foldl or foldr.
  • Given a definition for foldl and foldr, be able to draw a picture explaining the difference between the two.
  • Be able to write a simple main function in Haskell that asks the user for their name and greets them.
  • How can we define our own types in Haskell? What is the difference between the name of the constructor and the type name?
  • Could you write or interpret a type with multiple constructors (like the Shape example in class)?
  • What is record syntax? Could you write a type using record syntax? What are the advantages of record syntax?
  • How can we derive from a type class?
  • How can we write a recursive type?
  • Be able to write a simple type using type parameters.