Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: When does programming become automatic (if ever)?

by Anonymous Monk
on Apr 13, 2016 at 08:54 UTC ( [id://1160298]=note: print w/replies, xml ) Need Help??


in reply to When does programming become automatic (if ever)?

After many years of using Perl, I still don't always remember the order of arguments to substr or splice, but what I can do is type perldoc -f splice at lighting speed...

Point being, one way to get good at Perl is to know where all the documentation is. Having read or at least skimmed all of the documentation of Perl, a few books, and many CPAN modules at one point or another, I know what tools are available and where to look when I need something.

Replies are listed 'Best First'.
Re^2: When does programming become automatic (if ever)?
by Your Mother (Archbishop) on Apr 13, 2016 at 11:38 UTC

    Replying to you but for the OP's benefit. I think you're aware of everything I'm about to write.

    This is really an important revelation, I think. A year or so before I started picking up Perl I became faster in a Unix environment than just about everyone at work. It wasn't aptitude as much as comfort (I wasn't scared to try new things), good typing skills, and laziness. Typing orderstat and specstat and friends six thousand times a day was for the birds. Alias o and s afforded one finger typing, and automatic mouse-selection-buffer copy plus one button pasting meant I was faster out of the gate than everyone else. alias pd "perldoc" has been in my .aliases since I learned it exists. I live by Ctrl^R on the command line.

    In an age of instant documentation, being an adept librarian/researcher is equivalent to years of training. And having comfort with the tools means that once you find something, you can make it trivial to reuse. One that comes to mind–

    alias hs "perldoc -m HTTP::Status | perl -ne '/\A\s+100/ .. /510/ and +print'"
      Agreed! Another one to add to the list: sometimes it's easiest to just test something. Not sure about precedence? perl -MO=Deparse,-p -e ... Not sure what context something is in? sub ctx { warn wantarray ? "list\n" : "scalar\n" } Something else? Whip up a quick script using one of the Test:: modules. Data::Dumper and friends debug 75 to 95% of my problems. And so on...
Re^2: When does programming become automatic (if ever)? (IDE support)
by LanX (Saint) on Apr 13, 2016 at 09:07 UTC
    Talking about "automatisms" ...

    > I still don't always remember the order of arguments to substr or splice,

    that's actually a good idea for extending snippets in my IDE (yasnippet/Emacs) ¹

    > what I can do is type perldoc -f splice at lighting speed

    actually I could also expand the embedded documentation to reflect this in my IDE

    > at lighting speed...

    unfortunately not at light speed, often you are redirected to other perldocs

    like in

    perldoc -f m m// The match operator. See perlop.

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

    ¹) other suggestions for not memorable interfaces? caller ? what else ?

      often you are redirected to other perldocs

      That was kind of the point: Knowing when to look in perlre, perlop etc. helps!

      > that's actually a good idea for extending snippets in my IDE (yasnippet/Emacs) ¹

      for the records some trivial templates for yasnippet, which is derived from textmates standard and is similar to snippMate for vim.

      Not too far away from Abbrevations in Komodo.

      # -*- mode: snippet -*- # name: caller; # key: caller # -- my (${1:$package}, ${2:$filename}, ${3:$line}) = caller; $0

      # -*- mode: snippet -*- # name: caller(LEVEL) # key: caller # -- my (${2:$package}, ${3:$filename}, ${4:$line}, ${5:$subroutine}, ${6:$ +hasargs}, ${7:$wantarray}, ${8:$evaltext}, ${9:$is}_require, ${10:$hints}, ${11: +$bitmask}, ${12:$hinthash}) = caller(${1:$LEVEL}); $0

      please note that both versions of caller are expanded with the same keyword + TAB and you can chose from a dropdown between both versions.

      here the example for splice

      # -*- mode: snippet -*- # name: splice @ARR ,OFFSET ,LENGTH ,LIST # key: splice # -- splice @${1:ARR} ,${2:OFFSET} ,${3:LENGTH} , ${4:LIST...};

      since I can include code (elisp but also bash or Perl) I'd like to find a way to delete the commas of skipped arguments instead of creating 4 versions for drop down... but I'm still at the beginning.

      Vision: Ideally these snippets could be generated from POD-examples and show the documentation¹, I think DBI is a good candidate.

      Cheers Rolf
      (addicted to the Perl Programming Language and ☆☆☆☆ :)
      Je suis Charlie!

      PS: thanks to Tux for suggesting the return values for stat, (local)time, and caller (with or without args)

      ¹) probably best realized in combination with autocomplete-mode ... unfortunately emacs-wiki seems to be down at the moment...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (10)
As of 2024-04-18 12:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found