Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Answer: Why is it said that Perl does not implement true object orientation?

by Anonymous Monk
on Mar 27, 2003 at 21:23 UTC ( #246347=categorized answer: print w/replies, xml ) Need Help??

Q&A > object-oriented programming > Why is it said that Perl does not implement true object orientation? - Answer contributed by Anonymous Monk

Object Orientation is implemented in a language for two reasons: reduce code clutter and catch programmer errors. In the first sense, Perl's OO works fine. In the second, core Perl lacks compile-time object type checks. Think of this as "strict" for checking argument types and return types, before the program even runs. Java and C++ do this. It is both handy and cumbersome. Forcing it on the programmer leads to large extentions to the language (C++ templates) or else hacks to bypass it (the Java Vector only stores objects of type "Object", meaning any object, which throws away all type information). Rest assured, Perl 6's spec makes it available - optionally.

  • Comment on Answer: Why is it said that Perl does not implement true object orientation?
Replies are listed 'Best First'.
Re: Answer: Why is it said that Perl does not implement true object orientation?
by gmpassos (Priest) on Mar 28, 2003 at 08:36 UTC
    Well, I think that Perl5 OO is very good and can make everything that a OO should, with everything that Java has (since Java "want" to be 100% OO). Much programmers like to say that for real OO you never can do a global variable. Other says that isn't OO if you haven't types for variables.

    Fisrt, in Perl you have global variables because Perl have a concept that you can do everything that you want, and you are not forced to use or not OO, or any thing. About the types for variables, well, Perl don't want to confuse the developer with variable types or conversions, you just need to think about the algorithm. And the variable types are there, at least for C/C++, because they are converted to assembler instructions (to than be machine codes), and the CPU need to know that before. And you win speed with the type (but in Java not, at least should), since you (well, the compiler, or interpreter, or VM) don't need to always check what type of variable is that, and what I need to make to work with 2 different types, who do that is the developer. But every one that already have worked with XS and internal Perl variables saw that a SV (scalar variable) have some states (Flags), like integer, double, string, utf8, etc... and this is a kind of type for variable, but Perl do this automatically for you, including the conversions. But the most interesting thing of the Perl5 interpreter is the speed, that is very good, and Perl5 is the fastest scripting language that have, and even with not "typed" variables the memory management is the best, in cases best than C/C++. Saw some time ago a good article about language comparations.

    About the C++ OO, well a lot of peoples say that C++ is not a real OO too. But I think that they are confusing OO with Java, or other thing. OO is a concept of how to organize an app, including the reuse of code. If you have this concepts you can make beautiful classes in C++. And wxWindows is there to show that, one of the best OO librarys in C++. For who don't know what is wxWindows, is a full portable C++ GUI library, that works on Linux, Mac, Win32, Motif, WinCE... For Perl take a look at wxPerl, that is wxWindows linked to Perl.

    Just in case:

    Final words: Who say that Perl OO is not a real OO just don't know Perl, and this is the problem, who say bad things about Perl always don't know and don't use Perl. Just think something about what Perl is. Well, I use a lot of languages, work with a lot of peoples, talk with a lot of PhD at computer cience, and saw that much peoples spend much time talking about theories, defending the theorie just by the theorie, but forget that the objective of the theorie is to be good at pratic. You can have a language that is good at theorie and forgot the pratic, the final objective of everything. But theorie is still important to have a good vision about all, and is from there that good ideas come. ;-)

    ... In other words, theorie is like talk about sex without do sex, but camasutra is still interesting. ;-P

    Graciliano M. P.
    "The creativity is the expression of the liberty".

Compile-time object type checks are orthogonal to OO
by IlyaM (Parson) on Mar 28, 2003 at 13:16 UTC
    Compile-time object type checks are actually orthogonal to OO. You may like strong typing or not but anyway its absense or presence in a programming language doesn't make it "more" OO. Case it point: Smalltalk which is often claimed to be a "true" OO language is a weak typed language.

    Ilya Martynov,
    CTO IPonWEB (UK) Ltd
    Quality Perl Programming and Unix Support UK managed @ offshore prices -
    Personal website -

Log In?

What's my password?
Create A New User
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (9)
As of 2018-05-28 08:15 GMT
Find Nodes?
    Voting Booth?