|
|
|
|
|
by csense
4773 days ago
|
|
You should give Python another chance. Here's why: > meaningful indentation Indentation in other languages has meaning too. If you have Java code, for example, that looks like this: public static boolean isIncreasing(int a[])
{
boolean result = true;
for(int i=1;i<a.length;i++)
if (a[i-1] <= a[i])
continue;
else
System.out.println("a is not monotonically increasing");
result = false;
return result;
}
Can you spot the bug? The topic we're discussing is a huge hint as to what the bug is, but if the only clue you have is bad behavior in a longer program it can be much harder to spot. When skimming the code, the visual cue of the indentation is so strong that it's very easy for your brain to see what the programmer clearly intended to write rather than what's actually there. (The diagnosis of the above bug might be even hairier if the bug was introduced by inserting a "safe" print statement to help you debug an unrelated problem!)Forcing your code's visual cues and behavior to match defeats an entire class of bugs. And even if you start out hating it, ultimately it's like the required semicolons in C/C++/Java: It's an annoyance at first, but after a while it becomes so automatic that you no longer stop to think about it. |
|
Maybe I'm just different than you, but I immediately notice the missing braces. Actually, the visual cues I look for (even when skimming the code) are the braces, not the indentation; especially, the missing closing brace at the end of the block alerts me. The indentation is a plus, an added redundancy.
Moral of the story: not everyone reads code the same way.