views:

92

answers:

4

I know of class-based and protype based object oriented programming languages, are there any other alternatives? What are they?

+2  A: 

mixins allow you to extend a class with code that is defined elsewhere, such as in a module.

See Ruby Mixin Tutorial for an introduction.

Justin Ethier
how is it different from class based OOP with multiple inheritance (implementation without diamond problem)?
Gabriel Ščerbák
I agree it is very similar, however a mixin allows you to inject code from an "ancestor" without implying an *is a* relationship for the descendant. Or in other words you could think of it as an interface that may also contain code.
Justin Ethier
ah, I understand, something like plicy based design in C++, where you would use traits to compose template class... if I understand it right, this violates Liskov Substitution principle right? Or is the "mixedIn" relationship explicitly different from inheritance?
Gabriel Ščerbák
A: 

You may want to check Wikipedia's article on programming paradigms. The one I've worked with is aspect-oriented programming, which is where the mixins come in.

http://en.wikipedia.org/wiki/Programming_paradigm

bryanjonker
I read it and there is no further information regarding my question.
Gabriel Ščerbák
+1  A: 

Go has a concept that is similar to classes, but without inheritance and with very flexible interfaces. You can read more about it in Effective Go.

Lukáš Lalinský
Hmm, this remainds me of something I heard about OOP in functional languages. Are there any requirements for a function adding to types interface/bahaviour? Does it have to be in same package at least?
Gabriel Ščerbák
+1  A: 

These are indeed the two main approaches behind object-oriented languages, and I'm not aware of another completely different underlying principle.

But there exists a lot of variants of both approaches, as well as a lot of other programming language constructs that tackles reuse/extensibility in either class-based or prototype-based language. Examples: traits, mixin, extension methods, partial class, generics, first-class slots, split objects, etc. A lot of such constructions are first proposed in research papers (ECOOP, OOPSLA, POPL conferences), and a few of them become mainstream in popular languages. But I would qualify them as variations and not as groundbreaking new underlying principle.

Note though than you can mimic object-oriented programming in languages which are not object-oriented per-se. For instance, with Clojure multi-method. Object-oriented and functional programming are also slowly merging, for instance in Scala.

EDIT

It's actually hard to make a list of classic/seminal papers, and I don't pretend to have sufficient knowledge to do so. If there is one somewhere, I would be very interested to see it :) Still, here are a few ones that might interest you.

Inheritance, delegation, subtyping:

Module, composition, adaptation

ewernli
Hmm, I guess you are right, can you point me directly to some influential/good research papers? I will give you upvote straight for some links... I am aware of some of the functional stuff like in CLOS etc. I am interested in hearing more, therefore I asked this question:)
Gabriel Ščerbák