Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: How do you master Perl?

by NateTut (Deacon)
on Apr 11, 2005 at 16:05 UTC ( #446650=note: print w/ replies, xml ) Need Help??


in reply to How do you master Perl?

Maybe this should be one of the basic topics, but I see plenty of "experts" making this mistake. Write readable code! Use meaningful variable names. Yes "foo" and "bar" are cute names but they don't say much about what is going on in your code.

Obfuscation and golfing are fun diversions, but don't write your production code that way. Use comments and spend some time on the layout of your code to make it presentable. Be proud of your work.

My $0.02.


Comment on Re: How do you master Perl?
Re^2: How do you master Perl?
by brian_d_foy (Abbot) on Apr 11, 2005 at 19:14 UTC

    Ah yes, the dear topic of the organized mind!

    I actually tend to think the people who golf and obfuscate aren't really the culprits of the everyday unreadable code.

    I really don't know how to deal with that problem, and some Perl masters don't have the greatest styles. I vaguely remember a great quote from a master programmer who said that computer program where meant to be read by humans, not computers. Was it Knuth? Does anyone know this quote?

    I think this comes back to a master controlling his environment. Randal could probably instruct me on further koans about this (and he did learn quite a number of interesting things in that part of his life). I'll have to think more about this one.

    --
    brian d foy <brian@stonehenge.com>
      I agree I think Obfuscating and Golfing are unrelated to unreadable production code. One technique I was taught early on (in another programming language) is to write the comments first. Write in the comments what you are going to do in the code. It really helps to clarify your plans and to remember what that plan was after you've struggled through the early portions

      Unreadble code often comes from unskilled coders, but not always. Some people just hate typing so much they make all their variable names 1 character. I like code that reads like poetry...

      I vaguely remember a great quote from a master programmer who said that computer program where meant to be read by humans, not computers. Was it Knuth? Does anyone know this quote?

      I have that quote on my homenode. It’s from the preface to the first edition of Structure and Interpretation of Computer Programs by Abelson, Sussman and Sussman. The exact phrasing is

      Programs must be written for people to read, and only incidentally for machines to execute.

      With regard to the topic of this thread, that book is highly recommended – and it’s available online freely, in full.

      Makeshifts last the longest.

Re^2: How do you master Perl?
by dragonchild (Archbishop) on Apr 11, 2005 at 19:52 UTC
    Obfuscation and golfing are fun diversions, but don't write your production code that way. Use comments and spend some time on the layout of your code to make it presentable. Be proud of your work.

    As a golfer, I have to point out that golfed code is production code. It's just a different kind of "production" than the one you get paid for. Same with obfuscation, even more so than golf. Layout is extremely important, especially in multi-line golfs. And, I am proud of every golf I write.

    Now, I understand what you're trying to get at. Readability is the key is code that is meant to be edited. So, you should "golf" for editability. :-)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (10)
As of 2014-12-26 11:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (171 votes), past polls