by timr · 17y ago · 0 comments
That's silly. Anyone who has worked with a pure OO language knows that there's nothing inherently imperative about the approach. Just because the most popular OO languages (C++, Java) ultimately force you to have a main() doesn't mean that a procedure is required to write OO code. That's more a reflection of the OS execution model than the language used to write the app.
I've personally written CORBA apps that were asynchronous, distributed and multi-threaded -- in C++. Object-oriented development is more than capable of handling the complexity of multi-core processing.
The point is, OO does not require that your code be executed any more sequentially than does a functional language.
OO does not require that your code be executed any more sequentially than does a functional language.
If by "OO", you mean mainstream OO languages like Smalltalk or Java, then they absolutely do have a more operational definition than a pure functional language does. Objects send messages to other objects; as a result of receiving a message, the internal state of an object changes.
An object-oriented program is not required to be expressed in terms of a "sequence of steps" any more than is a functional program. You can instantiate objects that talk to one another, asynchronously or otherwise, to collaboratively do work.
Several well-known Java gurus have advocated this, eg. Joshua Bloch. I worked with Ken Arnold for a bit, and a lot of the code he wrote was in this style.
The problem is that you're usually using Java because you want access to all those Java libraries, and the vast majority of Java libraries do not use this style. So you get state leaking into your program even if your own code doesn't do it.
(This is also why I'm less thrilled by Clojure than many other people are, even though I think it's a very well-designed language. The reason people are into Clojure is because it can use Java libraries and yet provides a mostly-functional language on top. But the problem isn't in Java-the-language, it's in Java libraries themselves. Unless you go rewrite the offending libraries - and this includes most of Swing, JSF, JFreeChart, the JavaBeans spec, and Calendar - you'll still run into problems. The only major libraries I've seen that use a relatively stateless style are Date and Java Collections Frameworks (both done by Josh Bloch, not surprisingly), JavaSpaces (done by Ken), and the basic String and Number classes.