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

Re: the next step

by FoxtrotUniform (Prior)
on May 09, 2002 at 15:59 UTC ( #165411=note: print w/ replies, xml ) Need Help??


in reply to the next step

    I guess my question is what I should do to take my knowledge of Perl to the next level.

One way to raise your expertise: expose yourself to different languages, see what they do well, learn their idioms, and apply that to Perl. Lisp is the best example I can think of: if you get into Lisp, you'll learn all kinds of cool tricks involving anonymous subs, closures, lists, function application, and functional programming. (You can get pretty much the same techniques out of Haskell, but you'll miss currying and you'll even get to keep currying when you switch back to Perl.) Most of these tricks can be done in Perl.

As a happy consequence, you'll also have a bigger toolchest of techniques to use. Some problems are hard with one tool, and trivial with another.

Another way, which works really well and shows results quickly, is to subject your code to relentless peer review. Having other people paw through your work, pointing out which bits are awkward, which are error-prone, which are hard to maintain, and sometimes which are elegant, is a tremendously valuable learning tool. If learning other languages expands your toolchest, code review sharpens the tools.

I can't emphasize enough how important code review is. I'd say the primary advantage to working on an existing Open Source project is that you'll be able to push your code on other experienced programmers for review.

As a happy consequence, you'll develop some extra humility.

Update: Clarified the Haskell/currying point: you'll miss Haskell's currying when you go back to Perl. (IIRC, Perl 6 will support curried functions, so maybe it's not so big a deal.)

Update 2: So you can get curried functions in Perl, albiet with a bit more trouble than in Haskell. Thanks, educated_foo!

Good luck.

--
:wq


Comment on Re: the next step
Re: (FoxUni) Re: the next step
by educated_foo (Vicar) on May 09, 2002 at 16:55 UTC
    You can get pretty much the same techniques out of Haskell, but you'll miss currying.

    Huh? Haskell's curried...

    foo a b c = a ++ c ++ b with_parens a b = foo a b y = with_parens "<" ">"
    then print (y "banana") prints "<banana>". BTW, if you haven't, you should definitely check out Haskell, as it can be a truly mind-bending experience. It's easy to get up and running with the HUGS interpreter, now with delicious readline support.

    /s

    Update: you won't miss the currying anymore...

    use strict; use Carp; use Attribute::Handlers; sub _curry { my ($n, $func, @args) = @_; return sub { my $narg = @args + @_; if ($narg > $n) { carp "$narg args to curried function (expects $n)."; } elsif ($narg < $n) { return _curry($n, $func, @args, @_); } else { return &$func(@args, @_); } }; } sub curry : ATTR(CODE) { my ($package, $symbol, $code, $name, $n) = @_; confess "Usage: sub mysub : curry(N), where N > 0" unless $n; local($^W) = 0; no strict 'refs'; my $newsub = _curry($n, $code); *{$package . '::' . *{$symbol}{NAME}} = $newsub; } sub foo :curry(3) { print "foo: @_\n"; } my $x = foo(1,2); &$x(3); &$x(2);
Re: (FoxUni) Re: the next step
by emilford (Friar) on May 09, 2002 at 17:01 UTC
    Yeah, I was a bit confused by your Haskell and currying comment. Would you like to elaborate that one for my boggled mind. :P

    On the other hand, I 100% agree with your comment on getting your code reviewed. There is no better way than to learn from your mistakes and the experience of others. It's almost like having a mentor who can guide you along the path to Perl Wisdom. I'm not too sure, however, just how willing people will be to critique my code in the Open Source world. I'm sure they're more looking for programmers to get the job done quickly and efficiently.

    I guess the only way to find out is to jump right in!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (15)
As of 2014-04-16 16:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (432 votes), past polls