Whitespace as syntax (was Re: Python Rocks!)

tye4 tye4 at yahoo.com
Thu Feb 10 00:20:19 EST 2000


Future language designers should learn from the blunders of Python
and other languages.

Listed below, from worst to best block delimiter schemes found in languages.

Pascal. Score: 2/10. Pascal is my most favorite lang... however, hate those
'begins' - they create double indentation as shown below. This bug was fixed
in future incarnations of Pascal, e.g. Ada

if foo then
  begin
     bar;
     stool;
  end;

-------------------------------------

C++/Java. Score: 5/10
if (foo)
{
    bar();
    stool();
}

--------------------------------

Python. Score: 7/10.
Good points of Python:
1) No semicolons at end of line
2) No 'begin' or '{' for start of a block
3) Forces programmers to indent (improves readability)

Bad points:
1) No visible indicator for end of a block
2) If indentation level is 2 or 3 spaces, ending of block even more harder
to discern
3) Have to pay careful attention to the properties of Editors (does it
convert tabs to spaces? etc.)
4) Forces programmers to indent (potential source of errors if tabs and
spaces are mixed)

if foo:
    bar()
    stool()
x = 10

---------------------------------------

Ada. Score 10/10
No redundant 'begin' or '{'. Visible indicator of end of a block

if foo then
    bar;
    stool;
end if

XML: Score: 11/10. Simple and intuitive block begin and end.

<item>
    <prog_lang name = Python>
</item>


tye4






More information about the Python-list mailing list