Final Review TA Review Session Final Exam CS 242 Monday Dec 10

Slides:



Advertisements
Similar presentations
Objects and Classes David Walker CS 320. Advanced Languages advanced programming features –ML data types, exceptions, modules, objects, concurrency,...
Advertisements

Type Systems and Object- Oriented Programming (III) John C. Mitchell Stanford University.
Kathleen Fisher cs242 Reading: “Concepts in Programming Languages”, Chapter 6.
Programming Languages and Paradigms
Lecture 10: Part 1: OO Issues CS 540 George Mason University.
Portability and Safety Mahdi Milani Fard Dec, 2006 Java.
INF 212 ANALYSIS OF PROG. LANGS Type Systems Instructors: Crista Lopes Copyright © Instructors.
Georgia Institute of Technology Workshop for CS-AP Teachers Chapter 3 Advanced Object-Oriented Concepts.
Object Oriented Programming Chapter 7 Programming Languages by Ravi Sethi.
CS 330 Programming Languages 10 / 16 / 2008 Instructor: Michael Eckmann.
Objects and Classes David Walker CS 320. Advanced Languages advanced programming features –ML data types, exceptions, modules, objects, concurrency,...
Programming Language Paradigms: summary. Object-oriented programming Objects are the fundamental building blocks of a program. Interaction is structured.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
C#.NET C# language. C# A modern, general-purpose object-oriented language Part of the.NET family of languages ECMA standard Based on C and C++
© 2006 Pearson Addison-Wesley. All rights reserved4-1 Chapter 4 Data Abstraction: The Walls.
Scripting Languages For Virtual Worlds. Outline Necessary Features Classes, Prototypes, and Mixins Static vs. Dynamic Typing Concurrency Versioning Distribution.
Run time vs. Compile time
Programming Languages Structure
Data Abstraction and Object- Oriented Programming CS351 – Programming Paradigms.
1 Run time vs. Compile time The compiler must generate code to handle issues that arise at run time Representation of various data types Procedure linkage.
Objects and Classes David Walker CS 320. Advanced Languages advanced programming features –ML data types, exceptions, modules, objects, concurrency,...
OOP in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
OOP Languages: Java vs C++
Programming Languages and Paradigms Object-Oriented Programming.
OOPs Object oriented programming. Based on ADT principles  Representation of type and operations in a single unit  Available for other units to create.
Sadegh Aliakbary Sharif University of Technology Fall 2011.
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
Types for Programs and Proofs Lecture 1. What are types? int, float, char, …, arrays types of procedures, functions, references, records, objects,...
1 Chapter 10: Data Abstraction and Object Orientation Aaron Bloomfield CS 415 Fall 2005.
Algorithm Programming Bar-Ilan University תשס"ח by Moshe Fresko.
1 Programming Language History and Evolution In Text: Chapter 2.
1 COSC3557: Object-Oriented Programming Haibin Zhu, Ph. D. Associate Professor of CS, Nipissing University.
Types John Mitchell CS 242. Type A type is a collection of computable values that share some structural property. uExamples Integers Strings int  bool.
CSE 425: Object-Oriented Programming I Object-Oriented Programming A design method as well as a programming paradigm –For example, CRC cards, noun-verb.
The Procedure Abstraction, Part V: Support for OOLs Comp 412 Copyright 2010, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in.
Guided Notes Ch. 9 ADT and Modules Ch. 10 Object-Oriented Programming PHP support for OOP and Assignment 4 Term project proposal C++ and Java Designer.
Introduction to Object Oriented Programming CMSC 331.
Midterm Review John Mitchell CS 242. Midterm uThurs Nov 7, 7-9PM Terman Aud Closed book uClass schedule Thurs Oct 31, Tues Nov 5 – topics not on midterm.
Programming Languages by Ravi Sethi Chapter 6: Groupings of Data and Operations.
CS112: Structure of Programming Languages A smorgasbord of topics in programming languages including programming paradigms and syntax, semantics, implementation.
Objects & Dynamic Dispatch CSE 413 Autumn Plan We’ve learned a great deal about functional and object-oriented programming Now,  Look at semantics.
Chapter 10, Slide 1 ABSTRACT DATA TYPES Based on the fundamental concept of ABSTRACTION:  process abstraction  data abstraction Both provide:  information.
Lecture 10 Concepts of Programming Languages Arne Kutzner Hanyang University / Seoul Korea.
Object-Oriented Programming Chapter Chapter
Design Patterns David Talby. This Lecture Re-routing method calls Chain of Responsibility Coding partial algorithms Template Method The Singleton Pattern.
(1) ICS 313: Programming Language Theory Chapter 12: Object Oriented Programming.
OOPs Object oriented programming. Abstract data types  Representationof type and operations in a single unit  Available for other units to create variables.
CS-1030 Dr. Mark L. Hornick 1 Basic C++ State the difference between a function/class declaration and a function/class definition. Explain the purpose.
ISBN Object-Oriented Programming Chapter Chapter
Principles of programming languages 10: Object oriented languages Isao Sasano Department of Information Science and Engineering.
1 CS Programming Languages Class 22 November 14, 2000.
Semantic Analysis II Type Checking EECS 483 – Lecture 12 University of Michigan Wednesday, October 18, 2006.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Inheritance and Class Hierarchies Chapter 3. Chapter Objectives  To understand inheritance and how it facilitates code reuse  To understand how Java.
Author: DoanNX Time: 45’.  OOP concepts  OOP in Java.
CSE 341 Section 10 Subtyping, Review, and The Future.
A Survey of Object-Oriented Concept Oscar Nierstrasz.
Types John Mitchell CS 242. Type A type is a collection of computable values that share some structural property. uExamples Integers Strings int  bool.
CS 100Lecture 231 Announcements Check your grades on the door of 5141 Upson More review tomorrow Review session Sunday night w/Alan FINAL EXAM: Tuesday.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
ISBN Chapter 12 Support for Object-Oriented Programming.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 10 Java Fundamentals Objects/ClassesMethods.
Language Paradigms CS655.
Design issues for Object-Oriented Languages
Programming Language History and Evolution
Object Lifetime and Pointers
Names and Attributes Names are a key programming language feature
Types for Programs and Proofs
Names, Binding, and Scope
The Procedure Abstraction Part V: Run-time Structures for OOLs
Presentation transcript:

