Heterodoxy

Whammo on 2001-12-11T05:04:55

"There ain't no good guy
There ain't no bad guy
There's only you and me and
We just disagree"
-- Dave Mason


I don't like Object Oriented programming.



There. I said it. Can't stand it. Give me procedural code any day.



There's a lot of hubbub in Perl circles about Ruby. There's a lot of hubbub everywhere about Java.



Well, OO is where it's at.



So they say. Oh, sure, there's a lot of things that are often packaged with OO that I like. Method and operator overloading. Inheritence. Data encapsulation. (Although not strict encapsulation. It's painful to see so many programmers jumping through hoops to get around one of the very features they often tout.)



As a matter of fact, there's really only one thing that kills OO for me.



That you can't program in it?



Very funny. No. The syntax.



When I'm programming, I'm giving commands! Read in a string! Chop off the newline! Print that string out! None of this, "String, be read", "String, be chomped", or "String, be printed." (Or is that "Input, be read into the string", "Newline, be removed from the string", and "Output, be receptive to the contents given by string."?



A lot of people like the syntax. It's so clean. It's so pure.



@#$!



Look down inside that object code. What do you see? Yep, good old procedural stuff. When it comes down to nuts and bolts, it's still action-centric.



Not if it's done right.



Where everything's an object? Oh, come on. You don't actually believe that, do you? Do you normally communicate that way? Do you normally think that way? "I, these two numbers, will add." Of course not. That's why you still see the very "procedurish" 'a = b + c' in OO code.



Except that '+' is probably an overloaded method of one of the classes.



I said I like overloading. But tell me this:



If you can overload an operator and still make it procedurish, why can't you do it with a regular method? You can still have all the good things normally associated with (but not necessarily limited to) traditional OO languages, but keep a more standard procedural syntax. Why isn't there a language that balances the two, instead of the Jeckyl and Hyde nature of object-centric syntax?



Oh, wait. There is.



Perl.



Indirect object syntax.



Which no one likes.



Except, apparently, for me.


Wrong premise

Matts on 2001-12-11T11:00:30

I think you *do* like object oriented code. You just don't like the syntax.

Moreover, I think you might like it better if you thought in terms of message passing. You pass an object a message to frobnosticate, and it obeys.

Besides, not everything should look OO, it's just a good design pattern for the underlying system. Read the internals section of the pickaxe book and you'll see what I mean - I'm willing to bet it would be impossible to explain Perl's internals in such a short section.

But we should still be pragmatic. Yes, a + b should still look like a + b. It just makes sense that way. How it's implemented internally though is of consistency and beauty (in ruby's case).

Besides, processors work procedurally, not OO (well, these days they do funky parallel stuff, but I digress), so it would be impossible to be procedural all the way down to the bare metal. It's just a useful tool to layer over procedural code.