Final Exam: COMP 320
due 5pm, Monday, June 6th
A final exam is only partially a learning exercise; it is mostly an
assessment tool to clarify what you have learned over the course of the
quarter. Therefore, you should do this assignment entirely on your own,
using only the textbooks (Programming Languages and Learn You
a Haskell), your own written work
(notes, problem sets, and
your presentation), and your own understanding. The only exception to
this rule is that you may refer back to the sources you used for your
presentation in answering Question 3, citing them as appropriate.
(You should also cite the textbooks as appropriate, at least informally
-- e.g., "Sebesta, pp. 277-279".)
You may not talk to other students in the class about the exam.
- What is the distinction between an expression and a statement?
How does C confuse this distinction? (Provide specific examples,
and clearly specify what each example illustrates.) (10 points)
- Of the key issues discussed in Chapters 5 - 8, which are relevant to
Haskell, and how does it handle those issues? (15 points)
- Of the key issues discussed in Chapters 5 - 12 (and optionally 14),
which are relevant to a language on which you did a presentation, and how
does it handle those issues? (Specify which language you are talking
about!) (20 points)
- Consider the following two code snippets in Haskell and Java.
Haskell Code Segment:
testAdd2 = addToEnv "fib0" (addToEnv "n" ))
[ addToEnv "fib1" testAdd2,
setVarValue "fib0" 0 testAdd2
Java Code Segment:
testAdd2 = addToEnv("fib0", addToEnv("n", emptyEnv));
testResults = addToEnv("fib1", testAdd2);
testResults = setVarValue("fib0", 0, testAdd2);
Assume that in both cases
functions to add an uninitialized variable to an environment and set the value
of a variable in
an environment, respectively, where an environment is a list of variable name-value
pairs as in our Jay interpreter program. Both
functions return an environment. Assume
all been declared and initialized appropriately in the Java code segment. Note
that the Java
testResults variable is an array of environments,
each of which represents the result of a particular test case.
Thesis: These two code segments appear to be very similar, with minor syntactic
similarity is, however, misleading; the semantic differences go much deeper
than the syntactic ones.
Assignment: Justify the thesis above, focusing on the role and type
testAdd2 in each code segment, and how that impacts each line of code in
the two examples.
- Answer two of the following questions.
(20 points (10 points each))
- What is the difference between static binding and dynamic binding
of messages/methods/functions? (Dynamic binding is
often described in conjunction with polymorphism.) In general
when the terms static
and dynamic are used to describe programming language features, what do
these terms mean?
- Some people claim that a language must support garbage collection
to be considered a modern, high-level language. What is garbage collection,
what are its benefits, and what are the disadvantages that would explain
why a language such as C++ does not support it?
- In his well-known paper, “The Object-Oriented Classification
Paradigm,” Peter Wegner presented the following informal “equation” for
the object-oriented paradigm [Wegner 88]:
object-oriented = objects + object classes + class inheritance
We might also write this as:
object-oriented = encapslation + user-defined types + class inheritance
- How does this “equation” define the object-oriented paradigm?
Make sure to define any buzzwords you use. Are there any features of the oo paradigm
that are missing from this equation?
- Come up with similar informal “equations” for the imperative and
functional paradigms, and explain your new
- Of the paradigms we studied this quarter (functional, logical, object-oriented,
and procedural) which would you pick for first-year students to learn? What
is it about the paradigm that would lead you to your decision?
- Write an essay for the following question. (25 points)
Imagine that you are a programming language consultant, and you have been
called in to recommend a language for a company about to start a large and
important software project. You do not yet know enough about the project to
know which language to recommend. What kinds of questions do you need to ask
the project managers to determine which language would be appropriate? What
kinds of language issues should you consider? Be explicit about what kinds
of considerations would lead you to which languages