logoalt Hacker News

bmandaleyesterday at 10:13 PM3 repliesview on HN

Clearer for the computer, but not for the human. Many errors, some severe, have been caused by a human only looking at the indentation and not realizing the braces don't match.


Replies

Blikkentrekkeryesterday at 11:55 PM

That's just because most languages go by braces and have optional intendation that is just ignored by the compiler.

I'd reckon that in a language where stuff is done by indentation but optional braces exist that are just ignored so many errors would also have been caused by braces being misplaced by the programmer to queue other programmers who thought some scope happened as a consequence but the compiler disagreed due to the indentation, which by the way was caused by tabs and spaces being mixed in the code and it not properly showing up for another programmer with tab with set differently.

show 1 reply
szmarczakyesterday at 10:25 PM

> human only looking at the indentation and not realizing the braces don't match.

If it ever gets to that point, a refactor is obligatory.

Don't give the human tools to make easy mistakes. Any grammar can be abused, so blame the human for not writing clean code.

show 1 reply
szmarczaktoday at 12:45 AM

> and not realizing the braces don't match.

Make your IDE highlight the current section or display a hint showing starting bracket. For example, C++ devs do #endif // #if ...

Too many brackets? Refactor - problem solved.