Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: disadvantages of perl

by zgrim (Friar)
on Jul 02, 2009 at 14:22 UTC ( [id://776759]=note: print w/replies, xml ) Need Help??


in reply to disadvantages of perl

I'm nobody, but hey, I'll give it a shot.

The C API is a mess. Ok, say you identified the few bottlenecks of your code with great profilers like NYTProf, now you think "i'll write that in C". Except, see, you'd need to be a freakin genious to get that right. The Perl C API should have an explicit motto like "Not for mere mortals" or "Abandon all hope ye who enter here". Or something. To program non-trivial stuff with its C API, you *have* to know all the implementation details of Perl. You know, all the stuff grown into it since 1994. Or something.

Speed. We lose each day on the speed front. It's not the late 90s anymore. :(

Multiple cores. perl copies waaay too much data around. Can not be told to do otherwise. Readonly is not readonly. Fork COW ? Exploding RAM. Given the rise of multiple cores this is... unfortunate.


Syntax. I need to repeat myself way too much. use warnings, strict, feature, shift, ref... think for example, params validation, say, is_non_empty_hashref,


# WTF if ( defined $r && ref $r && ref $r eq 'HASH' && keys %$r ) { ... }

Sigils are OK. IMHO, their only problem is that deep structures can become syntax horrors. I think explicit aliasing in the core could reduce this one.


Exposed internals. I know about the guts. I'd like to not care. KTHX.
# XXX PerlIO: Wide character... binmode $socket, utf8::is_utf8( $data ) ? ':utf8', ':raw';
Context gotchas! Quick, tell me the difference between lists and arrays. You think you wouldn't need to know ? wantarray() ? Oh...

Let me try to sum things up. Yes, i'd love the language to have macros, a speed{y,ier} VM, a clean and well-documented API, powerful function signatures, a bit-more-than-minimal OO, immutability, cached compilations (ie. working bytecode), assertions, inline expansions. Type hinting, for speed, would be the sugar on top. What did i miss ? Ah, *way-too-many-ways-to-do-stuff* !! :) I'd like the Core to HLP ME THRE PLIZ.

Yes, i know about the Promised Land. Oh, the Dream... Except, you know, Perl 6 is/will be *another* language. :)
I love Perl 5. It gets many things more than right. I like the people. I like the culture. Did i say i love perl ? And after it drives me nuts, i love it more, because that usually means i find "better" ways to do the stuff i was doing. And then i hate it again. And then... yes, sorry, it's a nice day here at the Asylum...


Update: del bad, pathological code, for spawning responses undermining the point :)

-- 
perl -MLWP::Simple -e'print$_[rand(split(q|%%\n|, get(q=http://cpan.org/misc/japh=)))]'

Replies are listed 'Best First'.
Re^2: disadvantages of perl
by ikegami (Patriarch) on Jul 02, 2009 at 15:25 UTC

    Exposed internals. I know about the guts. I'd like to not care. KTHX.

    # XXX PerlIO: Wide character... binmode $socket, utf8::is_utf8( $data ) ? ':utf8', ':raw';

    While the status of the UTF8 flag currently needs to be known and manipulated in some situations (bad!), that's not one of them. The UTF8 flag offers no indication as to whether something needs to be encoded or not. See Re: Decoding, Encoding string, how to? (internal encoding)

Re^2: disadvantages of perl
by JavaFan (Canon) on Jul 02, 2009 at 15:22 UTC
    if ( defined $r && ref $r && ref $r eq 'HASH' && keys %$r ) { ... }
    There's no need to write it like that. 'ref' never returns an undefined variable. You may write this as:
    if (ref($r || "") eq 'HASH' && keys %$r) { ... }
    Or, after turning off the appropriate warning:
    if (ref $r eq 'HASH' && keys %$r) { ... }
    which isn't too bad.

    Note that it won't enter the block if $r is a blessed hash, but that I consider a feature. (Otherwise, replace ref with Scalar::Util::reftype).

Re^2: disadvantages of perl
by Anonymous Monk on Jul 02, 2009 at 14:34 UTC
    # WTF if ( defined $r && ref $r && ref $r eq 'HASH' && keys %$r ) { ... }
    indeed
    if( $r and UNIVERSAL::isa($r,'HASH') and %$r ) { ... }
    Exposed internals. I know about the guts. I'd like to not care. KTHX. ..

    You don't need to know about the guts, but you do need to encode your data, if you care about its encoding.

      You don't need to know about the guts, but you do need to encode your data, if you care about its encoding.

      Unfortunately, you do in some circumstances. For example, the only difference in between $up and $dn in the following is the internal storage format, yet they differ in output.

      $\ = "\n"; utf8::downgrade $dn = chr(0xC9); utf8::upgrade $up = chr(0xC9); # <5.10 >=5.10 print pack('A', $dn) eq chr(0xC9) ?1:0; # 1 1 print pack('A', $up) eq chr(0xC9) ?1:0; # 0 1 print $dn =~ /\w/ ?1:0; # 0 print $up =~ /\w/ ?1:0; # 1

      They are being fixed. As you can see, pack no longer depends on the internal encoding since 5.10.0. Other discrepencies such as /\w/ are being fixed too.

      Should be
      if( UNIVERSAL::isa($r,'HASH') and %$r ) { ... }

        ... except that even that abusive code can't accurately determine if you can dereference all hashlike $r as a hash.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-04-23 23:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found