re: What’s an unpopular software opinion you have? VIEW POST

FULL DISCUSSION
 

A left curly bracket that marks the start of a code block should be placed on a new line.

 
 
 
 
 
 
 

C# or JavaScript? C# I agree. JavaScript no, why!!!

 

I'm the same - some languages are fine with it on new lines, some are strange.

Most importantly though is that you are consistent. Don't be like PHP PSR-1 and have classes and functions one way but if/for/while etc another.

 

Any language using curly brackets for code blocks. Simply because with a new line the left and right curly brackets align, oh the beauty of alignment!
But your opinion must be even more unpopular, that you prefer new line in one language and not the other.

It's the way I learned each language and I think most of the JS I work on has enforced linting.

I had a colleague who was putting the curly bracket on the same line, for compactness, but then was starting the code block with an empty line, for readability.

I used to like my brackets to match, but lint disagrees and so do most programmers. I have my principles, and if you don't like them, well ... I have others. Life is full of disappointments and sometimes it's easier just to go with the flow.

 

curly brackets are syntax trash, they are for the compiler...
humans use indentation

 

Languages that rely on indentation scare the bejeezus out of me! 😥

 

I live in conflict on this one. In PHP, when it's a class, I always add the brace on its own line, but for a function, I bundle it with the function name. On the other hand, when writing JavaScript, I never put the brace on its separate line. :deal_with_it:

 

Nope, I don't need to deal with your inconsistent syntax. 😋

code of conduct - report abuse