tags:

views:

522

answers:

11

From what I understand, OOP is the most commonly used paradigm for large scale projects. I also know that some smaller subsets of big systems use other paradigms (e.g. SQL, which is declarative), and I also realize that at lower levels of computing OOP isn't really feasible. But it seems to me that usually the pieces of higher level solutions are almost always put together in a OOP fashion.

Are there any scenarios where a truly non-OOP paradigm is actually a better choice for a largescale solution? Or is that unheard of these days?

I've wondered this ever since I've started studying CS; it's easy to get the feeling that OOP is some nirvana of programming that will never be surpassed.

+8  A: 

In my opinion, the reason OOP is used so widely isn't so much that it's the right tool for the job. I think it's more that a solution can be described to the customer in a way that they understand.

A CAR is a VEHICLE that has an ENGINE. That's programming and real world all in one!

It's hard to comprehend anything that can fit the programming and real world quite so elegantly.

Robin Day
As I was sitting here thinking about my question, I was kinda thinking the same thing. You can do just about anything with any paradigm (just like you can technically write Crysis in assembly), but it will be the easiest to a human to program in a way that he/she can organize in their brain the most naturally, which is almost certainly OOP.
JoeCool
I think the Car example is the single most stupid example used in OOP tutorials. Car is for structs, not for OOP. What does it say about information hiding? Nothing.
zilupe
I don't think the intent of the CAR example is ever to describe OOP completely. It is however an example that can be globally understood in order to introduce someone to the notion of an Object, nothing more. After that you can then use better examples to explain any other features of OOP.
Robin Day
Lisp has a lot of CAR aswell.
kotlinski
+1 the success of OOP is because humans are exceptionally good at classifying and modelling objects
annakata
I'm not sure I'd describe OO as being elegant... that crown probably has to go to Lisp as well. What drives OO is that it's so unavoidably pragmatic.
Kevin Wright
I wasn't saying OO is elegant. I was saying the the "fit" between RL and OO was elegant.
Robin Day
A: 

Using OOP makes the code easier to manage (as in modify/update/add new features) and understand. This is especially true with bigger projects. Because modules/objects encapsulate their data and operations on that data it is easier to comprehend the functionality and the big picture.

The benefit of OOP is that it is easier to discuss (with other developers/management/customer) a LogManager or OrderManager, each of which encompass specific functionality, then describing 'a group of methods that dump the data in file' and 'the methods that keep track of order details'.

So I guess OOP is helpful especially with big projects but there are always new concepts turning up so keep on lookout for new stuff in the future, evaluate and keep what is useful.

stefanB
+1  A: 

I'm the biggest fan of OOP, and I practice OOP every day. It's the most natural way to write code, because it resembles the real life.

Though, I realize that the OOP's virtualization might cause performance issues. Of course that depends on your design, the language and the platform you chose (systems written in Garbage collection based languages such as Java or C# might perform worse than systems which were written in C++ for example).

I guess in Real-time systems, procedural programming may be more appropriate.

Gal Goldman
A: 

Note that not all projects that claim to be OOP are in fact OOP. Sometimes the majority of the code is procedural, or the data model is anemic, and so on...

eljenso
some "OOP" projects only use objects as buckets to hold mounds of spaghetti code.
DarenW
+4  A: 

Linux is a large-scale project that's very much not OOP. And it wouldn't have a lot to gain from it either.

I think OOP has a good ring to it, because it has associated itself with good programming practices like encapsulation, data hiding, code reuse, modularity et.c. But these virtues are by no means unique to OOP.

kotlinski
It's not just Linux, pretty much every kernel that's commonly used these days (such as the Windows NT kernel) is written in C. That's because it is widely believed that C is the right tool for writing a kernel. That doesn't mean that it's a serious challenger to OOP for more mundane tasks though.
DrJokepu
Some parts of the kernel sources cannot use OOP due to the computer architecture. For example, the kernel API uses the CPU interrupts to communicate with the user processes and it is very hard to adapt objects here.
Zyx
@Zyx: No, that's not hard at all to adapt, look at the current OO operating systems (Singularity, Jnode), they all do it. When you call `open(2)`, the file descriptor it returns is an object. This is still OO by pattern, even though it isn't implemented directly by the language. Then you have block devices etc which can all be accessed in a uniform way, i.e: an interface.
Longpoke
A: 

