xigoi

Braces Criticism

There are, in general, three common ways to delimit code blocks: braces, end-keywords and indentation. When we write pseudocode on paper, we tend to almost always use indentation — it provides an easy visual cue and takes the least effort to write. So why do so many programmers insist on using braces for this purpose, which make code much harder to visually parse? Here are some commonly given reasons with my responses:

Pasting code from the internet messes up the indentation and it's tedious to fix it.
Are you coding in Windows Notepad?
A changed indent can cause the code to behave differently.
When this happens, you'll clearly see it. On the other hand, a misplaced brace might go unnoticed and the indentation will give you a false sense of the code being correct.
I have auto-indent, so the indentation will always match the braces.
That's cool. You'll still get slowed down by having to visually process them.
I don't think invisible characters should change the meaning of code.
Firstly, indentation is followed by visible characters, which makes you able to clearly see it. Secondly, by this argument, you could also argue that publicstaticvoidmain should be equivalent to public static void main — we're just ignoring “invisible” characters, no?
Mixing spaces and tabs is going to create a mess.
See the answer to the first question.

Semicolons Criticism

A very popular feature in programming languages, especially those derived from C, is requiring a semicolon after every statement. Why is this necessary if you're already separating statements by newlines? It just adds one more character you need to type; and more importantly, a lot more characters that you have to visually process, but that don't contribute in any way to the logic of the code (the term for this is syntactic noise). There's a lot of languages that do completely fine without them: Python, Ruby, Lua, Nim, Go, Haskell, etc. And JavaScript shows that even in a language that uses semicolons, they can be inferred pretty well. Also note that Lua doesn't actually care about newlines, its syntax is made in a way that a statement always ends unambiguously.