Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You're right about auto-formatting being possible with significant whitespaces... but:

When you copy-paste a block of code in another block of code, with significant whitespace you have to correctly reindenting everything very carefully, while with explicit blocks you can let an automatic formatter do the work.

When you copy-paste a block of code in chat/email/comment, it is sometimes difficult to preserve significant whitespaces. For example, I've seen a lot of blog comments "eat" the white spaces at the beginning of each line (example: https://unspecified.wordpress.com/2011/10/18/why-pythons-whi...)

It can be difficult to fix code incorrectly mixing spaces and tabs (especially for beginners).

Rob Pike wrote on this topic:

> Some observers objected to Go's C-like block structure with braces, preferring the use of spaces for indentation, in the style of Python or Haskell. However, we have had extensive experience tracking down build and test failures caused by cross-language builds where a Python snippet embedded in another language, for instance through a SWIG invocation, is subtly and invisibly broken by a change in the indentation of the surrounding code. Our position is therefore that, although spaces for indentation is nice for small programs, it doesn't scale well, and the bigger and more heterogeneous the code base, the more trouble it can cause. It is better to forgo convenience for safety and dependability, so Go has brace-bounded blocks.

Source: https://talks.golang.org/2012/splash.article



Without examples it's hard to say. Python isn't static, and it's type system isn't as capable as MLs.

I'm entirely unconcerned about random formatting systems destroying whitespace. Some eat angle brackets. Maybe I'm not copy+pasting enough. I find "for beginners" to not be useful as a measure of anything - anything can be said to be confusing for beginners. But I can see how people might come to a different opinion.


Haskell doesn't nearly has as much of a problem with copy-and-pasting from websites as Python have. (But in Haskell the significant indentation is much more optional.)


> When you copy-paste a block of code in another block of code, with significant whitespace you have to correctly reindenting everything very carefully, while with explicit blocks you can let an automatic formatter do the work.

I've heard this argument a lot, but how often does it happen to copy paste extensive parts from web sites? Some short bits, yes, but longer parts with blocks? Almost never, since I always have to rewrite them to fit my variable names etc, so might as well make sure the formatting is right.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: