Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: [RFC] Review of module code and POD

by hippo (Bishop)
on Apr 01, 2021 at 10:05 UTC ( [id://11130668]=note: print w/replies, xml ) Need Help??


in reply to Re: [RFC] Review of module code and POD
in thread [RFC] Review of module code and POD

Consider using spaces instead of tabs for indentation.

8 simple words to start a holy war.


🦛

Replies are listed 'Best First'.
Re^3: [RFC] Review of module code and POD
by GrandFather (Saint) on Apr 01, 2021 at 11:13 UTC

    From that node subtitled "My arguement in favor of tabs": "Reputation: -34 (+44 -78)" - says it all really.

    Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond
Re^3: [RFC] Review of module code and POD
by Bod (Parson) on Apr 02, 2021 at 21:09 UTC
    Consider using spaces instead of tabs for indentation

    I never cease to be amazed at how The Monastery reveals that things I thought were standard practice...just aren't!

    The only formal education I have ever had relating to writing code was a short C++ course as part of my undergrad degree course and an even shorter Java course at another university as a small part of wider study. In both courses in the 1990's we were told to use tabs as indents and I didn't question why. Since then I have never questioned that anyone might do anything else...

    Is this a case of academia being out of touch with working practices or has the favour of spaces changes in the last quarter of a century?

      ... and I didn't question why.

      And thus is born tradition based on ..., actually I'm not sure what it's based on. Much bad process is a result of "because that's how I was told to do it" or, even worse, "that is how we did it at ...". From coding to coffee making to many other fields, progress is only made when people ask "Why?". The question shouldn't be judgmental or intended to create contention, but just for understanding and considering options. Emotive answers are almost always unhelpful, but white space and indentation issues often head that way.

      Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond
        From coding to coffee making to many other fields, progress is only made when people ask "Why?"

        Thankfully, in the intervening quarter of a century I have become much better at asking WHY!

        Indeed, a core part of my business culture revolves around the Four C's: We Create, we Communicate, we Care about our clients and colleagues and we do everything with Curiosity

        We hire against those criteria and our Core Competencies, Job Descriptions and Assessments are all based around those simple Four C's.

      You might think it doesn't matter whether you use spaces or tabs. Yet be very wary when using the make build automation tool. In what Eric S Raymond described as "one of the worst design botches in the history of Unix", semantic meaning was assigned to a TAB character in column one of makefiles!

      This tragic UI blunder has cost thousands of hours of lost productivity over many years. I've personally suffered, puzzling over cryptic error messages from make after my editor automatically converted TABs to spaces ... so I naturally singled it out as an example of a UI mistake when I wrote On Interfaces and APIs:

      The Unix make utility decrees that the actions of a rule must start with a tab. If you accidentally insert a space before the leading tab, look out! Ditto if your editor or other tool is configured to automatically convert tabs to spaces. This unfortunate design choice is a violation of the principle of least astonishment because most programs treat spaces and tabs the same way. Moreover, when you hit a (typically cryptic) error message for using a space instead of a tab, it may take a long time to figure out what the problem is because tabs and spaces look the same in most editors.

      Is this a case of academia being out of touch with working practices or has the favour of spaces changes in the last quarter of a century?
      It probably just happened to be the personal preference of your two lecturers. An analysis of the top 400,000 GitHub repositories reported that spaces were more popular than tabs in all languages except C and golang ... with tab indentation dominating golang presumably due to the gofmt command mandating:
      Gofmt formats Go programs. It uses tabs for indentation and blanks for alignment.

      > In both courses in the 1990's ... Is this a case of academia being out of touch

      The problems of the tab character "\t" were not as apparent in the 1990s like they were later.

      Different contexts have different indentation settings, while most people agree on 4 columns nowadays, do most apps default to 8 columns, which used to be standard.

      The chaos starts if people mix tab with space and everything looks perfectly indented in their own editor, but once it's opened with another editor ... or posted to perlmonks, it becomes a mess (yes browsers default to 8).

      I actually use the tab-key for indentation, but my editor has a setting to insert space. And a command to "untabify" foreign code.

      One benefit of "\t" is that it can be easily reverted with one backspace instead of four. But again, this can be fixed with modern editors and I use automatic indentation anyway.

      And I wasn't talking about semantic effects.

      Perl code is thankfully resilient against "\t" vs " " confusion, and whitespace rarely matters.

      But ask the Pythonistas what they think was Guido's biggest design error...

      In short: Academics in the 2020 wouldn't say this anymore.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

        As described nicely in this blog, the pro-TABS camp (including golang) exhort you to use TABs for indentation only, never for alignment:

        It's very important to only use spaces for alignment. Never, ever, use tabs for alignment. Tabs may be used for indentation only.
        I suspect this important distinction was not widely known in the 1990s, at least I don't remember it being mentioned back then.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (9)
As of 2024-03-28 09:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found