Re: Non-OO interface to mysql



On 2008-12-21 23:31, Lars Eighner <usenet@xxxxxxxxxxxxxxx> wrote:
In our last episode, <qjr226xg7u.ln2@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>, the
lovely and talented Keith Keller broadcast on comp.lang.perl.misc:
On 2008-12-21, Lars Eighner <usenet@xxxxxxxxxxxxxxx> wrote:
In our last episode,
<Itf3l.18820$iY3.12303@xxxxxxxxxxxx>,
the lovely and talented Tim Greer
broadcast on comp.lang.perl.misc:

However, I don't see a reason to seek such a thing out, just to avoid OO
(so I assume there's more to the question),

The idea is precisely to avoid OO (best) or at least to have function type
calls (second best).

What exactly do you hope to gain by avoiding OO?

1) The horrible slowness and waste of resources.

If you care about that, why are you coding in Perl? Compared to any
language that compiles to native code (even indirectly via a
JIT-compiler, like most Java implementations) it's horribly slow. And
compared to any language which uses an explicit type system, it's a
horrible waste of computer resources. (But it frees a lot of human
resources, and for a given time budget, the Perl programmer may even be
able to write a faster and less resource-intensive program than the C
programmer).

Now, let's do a little reality check on the "horrible slowness":


#!/usr/bin/perl
use warnings;
use strict;

use Benchmark 'cmpthese';

my $phandle = 23;
my $ohandle = MyClass->new();
my $arg = "this is an argument";

cmpthese(-3,
{
'proc' => sub { foo($phandle, $arg) },
'oo' => sub { $ohandle->foo($arg) },
});


sub foo {
my ($handle, $arg) = @_;
return $arg;
}


package MyClass;

sub new {
my ($class) = @_;
my $self = {};
return bless $self, $class;
}

sub foo {
my ($self, $arg) = @_;
return $arg;
}
__END__

This little program compares a "procedural" subroutine call with an
oo-style method call.

Rate oo proc
oo 783445/s -- -7%
proc 838852/s 7% --

Hooray, procedural calls are 7 percent faster. That's a whopping 84
nanoseconds per call. But let's run it again:

Rate proc oo
proc 786957/s -- -7%
oo 842802/s 7% --

Oh, this time oo is 7 percent faster.

If you repeat that a few times you will see that in about 50 % of the
cases the procedural call is slightly faster than the oo call and in
50 % of the cases the oo call is slightly faster - or in other words,
the difference is not even measurable with a simple benchmark.

hp

.



Relevant Pages

  • Re: longridge
    ... Do I need to sit down and work out a programmer on the computer if I ... and one thing that irritates me is the duplication of resources. ... Mobile Incident Hike ... to collate such material and the National Scout Organisations were to ...
    (uk.rec.scouting)
  • Re: Ideal computer language from scratch?
    ... time programmer access to the PC resources. ... Even a beginning Assembly programmer has far more control ...
    (alt.lang.asm)
  • Re: [opensuse] KDE accessibility. was Bye bye SuSE?
    ... Ah.....so if a programmer doesn't use a given setup feature, ... Resources have to be expended, ... before I allocate ...
    (SuSE)
  • Re: Virtual Storage Controls - Was Re: REGION=0M and LSQA
    ... I don't mind that you disagree with me Rick, ... it is a colossal waste of time and effort (and system resources ... system programmer or the application programmer ... The one thing so many people seem to think that IEFUSI does protect them ...
    (bit.listserv.ibm-main)