Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Pythonic Whitespace

Name: Anonymous 2011-11-05 21:16

Why does /prog/ dislike Python's use of whitespace? I have never had any problems with Python concerning whitespace, but numerous with C/C++.

Problems with C-style whitespace/bracing:
1) Code can be misleading, because while one reads indentation, it's not significant to the grammar. For instance:

if(true)
    a();
    b(); // This isn't actually in the body of the if.

2) There are over 9000 different ways of aligning bracing. Somehow, the most popular involves wasting a whole line for the opening brace'{'. Interestingly, such code always seems to neglect blank lines everywhere, leading to abominations like:

int a, b;
char c;
if(true)
{
    // do something
}

Why is the line of the if grouped together with the declarations of the variables!? What is wrong with the more readable and structured?:

int a, b;
char c;

if(true) {
    // do something
}

One can't say it's because the blank is a waste, because they often use nearly blank lines with solely '{' all the time!

Of course, Python saves even another line by eliminating the need for a closing brace '{'.

tldr: Why is Python's use of whitespace bad?

Name: Anonymous 2011-11-07 0:16

>>6
Yes. The lack of enumerations and constants is annoying also.

>>7
I've never "forgotten to indent code". As I said before, I've had numerous problems with forgetting things in C/C++ (missing brace, missing semicolon (especially at the end of classes (Notice how one doesn't need it in Java.)), but never in Python. If you're so disorganized to refuse to indent you're code properly, you'll be punished worse in C/C++, by the ways I've already enumerated.

I've helped many people (not just freshmen) at university write code, and they all share something in common: They're code is completely disorganized. They follow no coherent naming scheme (Not only identifiers start with lowercase, classes with uppercase (Something I wish languages would also enforce.), but consistent use of terms like "number, amount, count, size, length, etc"), neglect logical use of whitespace all together (not just in blocking), like in: for(int i=0;i<1234;i++) ... While neglecting these things won't stop your code from compiling, they'll muddle your mind, and it's no wonder they have persistent problems. Yet, I feel that my preaching is lost on them. They're much more concerned with looking cool using shitty console editors than programming efficiently.

I deplore you to at least try Python before complaining about how its whitespace rules are restrictive, for I promise you that they are not.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List