Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^2: In Need of Mentoring

by chromatic (Archbishop)
on Jan 15, 2012 at 23:18 UTC ( [id://948030]=note: print w/replies, xml ) Need Help??


in reply to Re: In Need of Mentoring
in thread In Need of Mentoring

You almost make it sound as if coding style were merely a matter of fashion and not a matter of correctness. Consider the difference between a C-style for loop and iteration.


Improve your skills with Modern Perl: the free book.

Replies are listed 'Best First'.
Re^3: In Need of Mentoring
by qazwart (Scribe) on Jan 16, 2012 at 02:32 UTC

    It's both. As I pointed out, perlbool teaches people who want to learn object oriented programming to use var and use @ISA. If I look at Perldoc, there's use parent. And, at one time I was told this is how you create a constant:

    *PI = \3.14159; our $PI;

    Now we have use constant.

    And, there is a fashion in coding just as much as there is in the dresses in Vogue. We use to tell people to parenthesize everything because it was more readable. Now, we tell people to eliminate unnecessary parentheses because it clutters code and makes it less readable. Variable names use to be camelCase, now we are suppose to use underscores. And, what is the best way to do an infinite loop? Do you use for(;;) or while (1)

    Or should that be while ( 1 ) ; because the style is now to leave a space around parentheses and various punctuation marks because it's more readable. However, when I was learning C, I was told to get rid of spaces around parentheses because it made my code harder to read.

    I'm just happy I never learned about use English; until I was told that it shouldn't be used because it makes your programs run slower and it doesn't really make your programs more readable anyway.

      Or should that be while ( 1 ) ; because the style is now to leave a space around parentheses and various punctuation marks because it's more readable. However, when I was learning C, I was told to get rid of spaces around parentheses because it made my code harder to read.

      From what you've said, you've been programming long enough to have formed your own opinion. Have you?

      One of the lessons I learnt quite early on in my career -- thanks to a boss (and mentor) who favoured independent thought over group-think -- was that I should arrive at my own conclusions rather than accepting received wisdom. His words were (roughly):

      Listen to others arguments -- when they can be separated from opinion -- but draw your own conclusions.

      That has stood the test of time -- nearly 25 years -- and continues to serve me well.

      It allows me to perceive group-think; badly justified 'rules'; the latest greatest fads; and preserved-in-aspic dogma; for what they are: lazy thinking and/or born-again over-corrections. Let your own powers of reason be your guide.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

      The start of some sanity?

      It's both.

      The engineering part of programming allows us to learn from our mistakes. Things we did back in the '90s in Perl turned out to be more trouble than they're worth. Similarly things done in the '00s. I'm sure we'll look back on stuff done in the '10s with the same disdain, but if we're learning and evaluating based on what we've learned, I think we have a reasonable chance to improve.


      Improve your skills with Modern Perl: the free book.

Re^3: In Need of Mentoring
by educated_foo (Vicar) on Jan 15, 2012 at 23:54 UTC
    LOL.
    You almost make it sound as if coding style were merely a matter of fashion and not a matter of correctness. Consider the difference between a C-style for loop and iteration.
    I'd say the difference is a matter of *style*. Which way you write your loop has fuck-all to do with correctness, but the C-style loop will likely get you scolded on this website.

    EDIT: Apparently, I should have logged out and posted this anonymously to avoid losing karma. Oh, well.

      ... the C-style loop will likely get you scolded on this website.

      If you've never made a fencepost error, I salute you. The rest of us mortals seem to benefit from not having to worry about such things.


      Improve your skills with Modern Perl: the free book.

        Of course I've made fence post errors. But then on constructs that would be really awkward to do without C-style for loops.

        I don't think I've ever made a fence post error on

        for (my $i = 0; $i < @array; $i++) { ... }
        where I would not modify @array or $i, nor use $i to look elsewhere in the array. But then, this is about the only case where I would not use a C-style for loop, but a Perl style foreach.
      "LOL" == what a dog's tongue does on a hot day. You've made it clear what your slobberings are worth
        It's clever and courageous of you to log out before posting this "witty" comment.
      Nah, FWIW I ++ed it. Also FWIW, I think the OP should just put the thing on CPAN, none of this github etc crap. (Don't give in to the CPANazis.)
Re^3: In Need of Mentoring
by JavaFan (Canon) on Jan 16, 2012 at 09:13 UTC
    Consider the difference between a C-style for loop and iteration.
    Yeah, what about it? Is one of them incorrect? I know C programs with for loops that are correct, are you implying iteration is incorrect?
      I know C programs with for loops that are correct...

      Me too. I also know C programs with for loops that are incorrect. A C-style for loop can do everything an iterator can do, if you're willing to program it to do so. Why do languages support iteration natively instead of making everyone write structural code by hand (or by editor) every time?

      Is one of them incorrect?

      We both know better.


      Improve your skills with Modern Perl: the free book.

        If you're implying that I've suggested to never use "iterators", you cannot be further from the truth.

        But just because iterators exists, doesn't mean C-style loop are suddenly bad. Most people discover the world is more than black and white at the age of 4; but many programmers seem not have grasped the idea the world is filled with shades of gray, and even colours.

        BTW, I know Perl programs with iterators that are incorrect.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-04-20 01:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found