1 Future of Abstraction Alexander Stepanov. 2 Outline of the Talk Outline of the Talk  What is abstraction?  Abstraction in programming  OO vs. Templates.

Slides:



Advertisements
Similar presentations
The C ++ Language BY Shery khan. The C++ Language Bjarne Stroupstrup, the language’s creator C++ was designed to provide Simula’s facilities for program.
Advertisements

Lecture 10: Part 1: OO Issues CS 540 George Mason University.
1 COSC2767: Object-Oriented Programming Haibin Zhu, Ph. D. Associate Professor of CS, Nipissing University.
Chapter 1 OO using C++. Abstract Data Types Before we begin we should know how to accomplish the goal of the program We should know all the input and.
1 STL and Its Design Principles Alexander Stepanov.
1 Objects and ClassesStefan Kluth 1.6Objects and Classes 1.6What is an Object? 1.7Objects and Classes 1.8Object Interface, Class Inheritance, Polymorphism.
Chapter 14: Overloading and Templates
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
OOP in C. Cfront Original C++ compiler was just a pre- processor –generated C code which could be compiled with an existing C Compiler.
C++ Training Datascope Lawrence D’Antonio Lecture 1 Quiz 1.
C++ fundamentals.
 By Wayne Cheng.  Introduction  Five Tenets  Terminology  The foundation of C++: Classes.