Final Review TA Review Session Final Exam CS 242 Monday Dec 10 12:15 – 3:15 PM B01

Announcements Today – last homework due 5PM No section this week Homework graded tomorrow, available Friday No section this week Next week Final exam – Monday afternoon Local SCPD students come to campus for exam IMPORTANT : Remote students email us by this Friday for faxing instructions.

Outline Course overview 50 questions you should know how to answer Course summary

Course Goals Understand how programming languages work Appreciate trade-offs in language design Be familiar with basic concepts so you can understand discussions about Language features you haven’t used Analysis and environment tools Implementation costs and program efficiency Language support for program development

General Themes in this Course Language provides an abstract view of machine We don’t see registers, length of instruction, etc. We see functions, objects, pointers (in some lang), … If programs don’t depend on implementation method, compiler writers can chose best implementation Language design is full of difficult trade-offs Expressiveness vs efficiency, ... Important to decide what the language is for Every feature requires implementation data structures and algorithms

Good languages designed for specific purpose C: systems programming JavaScript: make web pages interactive Lisp: symbolic computation, automated reasoning FP: functional programming, algebraic laws ML: theorem proving Clu, ML modules: modular programming Simula: simulation Smalltalk: Dynabook, C++: add objects to C Java: set-top box, Internet programming

Design Issues Language design involves many trade-offs space vs. time efficiency vs. safety efficiency vs. flexibility efficiency vs. portability static detection of type errors vs. flexibility simplicity vs. "expressiveness" etc These must be resolved in a manner that is consistent with the language design goals preserves the integrity of the abstract machine

Many program properties are undecidable (can't determine statically ) Halting problem null pointer detection alias detection perfect garbage detection etc. Static type systems detect (some) program errors statically can support more efficient implementations are less flexible than either no type system or a dynamic one

50 things you should know to get an A in CS242 Necessary, not sufficient condition

50 Questions to answer… 1. Write tail-recursive factorial in Lisp. 2. Explain the Lisp memory model. What is car and cdr? 3. Which is faster, an interpreter or a compiler? 4. Be able to evaluate (lambda f. lambda x. f (f x)) (lambda y. y+1) 5. Be able to explain the difference between alpha and beta reduction.

50 Questions to answer… 6. What makes a functional language different from a non-functional language? Parenthesis? 7. Cogently explain why everyone doesn't use functional programming. 8. Write a proof undecidability of the halting problem. 9. Appropriately reduce something to the halting problem.

50 Questions to answer… 10. Know the difference between pass-by-value, pass-by-reference. Be able to solve a problem related to this. 11. Explain a situation where compile time type checking is a bad idea. 12. Explain what type safety is and why Java has it and C does not. 13. Would adding type inference to C be a good idea?

50 Questions to answer… 14. Know how to do type inference tree questions. 15. Explain Polymorphism vs Overloading. How are they different. Give a language that uses each of them. 16. Describe an activation record. What is in it and why? 17. The control/access link points to the ...? 18. Explain dynamic scoping and give 2 examples where it was used from the class.

50 Questions to answer… 19. Define and compare the upward and downward funarg problems. 20. Why do we need closures (other than to give you some diagrams to fill out)? 21. What are the 4 aspects of OOP? <you better know this> 22. What is the difference between subtyping and inheritance. Give a language where these are the same and one where they are different.

50 Questions to answer… 23. How are objects represented in Simula? 24. Draw the runtime Smalltalk representation of a colored point. 25. Explain why the Ingalls test may not be the best way to judge a PL. What aspect of languages does he focus on? 26. What is the main C++ design goal? Give 3 examples of C++ design decisions that directly support this goal.

50 Questions to answer… 27. C++ vs Smalltalk vs Java dynamic lookup, how are they different. Is C++'s really dynamic? 28. How are C++ vtables laid out in subclasses? 29. What is the difference between virtual and overloaded C++ functions? 30. Explain the diagram on C++ slide 28 without getting confused.

50 Questions to answer… 31. How does C++ deal with diamond inheritance? And what is diamond inheritance? 32-34. Study, study, study. 35. Is Java like Smalltalk in that everything is an Object?

50 Questions to answer… 36. What is the difference between a C++ destructor and a Java finalize method? 37. Explain why Java arrays aren't really covariant. Since they aren’t covarient, they must be contravariant, right? 38. What are the steps from getting a class of the network to running it in the JVM? Why is each step run?

50 Questions to answer… 39. What is the purpose of stack inspection and how does it work? 40. What is the purpose of Java sandboxing and what kinds of actions are not allowed for programs in a sandbox? 41. What concurrency issues are not present in a multiprogramming environment that you have in a multiprocessor environment?

50 Questions to answer… 42. Write some Java code that has a critical section. Explain how you might get a race condition from your code. 43. Why does the Actor model of concurrency have forwarders? 44. How does the synchronize keyword work in Java? How do you synchronize blocks of code versus functions? 45. Why do many interoperability schemes use C/C++ as a "Lingua Franca"? Why not use Java?

50 Questions to answer… 46. What would a perfect world interoperability scheme look like? 47. What purpose does an interface definition language serve? What are two examples of IDL's given in class? 48. What’s a buffer overflow and how do language features in Java help prevent it? 49. How do you draw the layout of memory in relation to scoping? 50. Have you studied?

Summary of the course JavaScript Lisp Fundamentals ML and type systems lambda calculus functional prog ML and type systems Block structure and activation records Exceptions and continuations Modularity and objects encapsulation dynamic lookup subtyping inheritance Simula and Smalltalk C++ , Java Concurrency Logic programming

Fundamentals Grammars, parsing Lambda calculus Functional vs. Imperative Programming

JavaScript Language Features Stack memory management Parameters, local variables in activation records Garbage collection Automatic reclamation of inaccessible memory Closures Function together with environment (global variables) Exceptions Jump to previously declared location, passing values Object features Dynamic lookup, Encapsulation, Subtyping, Inheritance Concurrency? Do more than one task at a time (JavaScript is single-threaded)

Lisp Summary Successful language Specific language ideas Symbolic computation, experimental programming Specific language ideas Expression-oriented: functions and recursion Lists as basic data structures Programs as data, with universal function eval Stack implementation of recursion via "public pushdown list" Idea of garbage collection.

Algol Family and ML Evolution of Algol family Recursive functions and parameter passing Evolution of types and data structuring ML: Combination of Lisp and Algol-like features Expression-oriented Higher-order functions Garbage collection Abstract data types Module system Exceptions

Types and Type Checking Types are important in modern languages Program organization and documentation Prevent program errors Provide important information to compiler Type inference Determine best type for an expression, based on known information about symbols in the expression Polymorphism Single algorithm (function) can have many types Overloading Symbol with multiple meanings, resolved at compile time

Type inference algorithm Example - fun f(x) = 2+x; > val it = fn : int  int How does this work? Graph for x. ((plus 2) x) Propagate to internal nodes and generate constraints int (t = int) intint tint Solve by substitution = intint x  @ + 2 Assign types to leaves : t int  int  int real  realreal : int

Block structure and storage mgmt Block-structured languages and stack storage In-line Blocks activation records storage for local, global variables First-order functions parameter passing tail recursion and iteration Higher-order functions deviations from stack discipline

Summary of scope issues Block-structured lang uses stack of activ records Activation records contain parameters, local vars, … Also pointers to enclosing scope Several different parameter passing mechanisms Tail calls may be optimized Function parameters/results require closures Closure environment pointer used on function call Stack deallocation may fail if function returned from call

Control Structured Programming Exceptions Continuations Go to considered harmful Exceptions “structured” jumps that may return a value dynamic scoping of exception handler Continuations Function representing the rest of the program Generalized form of tail recursion

Modularity and Data Abstraction Language support for information hiding Abstract data types Datatype induction Packages and modules Generic abstractions Datatypes and modules with type parameters Design of STL

Concepts in OO programming Four main language ideas Encapsulation Dynamic lookup Subtyping Inheritance Why OOP ? Extensible abstractions; separate interface from impl Program organization Work queue, geometry program, design patterns

Simula 67 First object-oriented language Designed for simulation Later recognized as general-purpose prog language Extension of Algol 60 Standardized as Simula (no “67”) in 1977 Inspiration to many later designers Smalltalk C++ ...

Simula Summary Class: ”procedure" that returns ptr to activation record Objects: closure created by a class Encapsulation used as basis for C++ Subtyping: determined by class hierarchy Inheritance: provided by class prefixing Object access Access any local variable or procedures using dot notation Memory management Objects garbage collected

Smalltalk Major language that popularized objects Object metaphor extended and refined Used some ideas from Simula, but very different lang Everything is an object, even a class All operations are “messages to objects” Very flexible and powerful language Similar to “everything is a list” in Lisp, but more so Method dictionary and lookup procedure Run-time search; no static type system Independent subtyping and inheritance

Smalltalk Summary Class creates objects that share methods pointers to template, dictionary, parent class Objects: created by a class, contains instance variables Encapsulation methods public, instance variables hidden Subtyping: implicit, no static type system Inheritance: subclasses, self, super

C++ Summary Objects Classes: virtual function table Inheritance Created by classes Contain member data and pointer to class Classes: virtual function table Inheritance Public and private base classes, multiple inheritance Subtyping: Occurs with public base classes only Encapsulation member can be declared public, private, protected object initialization partly enforced

Function subtyping Subtyping principle Subtyping for function results A <: B if an A expression can be safely used in any context where a B expression is required Subtyping for function results If A <: B, then C  A <: C  B Subtyping for function arguments If A <: B, then B  C <: A  C Terminology Covariance: A <: B implies F(A) <: F(B) Contravariance: A <: B implies F(B) <: F(A)

Java Summary Objects Classes Inheritance have fields and methods alloc on heap, access by pointer, garbage collected Classes Public, Private, Protected, Package (not exactly C++) Can have static (class) members Constructors and finalize methods Inheritance Single inheritance Final classes and methods

Java Summary (II) Subtyping Virtual machine Determined from inheritance hierarchy Class may implement multiple interfaces Virtual machine Load bytecode for classes at run time Verifier checks bytecode Interpreter also makes run-time checks type casts array bounds … Portability and security are main considerations

Concurrency Concurrent programming requires Language support Ability to create processes (threads) Communication Synchronization Attention to atomicity What if one process stops in a bad state, another continues? Language support Synchronous communication Semaphore: list of waiting processes Monitor: synchronized access to private data

Concurrency (II) Actors, Cobegin / Coend Java language Threads: objects from subclass of Thread Communication: shared variables, method calls Synchronization: every object has a lock Atomicity: no explicit support for rollback Java memory model Compiler optimizations…

Good Luck! Think about main points of course Homework made you think about certain details What’s the big picture? Look at homework and sample exams Some final exam problems will resemble homework Some may ask you to use what you learned in this course to understand language combinations or features we did not talk about