in reply to Perl fan being tempted with Python

I get a kick out of all the people who gripe about Python's "context sensitive whitespace" rigid structure. Have they never edited a .conf file which depends on line-by-line organization? Have they never seen a Makefile? Shell script? How about Prolog? FORTRAN? COBOL?

FORTRAN and COBOL are line-oriented languages because data used to be stored on punchcards. One punchcard is one line of text. FORTRAN reserves the first 6 columns of each line (card) for continuation markers, comment markers, and line labels. Everything has to be indented to the 7th column, unless you're using a modern loose derivative of FORTRAN. COBOL took that even one step farther, demanding certain indentation levels for nested conditions, and on some statements, a redundant NUMBERING which indicated how much indentation the line had.

It's not better or worse, it's just different. After so many token-stream languages like C, C++, PostScript, Java, Perl, SGML, you might get to think that that's the only normal way to code. No, it's just the current "in" thing to do with the current "in" parser tools. There are many other languages and file formats where the most natural way to read is line by line.

--
[ e d @ h a l l e y . c c ]

Replies are listed 'Best First'.
Re^2: Perl fan being tempted with Python
by Fletch (Chancellor) on Jun 17, 2005 at 13:12 UTC

    I wrote a really witty rejoinder to this on a punchcard, but I can't seem to find a reader for it on any of my machines . . .

    The problem is not that it uses whitespace, it's that the amount of whitespace has semantic meaning. Yes a Makefile uses whitespace, but so long as there's one initial tab it doesn't make any difference what amount of additional whitespace precedes the command. And I can't think of any shell where the amount of whitespace makes a syntactic difference.

    No one's saying you can't use the amount of whitespace as a semantically significant portion of your programming language, but the fact that pretty much no one does any more might mean something.

    Update: OOOOH, you caught me AM. Thanks for showing the one corner case that proves that Perl is just as guilty. I'll have to go delete the part where I said Perl was completely wartless itself.

    --
    We're looking for people in ATL

      The problem is not that it uses whitespace, it's that the amount of whitespace has semantic meaning.
      It doesn't quite change the semantic meaning, but Perl thinks the programmer uses the amount of whitespace to have different semantic meaning:
      $ perl -wcle 'print("foo")' # 0 spaces -e syntax OK $ perl -wcle 'print ("foo")' # 1 space print (...) interpreted as function at -e line 1. -e syntax OK $ perl -wcle 'print ("foo")' # 2 spaces -e syntax OK
        All three examples had the same meaning, you just got a spurious warning for the second usage.