Remix.run Logo
bmandale a day ago

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.

Blikkentrekker a day ago | parent | next [-]

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.

bmandale a day ago | parent [-]

> tabs and spaces being mixed in the code

Python banned this in python3. Problem solved.

szmarczak a day ago | parent | prev | next [-]

> 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.

TheOtherHobbes a day ago | parent [-]

Javascript's delimeter soup ((){([]{})}); can become near impossible to parse barebrained, especially when mixed with indents and semicolons.

Semicolons are just noise. They're absolutely redundant.

Some brackets are necessary, but whitespace/indent languages make it clear there's a lot of redundancy there too.

The goal is to minimise errors and cognitive load. The fewer characters the better.

szmarczak a day ago | parent [-]

> whitespace/indent languages make it clear there's a lot of redundancy there too.

The only purpose for whitespace indentation is to make the code easier on the eyes. A space shouldn't have an impact in terms of execution, that would be too hazardous. It's too easy to randomly insert a space rather than a character.

xigoi 17 hours ago | parent [-]

> It's too easy to randomly insert a space rather than a character.

What are you doing with your code? I never find myself just randomly inserting characters.

szmarczak 14 hours ago | parent [-]

> I never find myself just randomly inserting characters.

Hasn't it ever occured to you trying to insert a space at your mouse but your cursor wasn't there? People sometimes forget to click (or think the cursor is already there), myself included. Characters are easier to spot because they are not invisible and random letters cause compile errors.

If it has never occurred to you, then good for you. However I do not see what the benefit of not using closing brackets would be.

xigoi 14 hours ago | parent [-]

I don’t use the mouse when editing code, so this particular mistake does not happen to me.

> I do not see what the benefit of not using closing brackets would be.

Less visual noise. And the ability to use braces for other syntax.

szmarczak a day ago | parent | prev [-]

> 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.