Opportunity missed by Python ?

C

Chris Angelico

What I don't get is, having seen Python's syntax with indentation
instead of open and closing puncuation and other -readability-
structures in Python's syntax, is if someone is going to invent any
new language, how could they NOT take Python's visual structures (read
as readability) and copy it, whether it be a compiled language,
explicidly typed checked or whatever underlying mechanism they want to
make that code executable.

What I would say is: How could they NOT be aware of Python's visual
structures. There are tradeoffs, and just because something works for
one language doesn't mean it's right for every other. I doubt the Dart
developers were unaware of Python's structural style, so the choice to
not use such was most likely conscious. (It may have been as simple as
"let's keep the syntax mostly JS-like, to make it easier for JS
developers to grok" though, rather than a major language-design
choice.)

ChrisA
 
D

Dominic Binks

I believe Occam had a visual structure and was compiled. In fact it was
even more picky than Python in this respect IIRC.
 
S

Steven D'Aprano

What I don't get is, having seen Python's syntax with indentation
instead of open and closing puncuation and other -readability-
structures in Python's syntax, is if someone is going to invent any new
language, how could they NOT take Python's visual structures (read as
readability) and copy it, whether it be a compiled language, explicidly
typed checked or whatever underlying mechanism they want to make that
code executable.

Because sometimes people have priorities other than readability. Or they
actually *like* braces. (I know, crazy!)

In fairness, the significant indentation is not all peaches and cream, it
has a dark side too. For example, the difference between visually
indistinguishable spaces and tabs can be meaningful (in Python 2, your
code may be broken if you mix spaces and tabs; in Python 3, the compiler
will give you an error). If you work in a noisy environment that eats
whitespace, such as crappy web forums, people using HTML email, editors
with unfriendly word-wrapping rules, and the like, you might miss having
braces. I occasionally see emails with code looking something like this:

print(something) while x < 100: print(something_else)
x -= 1 if x % 2 == 1: some_function() else: another_function()
third_function() print(x)


So the "off-side rule", as it is called, is not uncontroversial.
Languages developed by old-school language developers or academics, like
Google's Go language, tend to be very conservative and hence require
braces or even semicolons.

http://en.wikipedia.org/wiki/Off-side_rule


So many people keep asking for braces in Python that one of the
developers (Guido?) gave in and added it to the language. Just run

from __future__ import braces

at the top of your file, or at the interactive interpreter, and you're
done.

My own opinion is that the time I save with significant indentation is a
hundred times greater than the time I lose due to mangled code without
braces. So I consider Python's design a big win, but other people may
make other value judgments.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,156
Messages
2,570,878
Members
47,413
Latest member
KeiraLight

Latest Threads

Top