Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Hacking with objects

by gregor42 (Parson)
on Mar 26, 2001 at 21:01 UTC ( [id://67236]=note: print w/replies, xml ) Need Help??


in reply to Hacking with objects

I write in several programming languages & have for quite some time now. Interestingly, though I sucessfully(?) have crammed several flavors of syntax into my skull that machines understand, I've never been very good at learning human languages.

Which is maybe why I love PERL so much!

The entire issue raised by this discussion thread can be answered by the first basic shibboleth of PERL:

TMTOWTDI!

There MUST ALWAYS be more than one solution to EVERY problem! You can use OOP or choose not to, and you will never be wrong, you may only be shown different paths to the solution. Are you optimizing for execution speed? In that case you most likely be better off going for the 'hack'. (Frankus' word, not mine.)

If you're feeling REALLY motivated & have too much time on your hands, then do it BOTH ways & play with Benchmark.pl & you may learn something about how PERL works under the hood.

OTOH, if you have very fast turn-around in your job, you may be more interested in the maintainability of your code. Especially if your intention is on code re-use. This this case OOP offers good guidelines for design that a trained monkey can follow when re-using your code later.

And please don't flame for for implying that the use of OOP in PERL is slow in general. I'm referring to optimizations. And I do believe in wrapping your psycho-fast routines in objects and method calls as a general design principle. But the nature of the project dictates that more than a general rule. If you have 1/2 hour to turn out a CGI, you're most likely not going to be eloquent, but rather down & dirty. If you happen to be writing full-blown applications, then you're going to need a more thought out & well planned approach & design.

Wait! This isn't a Parachute, this is a Backpack!

Replies are listed 'Best First'.
Re: Re: Hacking with objects
by frankus (Priest) on Mar 26, 2001 at 22:36 UTC

    It seems to me that a lot of people are versed in OO Principals and undoubtedly versed in Perl principles: "TIMTOWDI" and "can do!".

    So in my mind these people should feel there is dissonance where: Perls "can do!" meets OO's "thou shalt not" or if you don't like that: OO's "I wouldn't do that if I were you". The point is Perl's OO is "as you like it" .. there are legends, that Perl-Coders whisper around the terminals at night after pizza, of hackers who can change the inheritance of objects at run-time.

    Perl is laiden with features we (ab)use daily,so why are objects any different? Why, when I say Objects, do folk don their Systems Analysts hat?

    --
    
    Brother Frankus.
      Brother Frankus,
      Thank you for provoking a thoughtful discussion on an interesting subject and all the other contributers to this discussion for equally interesting replies.

      Concerning your question on objects being different, perhaps it is due to the way that OOP is taught. One always reads about a considerable amount of rigour in how an object should be created, public and private data, methods, encapsulation and on and on. Then you have the whole issue of creating beastiaries of objects, how they play together, etc. It starts to feel like Latin with all the rigour with which verb are tensed and objects are declined. But when spoken or composed by a fluent speaker, it can be magical.

      Then you have English, a ne'er do well language consisting of parts of several languages and newly created bits when folk feel like it. Grammar is considerably looser (certainly in the Rocky Mountain regions) and you can make your point even by fracturing your sentences to near intelligability. But again, it can be very powerful when used fluently.

      I have often thought the OOP is the new Latin and Perl as Modern English. I suspect the speed with which we abuse Perl as compared to objects is similar - Perl is perhaps more easily bent to a users will than the seemingly more rigourous OOP. Perl was designed to reflect natural languages, after all (unless I have misread the Camel book yet again). Rigour of form tends to make folk stick to the rules that they have spent a good deal of time learning and then (over)zealously apply them to how the language should be spoken. Perhaps this tends to stop folk from thinking as an English style hacker and more as Latin style formalist.

      Just a thought.

      MadraghRua
      yet another biologist hacking perl....

        Perl's motto is TIMTOWTDI. I think that most people view Perl's OO support as providing some of the more organized and methodical WTDI. That said, it is possible to express yourself very loosely and fluently using OO techniques. Structure and flexibility can go together...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://67236]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-04-24 12:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found