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

> All those brackets are extra things your brain needs to process when reading the code, strip them away and it becomes just like reading written language

No, it doesn't, because written language explicitly marks ends, and sometimes also begginings, of structural units (programming gets brackets from natural language), it doesn't just use white space (until you get to units bigger than sentences.)



> No, it doesn't, because written language explicitly marks ends, and sometimes also begginings, of structural units (programming gets brackets from natural language), it doesn't just use white space (until you get to units bigger than sentences.)

Written language does of course use white space to separate words (this was not always the case, see for example classical Latin).

And I think it's fair to say that a line of Python is roughly equivalent to a sentence, and whitespace indentation is only used for syntax at that level.

The analogy breaks down a bit at higher levels, as Python blocks can recurse, but in writing we have structures like chapters, books, etc.


As pointed out, in written language, structural units (like chapters, paragraphs, bullet-point lists...) are usually finished with... distinctive whitespace (indentation or vertical space).

Beginnings are usually more prominent (more whitespace, bigger fonts and different alignment, or introductory sentences with colons for lists), just like in Python.

I am only saying that there's no need to make up arguments against significant-indentation. You can like how it looks or not: that's pretty subjective, though.

The only two objective arguments for either side I can see are:

* Terminating "end" or "}" are superfluous if you are already indenting code.

* Re-indenting a block with no termination indicator can lead to subtle bugs (at least more of them compared to when an indicator for block end is present).


Written language usually don't have paragraphs inside paragraphs.

In programming things are frequently nested several levels deep.

This is the key difference that makes a termination character/word important I think.


They do have it. Quotes (esp multi-paragraph ones) are usually indented another level in. So are nested lists (imagine if lists on different levels of nesting only used different bullet characters). So are mathematical formulae. Or table of contents. Or bibliographic references. Tables in general are a special case of horizontal spacing that matters. Figures and images in text.

It's not as common because writing is not all hierarchical all the time (or at least, lots of space would be wasted if entire chapters/sections were indented one level extra), whereas programming is heavily hierarchical with shorter "blocks".

Horizontal indentation is the most common way to express that hierarchy, including in programming languages that use block termination indicators — indentation is used to help humans parse the code, termination indicators are there to help computers parse it.

You are making it sound as if you are not making use of indentation when programming: I thought the only complaint was about it being significant.




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

Search: