1 / 23

CS ExCo

CS ExCo. Advanced in Topics Object-Oriented Programming. Connections Between: Functional & OO. Section 1: Language History. l -Calculus. Turing Machine. Why Do We Care?. Procedural Practical Little Math Grounding. Functional Programming Impractical Strong Mathematical Properties.

Download Presentation

CS ExCo

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS ExCo Advanced in Topics Object-Oriented Programming.

  2. Connections Between: Functional & OO Section 1: Language History

  3. l-Calculus Turing Machine Why Do We Care? Procedural • Practical • Little Math Grounding Functional Programming • Impractical • Strong Mathematical Properties Object-Oriented • Very Practical (fixes problems) • No Math Basis/ Chaos Theory

  4. What We Want to See: Functional Programming • Impractical • Strong Mathematical Properties Object-Oriented • Very Practical (fixes problems) • No Math Basis/ Chaos Theory Future OO Very practical Many Nice Mathematical properties

  5. A Bit of ProgrammingLanguages History Taken From: • Gelernter, David Hillel Programming Linguistics MIT Press, 1990 But first… What is a “Hero” language?

  6. Program Structure Flat No recursion No nested scopes No statement grouping No control structures goto & computed goto if (like computed goto) do (based around labels) Static Data Structure Flat Arrays Later strings Only locals & globals Static No dynamic allocation All locations picked at compile time Fortran (1957-66)

  7. Fortran:Abstractions? Hero? • Functions/Procedures • Absolutely no layered abstraction • Layered Abstraction: “first understand in general or in the abstract what’s going on; then worry about the details.” Apply recursively for best effect • At Least its consistent Hero! Achieved its goal to replace assembly Got people to actually use programming languages Hero? Or Villain?

  8. Program Structure Recursive Nested scopes Modules Recursive function calls Full set of control structures Static Data Structure Flat Arrays No records Dynamic Dynamically sized arrays Algol 60 “Algol Wall” Data and program structure Are separate worlds

  9. Algol 60: Hero? Yes • Discovered Recursive Program Structure.

  10. Program Structure Recursive Structure Calls Static Functions still aren’t first class values Dynamic Binding variables are bound within the calling environment Data Structure Recursive Atoms Lists Heterogeneous Lists Dynamic Garbage collection No records Lisp (60-65)

  11. Program Structure Flat Back to this again No parameter accepting subroutines No nested scopes Static Data Structure Records FINALLY! Tied to files Not “templates” for records Static No dynamic allocation COBOL (1960-61) A step back, IMHO

  12. PL/I for example: DECLARE FOOBAR DECIMAL FIXED REAL (8,3) STATIC EXTERNAL Algol 68: Allows anything, for example: this is an acceptable name for a variable of type integer Operator overloading, unions, pointers to anything, Call-by-reference Everything is first class and transparent, including procedures Yet: procedures are objects while structs “extend the language”, structures are based on arrays and one has data and programs and never shall the twain meet PL/I (1964) and Algol 68 COMPLEX

  13. Program Structure Partially recursive Procedures with recursive calls No true blocks, only compound statements Static Data Structure Flat Records Dynamic Record types extend type system Based on arrays Strongly typed Pascal (1971-74) Most importantly its simple! This temporarily reversed the trend. • “In an array structure, all components are of the same type…. In a record, the components (called fields) are not necessarily of he same type” • -Wirth

  14. Simula 67 The first Object-Oriented Language! The “Algol Wall” falls at last! Well, almost

  15. Program Structure Recursive Same as others Data Structure Recursive Dynamic Classes & Objects Classes instantiate objects Classes have code and take parameters Inheritance Simula 67: the language

  16. Fateful Choices • Broke down the “Algol Wall” by making data like procedures • We loose a way to describes object instances, just as there is no way to describe procedure instances • Classes and procedures are the same but distinguished by syntax as different class ACCOUNT(balance); real balance; begin integer acctNum; accrNum := getNextAcctNum(); procedure DEPOSIT(amount); real amount; balance := balance + amount; end … ref (ACCOUNT) MyAcct; MyAcct :- new ACCOUNT(45);

  17. No primitives Classes are objects Even blocks are objects Dynamically typed Extremely uniform Despite all this, it never was quite “it” Syntax is nearly unreadable, example: Given a “Point” class the plus method might be: +pt [ Point new x: x+pt x y: y+pt y] Smalltalk (1972-76)

  18. A complicated language designed for the DOD Based on Pascal Many different forms of packaging and data type declarations Strong typing with the flexibility of making new types Security was important (unlike Smalltalk and Scheme) No quite Object-Oriented Ada (mid 1970s)

  19. C, C++ and Eiffel • C gave us { } for blocks and lots of other nice syntax • C++ made OO and exceptions mainstream • Const allows expression of invariance • Eiffel is in the Pascal family • It is a well thought out OO language • Gave us the concept of whole program optimization • Hopefully the last of the Pascal line

  20. Anonymous Inner Classes GJ will have pretty good generics semantics Simplifies C++ greatly Java Our Hero

  21. Prototype Based OO LanguagesSelf etc. • No classes, only objects • New objects are made by cloning others • A “class” is just an object you use as a template • Can directly write objects and often add methods/properties on the fly • May be strongly or weakly typed

  22. BETA • Everything is a “pattern” • Patterns make up classes and methods • There is no direct representation of an object • Very similar to functional languages like Scheme • Strongly typed

  23. The Future? • Patterns are first class entities representing classes and methods • Direct object representations allow inner objects and modules • Ways to express invariance • Anonymous patterns and objects • Integration of Generics into the polymorphism system

More Related