Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I'm a C# developer, but I also know Java, JavaScript, XSLT, a little of C and Perl, e some other that I may have forgotten. Still, the paradigm I'm most familiar to is OOP.

I have always thought that OOP was the natural evolution of procedural programming, but I wondered if OOP is that perfect. After reading some articles on the web and some questions here, I found that many people don't agree with this, and some say even that OOP is a bad option.

While developing, I really appreciate using lambdas, LINQ, anonymous types and really enjoy JavaScript with its prototyping and dynamic nature.

But still, I can't think of any scenario where OOP is not an option, or where other paradigms fits better. The only thing I can think of is that sometimes programming with OOP is really boring and slow, like having to declare a class, import some other classes and declaring a method, specifying its parameters, return type and name just to show "Hello, World!" on the console screen. But still, for real-life programs, it seems like something that compensates its cost.

In what scenarios does other paradigms fits better than OOP? What are its advantages over OOP and were does OOP makes things worse instead of helping? Especially, what are the advantages and in what scenarios do excel procedural and functional programming?

share|improve this question
    
2  
Do SQL database queries count? –  nikie Dec 16 '11 at 20:53
    
Yes, it anything counts :) –  Raphael Dec 16 '11 at 20:55
3  
    
Your view of OOP seems a bit limited! Why do you say that Javascript's prototype-based object system isn't OO? It's called "object oriented" after all, not "class oriented"... –  C. A. McCann Dec 17 '11 at 2:40

1 Answer 1

up vote 2 down vote accepted

For instance, functional programming languages are very useful in a context where you are interested in provably correct programs. They have the property that you operate with expressions which always evaluate to the same value. There is no notion of "state" of your program (except possibly for some bootstrapping code), which facilitates proving correctness in a mathematically rigurous way.

share|improve this answer
    
Functions that have no side effect are also called pure functions. –  rightføld Dec 17 '11 at 0:32
    
This doesn't really apply to any of the functional languages in practical use, though. There are languages designed for proving things which are based on functional programming, and can convert proofs to code in a functional language, but there's still a big difference between a proof in Coq and a program in OCaml. –  C. A. McCann Dec 17 '11 at 2:27
    
@C.A.McCann, en.wikipedia.org/wiki/Curry-Howard_correspondence - strict typing, seen in many functional languages, is somewhat equivalent to proving correctness. –  SK-logic Dec 17 '11 at 14:10
    
@SK-logic: Not in the presence of non-terminating expressions, which allow a program to "prove" anything. Look at the sort of answers I post on Stack Overflow--trust me, I'm very familiar with the distinction here. :] –  C. A. McCann Dec 17 '11 at 16:25
    
@C.A.McCann, a type system guarantees a proof that certain constraints always hold, and that's it, nothing more. Of course all the type systems are limited (but some of them guarantees a termination) - just as well as any other correctness proving techniques. Distinction between strict typing and proving correctness is quite vague, thanks to the Curry-Howard isomorphism. –  SK-logic Dec 17 '11 at 17:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.