Shallow Versus Deep Copy and Pointers Shallow copy: when two or more pointers of the same types point to the same memory – They point to the same data.
Computer Science and Software Engineering University of Wisconsin - Platteville 7. Inheritance and Polymorphism Yan Shi CS/SE 2630 Lecture Notes.
OOP Languages: Java vs C++
CSE 332: C++ Algorithms II From Last Time: Search with Generic Iterators Third generalization: separate iterator type parameter We arrive at the find algorithm.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 14: Overloading and Templates.
Data Structures Using C++ 2E Chapter 3 Pointers and Array-Based Lists.
1 Classes- Inheritance Multiple Inheritance It is possible to derive a new class from more than one base class. This is called Multiple Inheritance. Under.
Polymorphism. Introduction ‘one name multiple forms’ Implemented using overloaded functions and operators Early binding or static binding or static linking.
CSE 332: C++ templates This Week C++ Templates –Another form of polymorphism (interface based) –Let you plug different types into reusable code Assigned.
Inheritance Joe Meehean. Object Oriented Programming Objects state (data) behavior (methods) identity (allocation of memory) Class objects definition.
Programming Languages and Paradigms Object-Oriented Programming (Part II)
Generic Programming Johan Torp. Agenda GP introduction GP in perspective Questions * GP = Generic programming in C++
Object Oriented Programming with C++/ Session 6 / 1 of 44 Multiple Inheritance and Polymorphism Session 6.
Chapter 6: User-Defined Functions
Overloading Binary Operators Two ways to overload –As a member function of a class –As a friend function As member functions –General syntax Data Structures.
OOP and Dynamic Method Binding Chapter 9. Object Oriented Programming Skipping most of this chapter Focus on 9.4, Dynamic method binding – Polymorphism.
Programming Language Support for Generic Libraries Jeremy Siek and Walid Taha Abstract The generic programming methodology is revolutionizing the way we.
C++ History C++ was designed at AT&T Bell Labs by Bjarne Stroustrup in the early 80's Based on the ‘C’ programming language C++ language standardised in.
Copyright © Curt Hill Generic Classes Template Classes or Container Classes.
Chapter 12: Pointers, Classes, Virtual Functions, and Abstract Classes.
Computer Engineering Rabie A. Ramadan Lecture 5.
Object Oriented Programming (OOP) Lecture No. 10.
Object-Oriented Programming Chapter Chapter
OOP in C++ CS 124. Program Structure C++ Program: collection of files Source (.cpp) files be compiled separately to be linked into an executable Files.
Digging into the GAT API Comparing C, C++ and Python API‘s Hartmut Kaiser
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.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 15: Overloading and Templates.
C++ Inheritance Data Structures & OO Development I 1 Computer Science Dept Va Tech June 2007 © McQuain Generalization versus Abstraction Abstraction:simplify.
Concepts in C++. Templates in current C++ C++ template is typeless No language support for constrained generics Accidental errors found in instantiation.
Chapter 3 Templates. Objective In Chapter 3, we will discuss: The concept of a template Function templates Class templates vector and matrix classes Fancy.
Presented by Ted Higgins, SQL Server DBA An Introduction to Object – Oriented Programming.
Chapter 1 C++ Basics Review (Section 1.4). Classes Defines the organization of a data user-defined type. Members can be  Data  Functions/Methods Information.
Java & C++ Comparisons How important are classes and objects?? What mechanisms exist for input and output?? Are references and pointers the same thing??
Polymorphism and Virtual Functions One name many shapes behaviour Unit - 07.
Chapter 16 Templates Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
C# Fundamentals An Introduction. Before we begin How to get started writing C# – Quick tour of the dev. Environment – The current C# version is 5.0 –
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 20 – C++ Subclasses and Inheritance.
CSE 332: C++ templates and generic programming II Review: Concepts and Models Templates impose requirements on type parameters –Types that are plugged.
Mr H Kandjimi 2016/01/03Mr Kandjimi1 Week 3 –Modularity in C++
Defining Data Types in C++ Part 2: classes. Quick review of OOP Object: combination of: –data structures (describe object attributes) –functions (describe.
Chapter 15 - C++ As A "Better C"
Inheritance Modern object-oriented (OO) programming languages provide 3 capabilities: encapsulation inheritance polymorphism which can improve the design,
Chapter 13: Pointers, Classes, Virtual Functions, and Abstract Classes
7. Inheritance and Polymorphism
Object-Oriented Programming (OOP) Lecture No. 45
OOP What is problem? Solution? OOP
Review: Two Programming Paradigms
Object-Orientated Programming
Finally! Discussing a language!
Chapter 12: Pointers, Classes, Virtual Functions, and Abstract Classes
Dr. Bhargavi Dept of CS CHRIST
Chapter 8: Class Relationships
Data Structures and ADTs
ENERGY 211 / CME 211 Lecture 17 October 29, 2008.
Jim Fawcett CSE687 – Object Oriented Design Spring 2014
Corresponds with Chapter 5
C++ support for Object-Oriented Programming
SPL – PS3 C++ Classes.
Presentation transcript:

1 Future of Abstraction Alexander Stepanov

2 Outline of the Talk Outline of the Talk  What is abstraction?  Abstraction in programming  OO vs. Templates  Concepts  A new programming language?

3 AbstractionAbstraction  The fundamental way of organizing knowledge  Grouping of similar facts together  Specific to a scientific discipline

4 Abstraction in Mathematics Abstraction in Mathematics Vector space {V: Group; F: Field; ×: F, V → V; distributivity; distributivity of scalars; associativity; identity} Algebraic structures (Bourbaki)

5 Abstraction in Programming Abstraction in Programming for (i = 0; i < n; i++) sum += A[i];  Abstracting +  associativity; commutativity; identity  parallelizability ; permutability; initial value  Abstracting i  constant time access; value extraction

6 1.Take a piece of code 2.Write specifications 3.Replace actual types with formal types 4.Derive requirements for the formal types that imply these specifications Abstraction in Programming

7 Abstraction Mechanisms in C++  Object Oriented Programming  Inheritance  Virtual functions  Generic Programming  Overloading  Templates Both use classes, but in a rather different way

8 Object Oriented Programming  Separation of interface and implementation  Late or early binding  Slow  Limited expressability  Single variable type  Variance only in the first position

9 Class reducer Class reducer class reducer { public: virtual void initialize(int value) = 0; virtual void add_values(int* first, int* last) = 0; virtual int get_value() = 0; }; class sequential_reducer : public reducer { … }; class parallel_reducer : public reducer { … };

10 Generic Programming Generic Programming  Implementation is the interface  Terrible error messages  Syntax errors could survive for years  Early binding only  Could be very fast  But potential abstraction penalty  Unlimited expressability

11 Reduction operator Reduction operator template typename iterator_traits ::value_type reduce(InputIterator first, InputIterator last, BinaryOperation op) { if (first == last) return identity_element(op); typename iterator_traits ::value_type result = * first; while ( ++ first != last) result = op(result, * first); return result; }

12 Reduction operator with a bug template typename iterator_traits ::value_type reduce(InputIterator first, InputIterator last, BinaryOperation op) { if (first == last) return identity_element(op); typename iterator_traits ::value_type result = * first; while ( ++ first < last) result = op(result, * first); return result; }

13 We need to be able to define what InputIterator is in the language in which we program, not in English

14 Concepts Concepts concept SemiRegular : Assignable, DefaultConstructible{}; concept Regular : SemiRegular, EqualityComparable {}; concept InputIterator : Regular, Incrementable { SemiRegular value_type; Integral distance_type; const value_type& operator*(); };

15 Reduction done with Concepts Reduction done with Concepts value_type(InputIterator) reduce(InputIterator first, InputIterator last, BinaryOperation op ) (value_type(InputIterator) == argument_type(BinaryOperation)) { if (first == last) return identity_element(op); value_type(InputIterator) result = * first; while ( ++ first != last) result = op(result, * first); return result; }

16 Signature of merge Signature of merge OutputIterator merge(InputIterator[1] first1, InputIterator[1] last1, InputIterator[2] first2, InputIterator[2] last2, OutputIterator result) (bool operator<(value_type(InputIterator[1]), value_type(InputIterator[2])), output_type(OutputIterator) == value_type(InputIterator[1]), output_type(OutputIterator) == value_type(InputIterator[2]));

17 Virtual Table for InputIterator Virtual Table for InputIterator  type of the iterator  copy constructor  default constructor  destructor  operator=  operator==  operator++  value type  distance type  operator*

18 Unifying OOP and GP Unifying OOP and GP  Pointers to concepts  Late or early binding  Well defined interfaces  Simple core language

19 Other Language Problems  Semantic information:  assertions, complexity  Multiple memory types:  pointers, references, parameter passing  Compilation model:  cpp, includes, header files  Design approach:  evolution vs. revolution

20 ConclusionConclusion We have to create a language that expresses everything we want to say about computations: If it is worth saying, it is worth saying formally.