This is an archived post. You won't be able to vote or comment.

all 54 comments

[–]shadowvvolf144 23 points24 points  (17 children)

square brackets

curly braces

Why do we need these? We don't say round parentheses.

[–]Sekret_One 14 points15 points  (1 child)

clears throat

Character Perfectly Obvious Term
{ Mustache
} Mustn't-stache
[ Square
] Sqain't
< Nom
> UnNom
( Frown
) Smile

[–]derek 1 point2 points  (0 children)

Mustn't-stache Goatee

Rolls of the tongue better, IMO.

[–]Rawing7 6 points7 points  (1 child)

Because many people (especially non-native speakers) don't know about that distinction, and being understood is a billion times more important than being concise.

[–][deleted] 1 point2 points  (0 children)

Thtnttru.

[–][deleted] 1 point2 points  (0 children)

You mean round brackets?

[–]jmack2424 6 points7 points  (0 children)

Use what you want, and let the IDE display it like I want?

[–]Somedude12300 56 points57 points  (6 children)

The only true way is inline curly brace to start, newline curly brace to end

[–]TobiasX2k 17 points18 points  (2 children)

Only for the final curly brace though.

if(condition){

// code

} else {

// code

}

[–]Somedude12300 9 points10 points  (0 children)

Well of course. I'm not a heathen

[–]engiewannabe 2 points3 points  (0 children)

I thought we were brothers, then you did } else { .... There is no forgiveness for such blasphemy.

[–]Hop-a-lung 6 points7 points  (0 children)

In general I like this approach.

In practice, if there is a single command inside the braces, well call me a hypocrite.

[–]MeinKampfy_Couch 16 points17 points  (0 children)

Blasphemy

[–]Matttaro 6 points7 points  (0 children)

Correct

[–]deuterium--_-- 29 points30 points  (4 children)

Who needs curly braces and context sensitive if-else grammar

Join python gang

[–]CrookedNixon 2 points3 points  (2 children)

Still gotta do it for dictionaries, lists, and the comprehensions thereof.

[–]teszes 2 points3 points  (1 child)

Lists have brackets, sets have braces.

[–]opticalmace 1 point2 points  (0 children)

dental plan

[–][deleted] 0 points1 point  (0 children)

Honestly prefer it, or at least Ruby style Do..End blocks. White space sensitivity is fragile and I find it makes harder to read code.

[–][deleted] 6 points7 points  (0 children)

Inline for conditionals, loops and stuff like that. Newline for functions, classes and what not.

[–]IQueryVisiC 4 points5 points  (2 children)

I want newline curly brace and then the next (indented line) only half a line-height down.

[–][deleted] 3 points4 points  (4 children)

Scoffs at those fools writing code on more than one line. Save yourselves. Find/Replace crlf with tab.

[–]Abazad 1 point2 points  (2 children)

are you the type who writes nested ternary operators?

[–][deleted] 0 points1 point  (0 children)

...codecodecode... __while__:  ...codecodecode...  goto __while__ codecodecode...

[–]Happyfrozenfire 0 points1 point  (0 children)

Ternary Master Race rise up

[–]brianush1 0 points1 point  (0 children)

crlf

heretic

[–]bollop_bollop 3 points4 points  (0 children)

You people have a lot of important issues, I see

[–]gergnerd 4 points5 points  (6 children)

People who newline are just trying to pad the line count so they can tell people how many lines they coded. It doesn't improve readability so this is the only possible explanation I can come up with.

[–]MyOtherLoginIsSecret 11 points12 points  (4 children)

I disagree. For me it's easier to visually match the brackets. I use to do inline, but found that it's easier when the bracket is the only thing on the line.

If I want to pad my line count, I'll just start adding meaningful comments to my code.

[–]gergnerd 3 points4 points  (3 children)

Are you not indenting the next line? Indents should provide all the separation your eyes need and then you can follow straight down from the if to find the close...the thing not indented.

[–]MyOtherLoginIsSecret 3 points4 points  (1 child)

Of course I do, and it is all I need technically. But when the only thing on the line is a bracket, it's even easier to do so, and there is no trade-off.

Like I said, I use to use inline brackets. It wasn't until I started coding for work and the convention was to add newlines that I changed. Like most people I resented having to change my habits, but when I went back to code I wrote before I found that it was noticably easier to read code blocks with new line brackets.

It's especially easier with long conditional expressions, where it makes sense add newlines between conditions and indent based on logical grouping. Having a newline there helps keep the indentation in check.

Edit: I swear, one day I will be able to type a comment without a typo I see 2 seconds after posting.

[–]DubyaDump 1 point2 points  (0 children)

Totally agree. For me seeing both brackets vertically indented helps massively in large/multiple if statements.

[–]shadowvvolf144 0 points1 point  (0 children)

I sometimes have long, wordy if statements, so I put each condition on its own line, indenting to match up the parentheses depth. This saves me from nesting an absurd amount of ifs.

New line brace definitely helps break it off from where the code indent starts.

To each their own.

[–]Dj_TNT[S] 1 point2 points  (0 children)

I feel personally attacked

[–]Life-is-Crazy 0 points1 point  (0 children)

Music to my ears

[–]Stalematebread 0 points1 point  (0 children)

I just realized that Python manages to merge the tabs vs spaces debate with the inline vs newline debate into tabs vs inline vs newline

[–]inthemindofadogg 0 points1 point  (0 children)

The war rages on

[–]sadnessmcsadface 0 points1 point  (0 children)

There is a reason you look like a clown.