logoalt Hacker News

graemeptoday at 10:49 AM1 replyview on HN

I think indentation is more intuitive. Even people using languages that use braces or similar usually use indentation to make code readable. If doing that you end up explaining both ideas (use braces and indent).


Replies

latexrtoday at 11:35 AM

I get why people like indentation for this. I don’t think there’s a right or wrong answer and it’s a matter of personal preference.

That said, my preference is curly braces (or whatever) because I’ve found indentation is often a bother. Yes, most of the time you use indentation together with braces, but not every time. There are many occasions where code is clearer without (or with custom) indentation. Furthermore, indentation-based parsing makes experimentation and finding issues more difficult. Sometimes you need to extract a small part of a larger block to bung in a REPL or something and now you’re fighting with stupid errors because of formatting, adding to the frustration.

Regarding intuitiveness, for beginners I have some doubts it makes much of a difference, and if it does I also doubt indentation wins. If you know how to write (which is a prerequisite), you know what parenthesis and quotation marks are, you understand they encapsulate something separate from the rest. Indentation is a different concept.

show 1 reply