
Programming styles
OOP and GP and Concurrency
We must evaluate programming styles/paradigms against a set of ideals.
Aims for
· For developers
· For programmers
· Etc
Programming languages are a means for expressing solutions; they still matter!
Classic OOP problems
· Double dispatch: intersection amon two objects
· Eternal polymorphism: adding operations to something
· Etc
Classic GP
Advantages
· Regularity and generality of code
· Shared implementation
· Composability
· Performance
Ex:
list
int s1 = accumulate(lst.begin(), lst.end(),0)
int p1 = accumulate(lst.begin(), lst.end(),1,multiply
vector
Matrix s2 accumulate(v.begin(), v.end(),0);
C++ GP: run-time efficiency with a high-level of abstraction
Classic template ex: prime # calculation by the compiler
Classic GP problems
· Irregularities of argument types
· No support for defining new types
OOP vs. GP
OOP: Ad-hoc polymorphism
GP: Parametric polymorphism
OOP: focus on design and use of hierarchies
GP: focus on design and use of algorithms
OOP: Dynamic (run-time) resolution of calls
GP: Static (compile-time) resolution of calls
OOP: Easy to add new type
GP: Hard to add new type
OOP: Hard to add new operation
GP: Easy to add new algorithm
There are solutions in the space that involves the combinations of these two styles.
Can we combine/extend these two styles to minimize problems? Bjarne’s guess: the convergence will hinge on concurrency
C++0x Concepts and Concept maps push GP support to more mainstream.
Concept maps help fix separately developed libraries together provided they are somewhat similar in semantics.
GP: runtime concepts (currently research)
References
· Design Patterns, 1994
· Concepts: Linguistics Support for Generic Programming in C++, OOPSLA ‘04
· Run-time concepts for the C++ standard library, SAC ‘08
· The C++ Programming Language, 2000
No comments:
Post a Comment