Linked by Eugenia Loli on Sat 15th Jul 2006 22:45 UTC
.NET (dotGNU too) Jeff Cogswell writes: "I'm about to make a confession. Even though I've written several books and articles about C++, I have a secret: C++ isn't my favorite language. I have lots of languages that I use, each one for different purposes. But the language I consider my all-time favorite is Python."
Thread beginning with comment 143589
To view parent comment, click here.
To read all comments associated with this story, please click here.
RE[4]: Python is . . .
by Cloudy on Sun 16th Jul 2006 18:32 UTC in reply to "RE[3]: Python is . . ."
Cloudy
Member since:
2006-02-15

Um, the C loop unrolling example isn't "syntactically optimized". It has exactly the same number of syntactic elements if you place the increment statements and action statements on the same line as it does if you don't.

What it does have is a visual cue that the action and increment statements are tightly coupled. You can't accomplish this in Python.

For this reason, the indentation rules of Python are not merely enforcing good indentation practice, since they add restrictions that prevent some useful practices.

Python indentation is like Pascal's banishing of 'goto' because Wirth didn't understand the situations in which goto made code more readable rather than less.

Reply Parent Score: 1

RE[5]: Python is . . .
by Tuishimi on Sun 16th Jul 2006 18:48 in reply to "RE[4]: Python is . . ."
Tuishimi Member since:
2005-07-06

Ummmmm yes it is. Syntactically optimized means that it arranges the statements in a manner that is optimized in some form. In this case it combines the three elements of looping in one statement line.

You can do many similar things in Python, btw. Often I choose to NOT use those kind of options simply because using other options are clearer to programmers, especially those who might not be used to a language's syntax.

You need to think about stuff like that in a corporate environment when whatever you write could arbitrarily be handed off to ANYONE with any varying degree of experience.

Reply Parent Score: 1

RE[6]: Python is . . .
by Cloudy on Sun 16th Jul 2006 19:47 in reply to "RE[5]: Python is . . ."
Cloudy Member since:
2006-02-15

Ummmmm yes it is. Syntactically optimized means that it arranges the statements in a manner that is optimized in some form. In this case it combines the three elements of looping in one statement line.

you're talking about the for construct itself, not about the example I'm describing.

Reply Parent Score: 1

RE[6]: Python is . . .
by Tuishimi on Sun 16th Jul 2006 18:51 in reply to "RE[4]: Python is . . ."
Tuishimi Member since:
2005-07-06

"Python indentation is like Pascal's banishing of 'goto' because Wirth didn't understand the situations in which goto made code more readable rather than less."

You have GOT to be kidding me. Please tell me you are kidding me. Code indentation is extremely important to readability. Perhaps I am misunderstanding you. GOTO statements created confusion by providing a somewhat (in appearance anyway) unstructured method of jumping in and out of code segments. Completely different from what we are talking about with code indentation.

Reply Parent Score: 1

RE[7]: Python is . . .
by Cloudy on Sun 16th Jul 2006 19:56 in reply to "RE[6]: Python is . . ."
Cloudy Member since:
2006-02-15

Perhaps I am misunderstanding you.

You're misunderstanding me.

Wirth banished goto from Pascal because it allowed certain 'undesirable' programming constructs. Doing so was an attempt to enforce readability by language design.

Python tries to enforce readability by language design by forcing indentation, including statement termination. But it's easy to write unreadable code in Python just as it was easy to write spaghetti code in Pascal.

By banishing the goto, Wirth actually made some things harder to write clearly, about which see Knuth's paper on goto structuring. So, the net effect was that Pascal didn't prevent unreadable code but did in some instances enforce unreadable code.

By forcing indentation, Python robs the programmer of certain constructs which can be used to indicate code structure, and it causes a different sort of typographic blindness, because of the tab substitution rule.

In other words, Python is like Pascal in that it attempted to do something to make code more readable that didn't really make the code more readable, but did eliminate some changes for readability.

Where you're getting confused about what I'm saying is that C allows one to write code that's at least as readable as Python because it allows one to properly indent. It allows readable code, but it doesn't attempt to enforce it. Whereas Python attempts to enforce readable code, but in doing so merely leads to different ways to write unreadable code while restricting programmers unnecessarily when there's a good reason to violate the convention of indentation.

Reply Parent Score: 1

RE[7]: Python is . . .
by mexisme on Mon 17th Jul 2006 10:17 in reply to "RE[6]: Python is . . ."
mexisme Member since:
2006-07-17

Code indentation is great... except when it's not.

There are times when I explictly choose not to use indentation, and I get annoyed when a language chooses to tell me, for example "Use underscores instead of camel-case" or "Use spaces instead of tabs for indentation" where the reason is based on opinion.

It's the age-old "thou shalt do it this way" argument with Python, despite the programmer's wishes or better judgement.

And I have to say this: "GOTO" is sometimes just plain better, for all sorts of context-sensitive reasons. The comparison is because Wirth banished GOTO for a readability **opinion**.

Reply Parent Score: 1

RE[5]: Python is . . .
by Espectro on Mon 17th Jul 2006 14:11 in reply to "RE[4]: Python is . . ."
Espectro Member since:
2006-02-01

Like my C teacher said - "You can use GOTO, it's in the language, right? Why not use it? After you write a million lines of code you can use 1 GOTO. Until then, don't think about using it."

Reply Parent Score: 1

RE[6]: Python is . . .
by Cloudy on Mon 17th Jul 2006 17:08 in reply to "RE[5]: Python is . . ."
Cloudy Member since:
2006-02-15

Your C teacher should have read Knuth.

Good C programmers commonly use forward goto because it improves readability and simplifies code.

Reply Parent Score: 1