TOPICS FOR THE COP 4020 EXAM on Erlang, Actor Programming, and General Concepts $Date: 2019/12/06 05:24:41 $ This exam covers topics from homeworks 1, 4, and 5, including actor programming and related programming techniques in Erlang, as well as conceptual questions relating to the entire course (as in homeworks 1 and 5). This exam is related to all the course objectives. REMINDERS The exam will be open book, open notes. (Warning: don't expect to learn the material during the exam, you won't have time! A good idea for studying is to condense your notes to a few pages of ready reference materials. We suggest that you memorize the Erlang syntax you'll need.) If you need more space, use the back of a page. Note when you do that on the front. Before you begin, please take a moment to look over the entire test so that you can budget your time. Clarity is important; if your programs are sloppy and hard to read, you may lose some points. Correct syntax also makes a difference for programming questions. We will take some points off for duplicated code, code with extra unnecessary cases, or code that is excessively hard to follow. You will lose points if you do not follow the grammar when writing programs! You should always assume that the inputs given will follow the grammar for the types specified, and so your code should not have extra cases for inputs that do not follow the grammar. When you write Erlang code on this test, you may use anything that is built-in to Erlang and the modules lists and ets. You are encouraged to define functions not specifically asked for if they are useful to your programming; however, if they are not built-in to Erlang/OTP, then you must write them into your test. (Note that you can use built-in functions such as length, and ++, and functions from the lists module such as lists:map/2, lists:foldr/3, lists:filter/2, lists:reverse/1, etc.) READINGS See the readings recommended in homeworks 1, 4, and 5. If you have time, study the relevant examples form the Code examples Web page. Also if you have time, and try the old exams (but note that some problems that are relevant to this exam (especially those related to homework 4) were on exam 4 in semesters that had 4 exams). TOPICS In the following, I use + to denote relatively more important topics, and - to denote relatively less important topics. Topics marked with ++ are almost certain to be on the exam. All of these are fair game, but if you have limited time, concentrate on the ones that are more important first (and in those, the ones you are most uncertain about). SKILLS [UseModels] [Concepts] [MapToLanguages] + Functional programming ++ Be able to write functional programs in Erlang (HW4: concat, substaddr for sales data records, count_matching; HW5: mapInside) [Spring'13: map2/3, which maps a two-argument function over 2 lists; Fall'13: lookup/2, which finds associated values in a list of pairs; Spring'15: sumsquares/1.] + Give the output of an Erlang expression involving pattern matching [Spring'13: pattern matching multiple choice, Fall'13: pattern matching short answers.] - Give the output of an Erlang expression involving processes + process communication and synchronization: + Implement an RPC protocol to communicate between 2 processes (HW4: election server) [Spring'13: twitter server and client functions; Fall'13: election server; Spring'15: shared variable server.] ++ Use asynchronous message passing in Erlang to implement servers (HW4: var server, noter, barrier synchronization server, event detector) [Spring'13: semaphore server, compositor server; Fall'13: log server, barrier synchronization server, election server; Spring'15: catalog server; shared variable server; notification server] + message passing and ports: + How do you create and use a process? (HW4: var server, noter, barrier synchronization server, election server, event detector) [Spring'13: semaphore server, compositor server, twitter server; Fall'13: log server, barrier synchronization server, election server; Spring'15: catalog server; shared variable server; notification server] + How can you get information out of a process? (HW4: var server, log server, barrier synchronization server, election server, event detector) [Spring'13: semaphore server, compositor server, twitter server; Fall'13: log server, barrier synchronization server, election server; Spring'15: catalog server; shared variable server; notification server] ++ Write a stateless server. (HW4: power server) [Fall'13: power server; Spring'15: average server] ++ Write a stateful server (i.e., one that has its own state). (HW4: var server, log server, barrier synchronization server, election server, event detector) [Spring'13: semaphore server, compositor server, twitter server; Fall'13: log server, barrier synchronization server, election server; Spring'15: catalog server; shared variable server; notification server] TERMS AND CONCEPTS [Concepts] [MapToLanguages] [EvaluateModels] You should be able to explain and use (in problems or essays) the following concepts (with appropriate comparisons to related concepts). You should be able to give examples of these concepts. + tactics: + What are good programming tactics that are important in functional or actor-based programming that we studied in Haskell and Erlang? (HW1: tactics) + translations between languages: + Correspondence between Haskell/Erlang and Java/C/C++/C# (HW1: translation table; HW5: example of expression in Erlang that gives type error in Haskell) ++ Scoping: ++ Find the free and bound identifiers in an expression (HW5: free and bound identifiers in Erlang code) [Spring'13: free and bound variables in (\x -> (\y -> map (f x) lst)) Fall'13: free and bound variable identifiers in (g (\g -> (\a -> (\b -> (length (g b)))))); Spring'15: free and bound variable identifiers in: concat(map(fun(Y) -> F(X,Y) end, (fun(Q,R) -> Q end)(LS,empty))) ] + Which kind of scoping does Erlang have: static or dynamic? (HW4: scope in Erlang; HW5: scope rules and closures) + How do closures aid in static scoping? (HW5: scope rules and closures) + Static vs. dynamic scoping (HW5: which is more useful: static or dynamic scoping?) + Scoping for exception handlers (HW5: exceptions and scope rules) + type checking + What is the difference between static and dynamic type checking? (HW5: type checking, does Erlang keep information about types at runtime? does Haskell?) + Which kind of type checking is found in Erlang? (or Haskell?) (HW4: type checking; HW5: example that executes without type error in Erlang but gives type error in Haskell) + What is a type error? (HW5: example of type error in Erlang; example vs. Haskell) + Abstraction and Information Hiding + What is an abstract data type (ADT)? (HW5: ADTs) + How do Haskell and Erlang differ in support for ADTs? [HW5: ADTs] + How are data abstraction and information hiding enforced in Erlang? (HW5: modules, data abstraction and information hiding) + Syntactic sugars + What is a syntactic sugar? What is an example in Erlang? (HW5: syntactic sugar example in Erlang) + processes: + What features in Erlang create and manipulate processes? + When should you use a stateless or stateful server? (HW5: when to use stateless servers?) - Given a sample program, say what possible orders of execution it has. - What happens when there is an unhandled exception in a process? + Semantic concepts in Erlang - What is a race condition? + What is message passing? What about it is asynchronous? + How do mailboxes work in Erlang? (What is their semantics?) - How does Erlang's receive work? How do after timeouts work? - Can processes and message passing be used to simulate mutable storage? + Can process have time-varying state in Erlang? + Are message executed concurrently by an Erlang server? - What is an agent or actor? - What is a protocol? COMPARISONS [Concepts] [MapToLanguages] [EvaluateModels]: - Comparison among programming models: - What is the difference between functional and imperative programming? - message passing model: - Why is message passing important? - How and when should message passing and processes be used? - What are the relative advantages and disadvantages of using the message passing vs. the functional model for solving problems? - What are the features of Erlang that make it interesting? - What is useful about Erlang's combination of features? -general - What programming style is best suited for what kinds of problems? - What are the advantages of each style of programming for making programming easier? - What is the difference between declarative and imperative programming? - What are the advantages of explicit state? - How does explicit state help abstraction? Encapsulation? - What are the goals of declarative programming? - What are the goals of message passing programming? - What makes a model or style of programming declarative? - What does declarativeness have to do with referential transparency? - Is programming with state declarative? Why or why not?