views:

265

answers:

4

OOP is probably the most used programming paradigm in today's software design. My question is -- what other paradigm(s) can compete with it and can stand in the place of oop? To clarify that question, I'm not asking about what other paradigms there are. There are many of them and I'd like to know which one:

  • Has been used in practice, not only in theory.
  • Can compete with oop, so it can be used in a large project without or with minimum of pain.
  • Can be used to develop a desktop app with business logic, databases, and so on.
  • Is not used with companion of oop, but can replace oop.

And if there is any, what are the pros/cons of it, why it is better/worse than oop, what languages are the best to use it, what about using it in popular languages, has it any design patterns, and can it totally replace oop?

+10  A: 

Functional programming is another programming paradigm that is popular, mostly in academics. The best example of a functional programming language is Haskell and Standard ML.

The fundamental difference between functional programming and object oriented programming is that you are programming in the sense of data flow instead of control flow. See the presentation Taming Effects with Functional Programming by Simon Peyton-Jones for a good introduction.

A good example of functional programming used in the industry is Erlang. It is mostly used in telecommunication, distributed and fault tolerant systems. See the presentation Erlang - Software for a concurrent World by Joe Armstrong.

There is also newer functional programming languages that combines it with OOP. Two good examples is F# for the .NET platform and Scala for the Java platform, they can often use existing libraries on the platform written in other languages.

The trend of new programming languages now is Multi-paradigm, where multiple paradigms like object oriented programming and functional programming is combined in the same language.

Jonas
Can functional programming replace oop or is it used with oop? Are there any real world examples of apps written in this paradigm? What about design patterns?
ventr1s
Scala aims to integrate features of object-oriented and functional languages.
Philipp
Good answer, yet I think that functional programming and object-oriented programming are not two sides of a medal, they can perfectly coexist (as you mentioned). It's more like this: Procedural VS Object-oriented, Imperative VS Functional. Lisp is a popular procedural functional language, Java is an object-oriented imperative language.
fhd
@ventr1s: Yes, functional programming *can* replace OOP but it is most likely to be used together with OOP in languages like Scala and F#.
Jonas
@ventr1s: A good example of functional programming in the industry is the distributed NoSQL database RIAK written in Erlang. http://riak.basho.com
Jonas
@ventr1s: See this question about functional programming and design patterns: http://stackoverflow.com/questions/327955/does-functional-programming-replace-gof-design-patterns
Jonas
+1  A: 

FP - Functional Programming is an extremely popular programming paradigm that has been around for a very long time and has, in more recent years, started becoming more and more prominent. FP favors immutability over mutability, recursion, and functions with no side effects. Some examples of popular fp languages are Erlang, Scala, F#, Haskell and Lisp (among others).

Matthew J Morrison
Scala is a good example of the OOP/FP combination.
Justin Ardini
+2  A: 

Procedural processing was everything before OOP turned up, has produced some large real world applications (in fact, most of them originally) and many operating systems.

It can certainly be used in large scale products with a minimum of pain, and a maximum of performance

Woody
A: 

There are no paradigms currently that can genuinely replace OOP. The issue with (benefit of) OOP is that it does a vast amount of work for you- automatically releasing resources, validating data, etc, and it makes it easy to validate code- not to mention that the vast majority of the world's existing libraries are written in an OOP language like C++, C# or Java. The reality of getting along without such large-scale libraries and such is exceedingly doubtful.

In niche or academic worlds, you'll find a lot of Functional Programming. However, if you really want to do a large project, OOP is the only way to go.

I think that generic programming is going to come up as a new paradigm. However, it's really still in the development phase and only C++/D offer genuinely good generic programming.

DeadMG
OOP doesn't do any of those things. It can make them easier, but only if the design of the OO framework includes them, like in .Net, or if you are willing to write them.
Matt Ellen
Technically, you're right. However, the reality is that all popular OO languages include resource management as a feature of object orientation. You'd be hard pressed to find a directly object supporting language that doesn't include it. And the OP is clearly interested in practice, not theory.
DeadMG
resource management is not a feature of object orientation - resource management is a feature of imperative programming languages, which can be object oriented or not. I don't know of any purely functional languages that force you to manage system resources explicitly.
Matthew J Morrison