The promise of OOP was code reuse and easier maintenance. I am not sure it delivered. I see things such as dot net as being much the same as the C libraries we used to get fro various vendors. You can call that code reuse if you want. As for maintenance bad code is bad code. OOP did not help.

Jim C
I downvoted because I don't agree. It's not that I'm an OOP fanatic, I just believe OOP helps.
CiscoIPPhone
A: 

People like to think of various things as "objects" and classify them, so no doubt that OOP is so popular. However, there are some areas where OOP has not gained a bigger popularity. Most of the systems use relational databases rather than objective. Even if the second ones hold some notable records and are better for some types of tasks, the relational model is unsually chosen due to its popularity, availability of tools, support and the fact that the relational model is in fact a mathematical concept, contrary to OOP.

Another area where I have never seen OOP is the software building process. All the configuration and make scripts are procedural, partially because of the lack of the support for OOP in shell languages, partially because OOP is too complex for such tasks.

Zyx
+4  A: 

Zyx, you wrote, "Most of the systems use relational databases ..."

I'm afraid there's no such thing. The relational model will be 40 years old next year and has still never been implemented. I think you mean, "SQL databases." You should read anything by Fabian Pascal to understand the difference between a relational dbms and an SQL dbms.

" ... the relational model is usually chosen due to its popularity,"

True, it's popular.

" ... availability of tools,"

Alas without the main tool necessary: an implementation of the relational model.

" support,"

Yup, the relational model has fine support, I'm sure, but it's entirely unsupported by a dbms implementation.

" and the fact that the relational model is in fact a mathematical concept,"

Yes, it's a mathematical concept, but, not being implemented, it's largely restricted to the ivory towers. String theory is also a mathematical concept but I wouldn't implement a system with it.

In fact, despite it's being a methematical concept, it is certainly not a science (as in computer science) because it lacks the first requirement of any science: that it is falsifiable: there's no implementation of a relational dbms against which we can check its claims.

It's pure snake oil.

" ... contrary to OOP."

And contrary to OOP, the relational model has never been implemented.

Buy a book on SQL and get productive.

Leave the relational model to unproductive theorists.

+1  A: 

See this and this. Apparently you can use C# with five different programming paradigms, C++ with three, etc.

Software construction is not akin to Fundamental Physics. Physics strive to describe reality using paradigms which may be challenged by new experimental data and/or theories. Physics is a science which searches for a "truth", in a way that Software construction doesn't.

Software construction is a business. You need to be productive, i.e. to achieve some goals for which someone will pay money. Paradigms are used because they are useful to produce software effectively. You don't need everyone to agree. If I do OOP and it's working well for me, I don't care if a "new" paradigm would potentially be 20% more useful to me if I had the time and money to learn it and later rethink the whole software structure I'm working in and redesign it from scratch.

Also, you may be using another paradigm and I'll still be happy, in the same way that I can make money running a Japanese food restaurant and you can make money with a Mexican food restaurant next door. I don't need to discuss with you whether Japanese food is better than Mexican food.

Daniel Daranas
+3  A: 

You might have a look at Erlang, written by Joe Armstrong.

Wikipedia:

"Erlang is a general-purpose concurrent programming language and runtime system. The sequential subset of Erlang is a functional language, with strict evaluation, single assignment, and dynamic typing."

Joe Armstrong:

“Because the problem with object-oriented languages is they’ve got all this implicit environment that they carry around with them. You wanted a banana but what you got was a gorilla holding the banana and the entire jungle.”

I just read that Armstrong is credited for coining the phrase "Concurrency Oriented Programming". How's that for an alternative to OOP? :)
+1  A: 

I doubt OOP is going away any time soon, it just fits our problems and mental models far too well.

What we're starting to see though is multi-paradigm approaches, with declarative and functional ideas being incorporated into object oriented designs. Most of the newer JVM languages are a good example of this (JavaFX, Scala, Clojure, etc.) as well as LINQ and F# on the .net platform.

It's important to note that I'm not talking about replacing OO here, but about complementing it.

  • JavaFX has shown that a declarative solution goes beyond SQL and XSLT, and can also be used for binding properties and events between visual components in a GUI

  • For fault tolerant and highly concurrent systems, functional programming is a very good fit, as demonstrated by the Ericsson AXD301 (programmed using Erlang)

So... as concurrency becomes more important and FP becomes more popular, I imagine that languages not supporting this paradigm will suffer. This includes many that are currently popular such as C++, Java and Ruby, though JavaScript should cope very nicely.

Kevin Wright