Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: "Native Perlish"

by hardburn (Abbot)
on Mar 26, 2003 at 15:21 UTC ( [id://245955]=note: print w/replies, xml ) Need Help??


in reply to "Native Perlish"

When learning a human language, people are encouraged to try to "think" in that language, instead of thinking in their native tounge and translating. Now, when it comes to human languages, I'm an utter failure at learning ones outside my native tounge (probably because I'm too lazy to really study another one). Even so, I recognize the principal of thinking in a different language.

I've noticed a similar trend in programming languages. I orginally learned BASIC on an Apple //c. Around 1995, I started learning a little about Perl. I didn't get very far with Perl back then, and I soon went onto C. I did fairly well in C and later learned Java. However, at first, I programmed Java as if it were C--i.e., no real use of OO. And if you're not using OO, why are you bothering with Java?

I later figured out how to use Java's OO effectivly, but then bought the Camel and really started learning Perl. However, I was still "thinking" in C, and my code looked like it. For instance, I was always using the three-element form of for, I use parans and return even when its not necessary (still do, but less so than I used to). I got mad that you couldn't say if($condition) print "true"; but instead had to do print "true" if($condition);.

I think PerlMonks (plus a job where I've been writing Perl almost every day for the past year) is what really got me to "think" in Perl. Whenever I try a new language, I come up with a Perl solution in my head and try to translate. This doesn't work so well for Perl as it did for C. C is fairly bare-bones, and its idioms can often be translated directly into a new language. Perl has some very special ways of doing things.

Looking at other people's Perl code, I can usually spot what language their thinking in. It seems that most Perl programmers come from a C background. This script (external link) looks like it was written by someone thinking in VB (notice the long series of if statements when they could have used elsif or (beter yet) a hash). People who are really thinking in Perl will often use a clever bit of map or grep and a clear grasp of regexen (using /x for anything too complex, hopefully).

So yes, there is very much a "Perlish" way.

----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer

Note: All code is untested, unless otherwise stated

Replies are listed 'Best First'.
Re: Re: "Native Perlish"
by l2kashe (Deacon) on Mar 26, 2003 at 17:15 UTC
    I completely agree with your point, though you probably stated it much more concisely than I would have.

    I am a relative programming "babe in the woods". I've been at this for about 3 1/2 years or so, and have noticed the following trend in myself and others either learning to program or adding a new language to their belt.

    1) Learning the syntax
    2) Learning the functions available (builtin and libs)
    3) Learning to think in the language
    4) Accepting the limitations of the language

    When you can think in the language I think you have really started to grok it. You can address your problem from the way the language will be able to deal with it best. Depending on the available capabilities of the language, this could mean you have mastered it (i.e BASIC) or are well on your way to getting into deeper solutions (C, C++, Perl). When you get to the point where you can honestly review a problem and determine that the language probably isnt the right solution, you have become what I would consider a "native".

    At that point you are able to cleary define the problem, how to address it in the language, and whether or not that is valid in the given situation.



    /* And the Creator, against his better judgement, wrote man.c */

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-19 07:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found