Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
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. ---- Note: All code is untested, unless otherwise stated In reply to Re: "Native Perlish"
by hardburn
|
|