Don't ask to ask, just ask | |
PerlMonks |
Re: I dislike object-oriented programming in generalby MonkOfAnotherSect (Sexton) |
on Oct 19, 2007 at 01:37 UTC ( [id://645876]=note: print w/replies, xml ) | Need Help?? |
I suspect (and please don't take offense if I'm wrong - none is intended) that you are rebelling against formal Ivory Tower-ist training in Java. If that's the case, then you'll find many people that aren't mad about either Java or ivory-towerist OO ;-) Sensible OO-all-the-way-down ("SOOATWD") languages that are built on objects allow users to perform (at least) procedural programming without worrying about classes and objects. If you want, say, to operate on numbers in a loop in Python or Ruby without needing to think about "3" being an object under the covers you can (Ruby uses methods on its numbers, but code can still be fundamentally procedural in nature). Check out the Python and Ruby version of Chapters 2 and 3 of the Perl Cookbook v1, for instance, to see how non-threatening numbers as objects can be. In SOOATWD languages, your modules can be simply collections of procedures, or collections of higher-order functions, or, yes, classes. You can pass both functions and objects to and from other functions and objects. You can use whichever paradigm you need at any moment. Seriously. You don't have to think of "message passing". You can just call methods or member functions with parameters instead. Or whatever other terminology or world view makes you and others happiest. Part of the problem of OO equating to Inviolable Public Interface is Java's need for an object's variables to have accessor methods -- obj.getFoo(); obj.setFoo(x) -- since you may want to change the underlying implementation and if you don't use accessor methods then code which references those variables directly is screwed. This is far less of a problem with idiomatic code in SOOATWD languages which have properties, where underlying implementation can be changed and the changes remain invisible to any code which references those variables. Perl 6 won't be Java or Smalltalk ;-)
In Section
Meditations
|
|