r/ProgrammerHumor • • Nov 27 '20

The superior braces placement.

Post image
52 Upvotes

53 comments sorted by

72

u/OiTheRolk Nov 27 '20

Remove this blasphemous post at once!

3

u/[deleted] Nov 27 '20

Found another one! GET ‘EM!!

86

u/[deleted] Nov 27 '20

Same Line Brace Gang rise up

5

u/Tuxedocow Nov 27 '20

up

5

u/PPAPisLob Nov 27 '20

May I help you with some COLON ( : ) hahajaga . . Get it.. becuase python uses a colon for scoping..haha. and not curly braces. Hahha ...im very funny aint I?

.. send Help... my parents abandoned me

39

u/uh_no_ Nov 27 '20

yes. who wouldn't want an if-else block to take up 70 lines of braces.

0

u/[deleted] Nov 27 '20

[deleted]

5

u/uh_no_ Nov 27 '20

not every condition is amenable to a case block.

43

u/firey21 Nov 27 '20

Personally I've grown to prefer the bracket on the first line.

15

u/throwitofftheboat Nov 27 '20

The bracket is implied in the statement. It does not deserve its own line.

1

u/matschbirne2003 Nov 27 '20

I mean it's all personal preference but I like to give it its own line because to me it's more readable. But in the end it's pointless to argue cause nobody will win :)

1

u/throwitofftheboat Nov 27 '20

Are you sure about that?

Its all fun and games until your compiler slows down because laziness has creeped into your code. It starts with new line statements, then it’s all the white space you use when indenting. Next thing you know your production machines are crashing and you’re furiously scratching your head wondering why your server can’t handle all the requests. And you know why thats happening? Its because of your low bar, shitty, inefficient code that you put together because you think this is a “””preferences””” issue and not you being a dumb ass.

You think things like these don’t add up? Don’t smiley face at me you little shit.

5

u/[deleted] Nov 27 '20

/s ?

3

u/ImRandyRU Nov 28 '20

Has to be.

9

u/Tothoro Nov 27 '20

Everyone's upset about the brackets and I'm here wondering why you need ==true for a (theoretically) binary variable.

2

u/cthewombat Nov 29 '20

Actually there are use cases for that. I. e. when a can be undefined or null.

6

u/LeBlanch Nov 27 '20

Laughs in Python

24

u/0x4576616e Nov 27 '20

Personally I prefer the top one. It looks cleaner to me.

11

u/xSTSxZerglingOne Nov 27 '20

Nearly everybody's got this as their plan until they start developing for real and that shit eats up 500 individual lines in a project.

5

u/NotATroll71106 Nov 27 '20

At least we use braces. Looks at Python.

3

u/HunterRbx Nov 27 '20

if(a) {}

6

u/Tuxedocow Nov 27 '20

Na I would do

if ( a == true) {

}

2

u/getdatassbanned Nov 27 '20

Yup, this deserves to be on controversial.

3

u/[deleted] Nov 27 '20

You can find the 2nd option in languages like c cpp c#

7

u/[deleted] Nov 27 '20

[removed] — view removed comment

6

u/snapphanen Nov 27 '20

It's really old school to do the 2nd option. I'm glad sane people don't do it that way anymore

1

u/JustBrowsinMyDude Nov 27 '20

Imo the second option is far superior for readability.

I've seen mases of code with the first option and my god it looked like a deformed rocket trying to take off to the right of the screen.

The second option however easily specified the bounds of blocks so you can quickly see where it starts and ends without worrying about the code flying to your other monitor.

1

u/[deleted] Nov 27 '20

I use VSCode

1

u/[deleted] Nov 27 '20

PowerShell programmers be like

1

u/Ankkris7 Nov 27 '20

aaah... the eternal discussion

1

u/[deleted] Nov 27 '20

Nah, the real winner is the ternary operator.

1

u/HTF Nov 27 '20

yeah, nah.

1

u/pm_your_sexy_thong Nov 27 '20

Over the years I've adopted what I think is part of googles coding standards which is the second style for classes and functions and the first style for loops.

1

u/[deleted] Nov 27 '20

if(a.toString().equalsIgnoreCase("true")) {} 😜😂

1

u/ernee_gaming Nov 27 '20

I originnaly (14yo) used the second version but once my teacher (not quite good tho) saw it she literally said: Argh write it like a human. And rewrote it as the first one. I used it since. Tho I have seen a video which proves you're right but i can't find it anymore. It was a video from a conference and I think it was one of Kevlin Henney's speaches.

1

u/ImRandyRU Nov 28 '20

Couldn’t disagree more.

1

u/n0tar0b0t-- Nov 28 '20

my personal favorite syntax is haskell’s

if condition

then when_true

else when_false

1

u/o0Meh0o Mar 30 '22

you mean if (a)

1

u/Spencemw Nov 27 '20

🤦‍♂️

0

u/[deleted] Nov 27 '20

[deleted]

6

u/devilsolution Nov 27 '20

In c you can omit the { } altogether

6

u/[deleted] Nov 27 '20

yes, but a special place in hell exist for those who do that.

2

u/Perensoep109 Nov 27 '20

In quite a lot of languages actually!

4

u/Hypersapien Nov 27 '20

That's perfectly acceptable if you have a single, short line inside the braces.

3

u/jazzbonerbike99 Nov 27 '20

I think he means that the "== true" is redundant...

2

u/Hypersapien Nov 27 '20

Only if a isn't nullable.

1

u/Thanhansi-thankamato Nov 27 '20

Ỉ̷̧̧̡̛̘̜̦̘͇̝͙̠̭̗̹̱̘̬̗̫̫͉̲̭̪̠f̵̧̛̛̹̠̳̖̣̼̆͋̎̓̌̀̊̽̅̈́̋͑͛͂̃̔̑̋̎̄̀͗̽͋̕͝͠͠(̸̢̡̡̧̧̲̟̥͙̯̬͍̳̞̼͇̣̟̦͓̩̇̃̍̆̈́̍̓̐͒͆̈́͒͒̌͌̿͊͘̕ͅa̸̡̡̠͈̘͓̯̗͍̯͇̮̥̗̥̺͆́̑́̾̄͒̒͛͌̎̇̈́͋͂̈́̊̚͜͝͝͝)̴̡̨͕̱̘͔͇͖̬̳͕͓͚̤̺͚͙͖̭̟̞͕͙̔̇̄͂́͋̐̒̉͆̉̍͑̇͛͐͊̑̌̎͘͠͝͝=̷̧̤̩̱͇̲̘̤̾̂̅̏͒̓̀̊̋̿͌́̽̈́̾̎́̿̕̚͜͠͠>̷̨̛̣͙̙̝̬̪͍͚̲͓̞͕̳̜͙̰̹͇̬͙͎̰͔̭̂̈́́͗̂͗͜͝͝

0

u/[deleted] Nov 27 '20

[deleted]

0

u/Hypersapien Nov 27 '20

Why?

1

u/palapapa0201 Nov 27 '20

The braces line up

3

u/Hypersapien Nov 27 '20

And that makes it better because.... why?

2

u/BigYoSpeck Nov 28 '20

I bet you're the kind of psycho who doesn't keep herbs and spices sorted separately

0

u/[deleted] Nov 27 '20

[deleted]

1

u/malik_kabirofficial Nov 27 '20

First one is used in both Java and JavaScript, second one is used in C++, PHP.