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

Re: How do I train myself to write more Perl-ish Perl, rather than C-ish Perl?

by Joost (Canon)
on Dec 13, 2007 at 14:50 UTC ( [id://656831]=note: print w/replies, xml ) Need Help??


in reply to How do I train myself to write more Perl-ish Perl, rather than C-ish Perl?

If you want to be forced into the habit of using higher-level constructs, just maybe perl isn't the right language to do that, since it doesn't really force you to do anything you don't want.

Have you considered using some other high-level language that more or less forces you to disregard C-like ugliness and makes you work with map/grep-type functional constructs? Something like scheme/lisp may work well.

I'm not suggesting you'd use it instead of perl (though you may prefer it), but using it for a while should in the very least open your head to the possibilities and much many of the techniques used in lisp/scheme can be used in perl too.

Since you're a programmer with some experience this book - with full text available online should give you enough information to get started with common lisp. Can't really recommend any scheme books, since I haven't read any.

  • Comment on Re: How do I train myself to write more Perl-ish Perl, rather than C-ish Perl?

Replies are listed 'Best First'.
Re^2: How do I train myself to write more Perl-ish Perl, rather than C-ish Perl?
by mpeg4codec (Pilgrim) on Dec 13, 2007 at 19:00 UTC
    I will definitely second this, I had to learn Lisp (for AI) and Scheme and OCaml (for programming languages) last year at uni. While all three have constructs for iterative loops (for example), my professors wouldn't allow us to use them, forcing us to think in terms of recursive calls. Just this simple rule alone allowed me to think more ``functionally'', and soon I was thinking in terms of recursive algorithms, higher order functions, and so forth. This bled over to my Perl hacking, and my code has never been less C-like.

    I was stuck in the rut of the C way of doing things, but functional languages showed me the light. I'd recommend anyone take a short vacation away from imperative languages if they haven't yet.

Re^2: How do I train myself to write more Perl-ish Perl, rather than C-ish Perl?
by amarquis (Curate) on Dec 13, 2007 at 15:41 UTC

    No, I definately don't want Perl to start telling me what to do and how. I just think that, out of laziness, I've been coding the exact same way (a style built up while learning to program with C, C++ and Java), and I'd like to break out of the rut.

    Jumping to something like LISP sounds like a very good idea to shake things up, and wasn't something I'd not thought of. Thanks for the link as well, I'll definitely play around with it in my spare time.

Re^2: How do I train myself to write more Perl-ish Perl, rather than C-ish Perl?
by Cop (Initiate) on Dec 18, 2007 at 05:23 UTC

    C isn't ugly, your thought is. C lets you do everything in the way you want, but virtually nothing is built-in. That's all. Don't make conclusions that are dramatic.

Log In?
Username:
Password:

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

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

    No recent polls found