in reply to When to Use Object Oriented approach in Perl? (RFC)

Object-oriented programs run slightly slower [....] If you can get away without using object orientation, you probably should.

What a horrible conclusion. An equivalent conclusion is "If it is possible to do something in C or C++, then you probably should just not do it in Perl."

What are usually rather trivial run-time performance differences should have nearly zero bearing on your choice of approach. Even if your OO experiment found that the OO code was consistently 20% slower than the non-OO code, that is unlikely to be a significant factor in evaluating whether or not to use OO for that case (are you even going to notice most of the time if your script takes 3 seconds to run instead of 3.6 seconds to run?).

Clearly it shouldn't be the single most important factor. That particular comment should be simply and easily dismissed.

- tye        

  • Comment on Re: When to Use Object Oriented approach in Perl? (gah)

Replies are listed 'Best First'.
Re^2: When to Use Object Oriented approach in Perl? (gah)
by thanos1983 (Parson) on Aug 01, 2014 at 09:13 UTC

    Hello tye,

    You are right, a user would not been able to observe a difference even of a second. Some times I found my self spending too much time and effort trying to improve and compare my code with small percentages.

    The reason that I am using Perl is that simplifies life so much and also there are so many modules available to choose upon that it makes all other programming languages look so poor.

    So in conclusion is C and C++ faster? Yes, since Perl is written in C. But, taken in consideration the variety of modules available in Perl, I do not think so there is something to compare here.

    Apart from timing and simple tasks is also the ability to solve something really fast and really simple. This is the beauty of Perl.

    Thank you for your time and effort reading and replying to my question.

    Seeking for Perl wisdom...on the process...not there...yet!

      One nit to pick: C isn't faster than Perl because Perl is written in C. It's faster because it isn't doing much behind the scenes compared to what Perl is doing. Once you layer in a significant portion of what Perl would be doing, a C program would begin to perform similar to Perl, or worse since its code hasn't undergone the years of scrutiny Perl has.

      One reason that XS is useful is that it allows the programmer to decide what things that Perl would normally do are unnecessary in a particular xsub, thus only paying for what is needed and used.


      Dave

        Hello Dave,

        Nice short and valuable explanation, I did not think about that.

        Thank you for your time and effort clarifying these details.

        Seeking for Perl wisdom...on the process...not there...yet!