4 ms·
Python's whitespace indentation seems like a great idea until you realize that it makes things like copying & pasting code from web pages etc far more difficult
by cageface 16y ago
Python's whitespace indentation seems like a great idea until you realize that it makes things like copying & pasting code from web pages etc far more difficult and, worse, makes automatically reindenting a block of code in an editor impossible. If I come across a badly formatted block of code in Ruby or Java or C in emacs it takes me one keypress to sort it out. In Python I have to carefully, manually look at each line.
It's also fun to spend an hour looking for a bug caused by somebody inserting a tab instead of a space somewhere. We had a production crash that took us a long time to fix because somebody hotfixed a file with the wrong editor and did this.
I also don't understand how forcing people to indent code in the same way magically makes people write good code. The kind of programmer that can't or won't indent his code properly is introducing bugs far more serious than bad layout into your project.
Python's a nice language in many ways but I consider the syntax to be a bug.
- lars512 16y agoI consider the indentation approach excellent because it's so clear and readable. For exactly the same reason, I prefer YAML over XML, because the result is something more readable, something whose structure is understandable at a glance.
- Jeema3000 16y agoIt's also very annoying to have to un-indent an entire block of code during debugging just because you want to comment out the conditional statement around it...
- sbov 16y agoI'm willing to forgive the creators of Python if they didn't optimize their syntax for copying-and-pasting code. Hotfixing is a naturally perilous process regardless of language. I've spent hours tracking down untested hotfixes in Java. You're also probably less likely to come across a badly formatted block of python code because that would generally result in a bug. Much like misplaced brackets in Java/C/C++ would result in a bug. It doesn't make the code magically better. It makes it less redundant. Indentation should already be there, why do you need curly brackets?
- cageface 16y agoI'm willing to forgive the creators of Python if they didn't optimize their syntax for copying-and-pasting code. Copying and pasting is also known as refactoring. A syntax that makes that much harder than it needs to be is mis-optimized, IMO.
- Jach 16y agoBut code is read far more than refactored, so I think it's an okay tradeoff. (Plus what editors are ya'll using where changing the indentation of something is difficult?)
- prodigal_erik 16y ago> it makes things like copying & pasting code from web pages etc far more difficult This. I'm convinced half the reason Ruby is displacing Python is that it's actually practical to talk about Ruby code in forums without ridiculous little-known workarounds like pastebins.
- cageface 16y agoI do think that it's a pretty major issue, although I also don't get the impression that Ruby is displacing Python. If anything it seems like the momentum from Rails is petering out a bit. The Ruby community itself does strike me as more energetic though. All the activity on github etc seems a lot more impassioned to me than the coolheaded & practical world of Django et al.