Do you have much use for formats, protos, ties,...?

Discussion in 'Perl Misc' started by kj, Mar 13, 2005.

  1. kj

    kj Guest

    I do a lot of Perl programming, and yet there are many Perl features
    that I *never* find a use for, and I wonder whether this is because
    these features are inherently not very useful, or it's me who is
    being just too dense to realize what I'm missing. In decreasing
    order "remoteness from everyday programming":

    1. formats

    2. prototypes

    3. operator overloading

    4. tied variables

    I'm curious whether other Perl programmers find these feature
    useless as I do, and if not (as is likely) when do you find any of
    these features truly handy? I.e. what kind of programming task
    would become for you significantly more difficult (or plain less
    fun) to code if the feature were not available?

    kj

    --
    NOTE: In my address everything before the first period is backwards;
    and the last period, and everything after it, should be discarded.
    kj, Mar 13, 2005
    #1
    1. Advertising

  2. kj wrote:

    >
    >
    >
    > I do a lot of Perl programming, and yet there are many Perl features
    > that I *never* find a use for, and I wonder whether this is because
    > these features are inherently not very useful, or it's me who is
    > being just too dense to realize what I'm missing. In decreasing
    > order "remoteness from everyday programming":
    >
    > 1. formats


    I actually used this once, but looking back at it, I should have
    just used printf.
    >
    > 2. prototypes
    >
    > 3. operator overloading


    In fact, you're already using this; you just don't know it. Perl does a
    lot of behind-the-scenes stuff with overloading. And with tied
    variable (see next), you're automatically using overloading; that's
    how tying works.
    >
    > 4. tied variables


    Now, this, on the other hand, is truly useful. I just finshed a
    program that reads and rewrites selected lines in a data file.
    Tie::File was *very* useful for this.
    >
    > I'm curious whether other Perl programmers find these feature
    > useless as I do, and if not (as is likely) when do you find any of
    > these features truly handy? I.e. what kind of programming task
    > would become for you significantly more difficult (or plain less
    > fun) to code if the feature were not available?
    >
    > kj
    >


    --
    Christopher Mattern

    "Which one you figure tracked us?"
    "The ugly one, sir."
    "...Could you be more specific?"
    Chris Mattern, Mar 13, 2005
    #2
    1. Advertising

  3. Chris Mattern <> wrote:
    > kj wrote:
    >
    >>
    >> I do a lot of Perl programming, and yet there are many Perl features
    >> that I *never* find a use for, and I wonder whether this is because
    >> these features are inherently not very useful, or it's me who is
    >> being just too dense to realize what I'm missing.



    There is another possibility:

    or have you just not done a project that would have benefited
    from the feature. (The "right tool for the job" thing.)


    >> In decreasing
    >> order "remoteness from everyday programming":
    >>
    >> 1. formats

    >
    > I actually used this once, but looking back at it, I should have
    > just used printf.



    That isn't enough if you need word-wrapping or page headers though.

    So there are modules for getting that stuff. :)

    I'd count this one as "never used". There are now better alternatives.

    I seem to remember that they will not be in the core of Perl 6
    either, which seems to reinforce that position.


    >> 2. prototypes
    >>
    >> 3. operator overloading

    >
    > In fact, you're already using this; you just don't know it. Perl does a
    > lot of behind-the-scenes stuff with overloading.



    Right, but here we were talking "Perl programming" rather
    than "perl programming". :)

    That is, their usefulness at the Perl Program (programmer's API) level.

    My take on the above 2:

    Prototypes are a cure that can be worse than the disease, not used.

    Operator overloading would most often introduce "startle factor",
    so used only in very special circumstances, eg: when you are
    implementing some domain-specific language in Perl.


    >> 4. tied variables

    >
    > Now, this, on the other hand, is truly useful.



    <aol> Me too! </aol>


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Mar 13, 2005
    #3
  4. kj

    kj Guest

    In <> Tad McClellan <> writes:

    >Chris Mattern <> wrote:
    >> kj wrote:
    >>
    >>>
    >>> I do a lot of Perl programming, and yet there are many Perl features
    >>> that I *never* find a use for, and I wonder whether this is because
    >>> these features are inherently not very useful, or it's me who is
    >>> being just too dense to realize what I'm missing.



    >There is another possibility:


    > or have you just not done a project that would have benefited
    > from the feature. (The "right tool for the job" thing.)



    >>> In decreasing
    >>> order "remoteness from everyday programming":
    >>>
    >>> 1. formats

    >>
    >> I actually used this once, but looking back at it, I should have
    >> just used printf.



    >That isn't enough if you need word-wrapping or page headers though.


    >So there are modules for getting that stuff. :)


    >I'd count this one as "never used". There are now better alternatives.


    >I seem to remember that they will not be in the core of Perl 6
    >either, which seems to reinforce that position.



    >>> 2. prototypes
    >>>
    >>> 3. operator overloading

    >>
    >> In fact, you're already using this; you just don't know it. Perl does a
    >> lot of behind-the-scenes stuff with overloading.



    >Right, but here we were talking "Perl programming" rather
    >than "perl programming". :)


    >That is, their usefulness at the Perl Program (programmer's API) level.


    >My take on the above 2:


    >Prototypes are a cure that can be worse than the disease, not used.


    >Operator overloading would most often introduce "startle factor",
    >so used only in very special circumstances, eg: when you are
    >implementing some domain-specific language in Perl.



    >>> 4. tied variables

    >>
    >> Now, this, on the other hand, is truly useful.



    ><aol> Me too! </aol>



    Talk about startle factor, I'm kind of down on tied variables
    because last week I spent a lot of time chasing a bug whose root
    cause I'm sure is in some variable-tying nonsense in one of the
    CPAN modules I was using (Filter::Util::Call). I didn't fully
    track down the bug, but, in a nutshell, the act of assigning $_ to
    a lexical variable would cause $_ to become undef. As in,

    my $x;
    $x = $_;
    print "\$x: $x\n\$_: $_\n"; # *immediately* after the assignment,
    # and in the same scope

    => $x: 1
    $_:

    Perl is tricky enough out of the box without any further attempts
    at tie magic. These tied variables seem to sharply add to the
    potential for befuddlement.

    kj

    --
    NOTE: In my address everything before the first period is backwards;
    and the last period, and everything after it, should be discarded.
    kj, Mar 13, 2005
    #4
  5. kj wrote:

    > I do a lot of Perl programming, and yet there are many Perl features
    > that I *never* find a use for, and I wonder whether this is because
    > these features are inherently not very useful, or it's me who is
    > being just too dense to realize what I'm missing. In decreasing
    > order "remoteness from everyday programming":
    >
    > 1. formats
    >
    > 2. prototypes
    >
    > 3. operator overloading
    >
    > 4. tied variables


    I agree with the ordering. I never use formats. I almost never use
    protypes.

    Operating overloading and tied variables are handy when writing a module
    that wants an elegant API. Since most prograqmming is either one side
    or the other of an API it is true that actually implementing the API
    itself is not an every-day task. I would however sorely miss these
    features were they absent.
    Brian McCauley, Mar 13, 2005
    #5
  6. kj

    Guest

    kj <> wrote:
    > I do a lot of Perl programming, and yet there are many Perl features
    > that I *never* find a use for, and I wonder whether this is because
    > these features are inherently not very useful, or it's me who is
    > being just too dense to realize what I'm missing. In decreasing
    > order "remoteness from everyday programming":
    >
    > 1. formats


    Never used them.

    >
    > 2. prototypes


    Never define my own subs to use them, but I do benefit from subs from other
    modules (e.g. List::Util) which do use prototypes.

    > 3. operator overloading


    I don't use them directly, but I think I do benefit from their use in
    modules which I am never explicitly made aware of.

    >
    > 4. tied variables


    I occasionally use this directly, like Tie::File and some hash cacheing
    module I don't recall, but find them only marginally useful. I may benefit
    more from using it indirectly without knowing it.


    > I'm curious whether other Perl programmers find these feature
    > useless as I do, and if not (as is likely) when do you find any of
    > these features truly handy?


    I've used tied variables to make large data structures more memory
    efficient without having to recode the whole program.

    Xho

    --
    -------------------- http://NewsReader.Com/ --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
    , Mar 13, 2005
    #6
  7. kj

    Big and Blue Guest

    kj wrote:

    > I do a lot of Perl programming, and yet there are many Perl features
    > that I *never* find a use for, and I wonder whether this is because
    > these features are inherently not very useful, or it's me who is
    > being just too dense to realize what I'm missing. In decreasing
    > order "remoteness from everyday programming":
    >
    > 1. formats


    I use this is some "quick-information" scripts to wrap output (*and* I
    set the variable which determines where the long line may be split).

    > 2. prototypes


    Used to check that I use the function correctly within the same file.

    > 3. operator overloading


    Never used this directly.

    > 4. tied variables


    Used to dump the contents of dbm files (useful for NIS tools).
    Big and Blue, Mar 14, 2005
    #7
  8. kj

    Jim Keenan Guest

    kj wrote:

    > I do a lot of Perl programming, and yet there are many Perl features
    > that I *never* find a use for, and I wonder whether this is because
    > these features are inherently not very useful, or it's me who is
    > being just too dense to realize what I'm missing. In decreasing
    > order "remoteness from everyday programming":
    >
    > 1. formats


    Used them in the first Perl program I ever wrote. Use the 'formline'
    function which powers them a lot to this day.

    >
    > 2. prototypes


    Never directly.

    >
    > 3. operator overloading


    Never directly.

    >
    > 4. tied variables
    >

    Tie::File: every day. Lately some use of tied filehandles in testing
    STDIN (a module I developed myself based on Camel book examples) and
    STDOUT (IO::Capture::Stdout, IO::Capture::Stdout::Extended). But the
    dirty details of tying are wrapped up inside these modules, so that I
    don't have to think about them at the script-writing level.

    Jim Keenan
    Jim Keenan, Mar 14, 2005
    #8
  9. kj

    phaylon Guest

    kj wrote:

    > 1. formats


    Nope.

    > 2. prototypes


    Jap, for any less-complex often-to-use functions.

    > 3. operator overloading


    Nope.

    > 4. tied variables


    Only for experimental/debugging. I always have this 'slow'-feeling when
    I'm using them.

    > I'm curious whether other Perl programmers find these feature useless as I
    > do, and if not (as is likely) when do you find any of these features truly
    > handy? I.e. what kind of programming task would become for you
    > significantly more difficult (or plain less fun) to code if the feature
    > were not available?


    I would just say every coder has his own favorite "tools".


    p

    --
    http://www.dunkelheit.at/
    thou shallst fear...
    phaylon, Mar 14, 2005
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andrew Thompson

    Code that ties up the compiler

    Andrew Thompson, Nov 26, 2008, in forum: Java
    Replies:
    1
    Views:
    279
    Roedy Green
    Nov 27, 2008
  2. cpp4ever
    Replies:
    3
    Views:
    354
    Francesco
    Sep 8, 2009
  3. Michael Angelo Ravera

    Ranking an array (with ties and tollerances)

    Michael Angelo Ravera, Aug 17, 2011, in forum: C Programming
    Replies:
    13
    Views:
    550
    Michael Angelo Ravera
    Aug 21, 2011
  4. Axel Etzold

    Finding ties in sorting?

    Axel Etzold, Sep 14, 2007, in forum: Ruby
    Replies:
    4
    Views:
    114
    Dan Zwell
    Sep 14, 2007
  5. Andrew Hamm

    Chains of ties

    Andrew Hamm, Jul 9, 2004, in forum: Perl Misc
    Replies:
    0
    Views:
    96
    Andrew Hamm
    Jul 9, 2004
Loading...

Share This Page