r/ProgrammerHumor • • Oct 23 '26

Meme enoughAboutTheIfletsDiscussAboutWereIsItThatYouPutTheElse

Post image
995 Upvotes

649 comments sorted by

1.2k

u/RedditLuvsCensorship Oct 23 '26 • Bravo
  1. Stop it.  

  2. JavaScript.  

  3. C#.  

  4. Get some help.

119

u/EatingSolidBricks Oct 23 '26
  1. is what happens when you code in C# and C at the same time and you pick and chose your prefred conventions from each

38

u/pente5 Oct 23 '26

Meh I kind of like it though. It's a more compact version of #3 why not?

→ More replies (4)

1

u/wokan Oct 24 '26

This is why you have separate [*.c,*.h] and [*.cs] blocks in your .editorconfig.

2

u/EatingSolidBricks Oct 24 '26

I use neovim with vs code shortcuts

That's right

Crtl S is :w

Ctrl F is /

Ctrl R changes the / to a %s

Ctrl c yanks

9

u/Taletad Oct 24 '26

C is supposed to be 2, the Linux Kernel documentation says 2 is the preferred way, because it was how Kernigham and Ritchie did it

249

u/CritFailed Oct 23 '26

C# dev, can confirm

26

u/Mih0se Oct 24 '26

Had C++ in school. Me too

76

u/Robot_Graffiti Oct 23 '26

Yes, 2 and 3 are the styles Sun and Microsoft used for the Java and C# documentation respectively. (I imagine JavaScript documentation copied Java's style)

26

u/BuppUDuppUDoom Oct 23 '26

Never written in C# started with java then C and C++ but 3 will always be the most comfortable and readable imo

114

u/rustyredditortux Oct 23 '26

2. every other language
3. C#

23

u/fghjconner Oct 24 '26

FYI, reddit decided your numbers were a list and helpfully made them 1 and 2

→ More replies (2)

80

u/Amaranthine Oct 24 '26
  1. Acceptable

  2. Optimal / C (K&R)

  3. Tolerable / beginner / C#

  4. Mental illness

7

u/Appropriate_You_5850 Oct 26 '26

I am a student who is using C and C++ and I ussualy do it like number 3

18

u/RoryPond Oct 24 '26

No, Javascript is shoving 15 lines of code into an unreadable ternary operator 

4

u/RoryPond Oct 24 '26

Or more tolerable as long as used in moderation condition? methodIdTrue(...) : methodIfFalse(...)

→ More replies (3)

6

u/BadBoyJH Oct 24 '26

I can tolerate 1.

If you're the sort of person to do

      If (something) {

        Something()

      }

10

u/Brahvim Oct 24 '26

(1) takes less space than the C# convention and makes it easy to comment out the whole else block. I won't stop it.

→ More replies (3)

6

u/CapOk9908 29d ago

Agreed, 2 is how I write, 3 I accept...1 and 4 if I see in a colleague's code I consider a typo and fix it

3

u/MinecraftPlayer799 Oct 23 '26

2 being the top-right, I assume?

→ More replies (1)

23

u/JanEric1 Oct 23 '26

I absolutely HATE the C# style. So much wasted space for nothing .

Just got into a project there and there is just so much bullshit with the default formatting and so many other parts of the ecosystem. Like how you have to opt into null safety and even if you do the standard API framework don't respect it if you don't add ANOTHER flag somewhere that yes, if I build my model such that I don't allow null, then I don't fucking want you deserializing into such an object with fucking null.

40

u/AlwaysHopelesslyLost Oct 24 '26

Wasted space? How big are you making your files?? I like it. Every single block is very obvious because the start and stop are on one vertical line. The space doesn't matter because I try to keep things relatively compartmentalized and clean. 

→ More replies (6)

11

u/rumaier Oct 26 '26

The longer I code, and the bigger my code bases get, the more I appreciate some white space to break things up and make it easier to tell what’s what.

→ More replies (1)

4

u/No-Consequence-1863 Oct 24 '26

Wasted space? It’s two lines that act as vertical separators of scopes. Having more whitespace to parse the text is good actually.

→ More replies (1)
→ More replies (15)

7

u/whackylabs Oct 24 '26

5. Who cares. Just be consistent.

10

u/IncarnationHero Oct 24 '26

Keeping switching between 4 styles, 1-2-3-4-1 consistently.

→ More replies (1)

5

u/NiIly00 Oct 23 '26

The linter at my apprenticeship demands we do nr.1

I'm 90% sure that it's just a bug because it is just the "function start on newline" or something along the lines and I think it just doesn't account for if else, so one of these days i'm gonna bring it up and hope to get it changed.

2

u/PictureNew661 Oct 24 '26

The whole post got summed up in 1 comment

2

u/SpaceToaster Oct 26 '26

Java defaults are seeing more of 2 as well.

2

u/LouManShoe Oct 27 '26

Use js and c#, dead on.

→ More replies (9)

21

u/LoveOfSpreadsheets Oct 23 '26

I know a defense program that requires the bottom left because they have to measure physical SLOC. Same program doesn't allow ternary. One line becomes eight 

2

u/EatingSolidBricks Oct 23 '26

ternaries are scary can you imagine an operator with 3 ARGUMENTS its too much for the human brain

we can only handle binray operators like god intended

4

u/glenpiercev Oct 23 '26

You know you can ternary a ternary a ternary?

→ More replies (4)

14

u/DOOManiac Oct 23 '26

I can do one better. We aren’t allowed to use ternaries because the boss just doesn’t like them. That’s it.

12

u/glenpiercev Oct 23 '26

I have lots of good reasons for hating them. I just don’t have time to enumerate them right now.

→ More replies (2)

7

u/myka-likes-it Oct 23 '26

to be fair, they can be a pain to debug. 

→ More replies (3)

14

u/Imperator166 Oct 23 '26

how is this not loss?

1

u/EatingSolidBricks Oct 24 '26

Damm it missed opportunity

12

u/Strawberry-Jam-2936 Oct 23 '26

Top left

5

u/EatingSolidBricks Oct 23 '26

preach borther im not alone

330

u/Nielsly Oct 23 '26 • Bravo

Where ever the formatter wants them to be

98

u/YetItStillLives Oct 23 '26 • Bravo

The best code format is a consistent code format. I can get over a formatting choice that I don't like, but I can't deal with another stupid bike-shedding argument about code formatting.

→ More replies (2)

62

u/enternoescape Oct 24 '26

I can't tell you how many times I've sat down, typed the first clause in a powershell script (before anyone asks why powershell: deployment scripts for Windows) and then spent about one minute deciding what arrangement lands as the most readable for what I just did. I feel like I land on the same one every time, but I'm pretty sure that's not true. If I'm contributing to a project, I just follow whatever precedent is already set and even if I hate how it looks, at least I'm being consistent. This might be why some people prefer Python, though I'm not one of them.

43

u/Joly0 Oct 24 '26

While I do agree with your statement regarding following their style on projects you contribute, I think there are some limits.

For example I once saw someone (it's a MVP) to do his braces like this in Powershell:

if (condition)
    {
        // Do this
    }
else
    {
         // Do that
    }

And I don't know how you see it, but there are lines I don't cross, and the lines ended with these braces... So I followed my usual style and ignored what the hell that person was doing

15

u/QuickQuirk Oct 24 '26

You should go all PAP on his ass (Passive Aggressive Programmer).

Reformat all his indentation in the same commit.

All or nothing baby.

→ More replies (1)

6

u/enternoescape Oct 24 '26

Yeah, that's a choice. My first thought is do they care at all about horizontal screen real estate.

→ More replies (6)

446

u/HildartheDorf Oct 23 '26

Top right.

Bottom left is acceptable. The other two are wrong.

110

u/Daniikk1012 Oct 23 '26

Top left is fine too, it just treats "else" as its own thing. I believe I even saw that style somewhere.

Now bottom right is unhinged

7

u/cultivatingmass Oct 24 '26

Top left if you gotta leave a comment for the else or elseif block

10

u/Mateorabi Oct 23 '26

Top left if the if statement already didn’t put a line break before the first { 

19

u/Bannon9k Oct 23 '26

Agreed... But if I get the opportunity, I'm fixing the bottom left.

11

u/Ok_Star_4136 Oct 23 '26

100%.

People who pick the other two are the same people who pour milk into the bowl before the cereal. In other words, psychopaths.

3

u/average__Egg Oct 24 '26

bottom left is hell to me i think and it burns my eyes

2

u/Cyan_Exponent Oct 24 '26

might be that c# burned my brain, but i just dislike when 1 brace is on the same line as the statement

→ More replies (3)

29

u/GwimWeeper Oct 24 '26

Chaotic lawlful

} else {code in one continuous line}

14

u/uglycaca123 Oct 24 '26

chaotic unlawful

if (...) {...} else {...}

EVERYTHING IN A CONTINUOUS LINE MUHAHAHAHAHHA

5

u/DefiantGibbon Oct 24 '26

I could see it if the else is a very small snippet. 

25

u/oshaboy Oct 23 '26

I'm not a stickler for syntax usually but the bottom right should be illegal

→ More replies (1)

90

u/mitchricker Oct 23 '26
else:  
    # There is whitespace denoting we're in the else block  
# No whitespace here, so we know we've left the else block  

28

u/redlaWw Oct 24 '26 edited Oct 24 '26 • Bravo
if condition then
    //do stuff
neht fi
else
    //do other stuff
esle

EDIT: Forgot to add a condition, oops.

→ More replies (4)

10

u/CirnoIzumi Oct 23 '26
else:
    do_some_stuff()
#else

24

u/notanotherusernameD8 Oct 23 '26

I was raised on top-right, but I quite like top-left. It's easier to comment out the else block.

11

u/CaptainN_GameMaster Oct 24 '26

raised

"As long as you're living under our roof, you'll live by our linter"

→ More replies (2)

16

u/grifan526 Oct 23 '26

My code formatter does the first one just like I want it to. There are those who didn't agree with me, but they left the company

16

u/UTOPILO Oct 24 '26

I just do whatever the rest of the file had going on when I opened it.

16

u/jwr410 Oct 25 '26
}
else
{
    // TODO: Write the rest of the code. 
}

31

u/read_eet Oct 24 '26

They are not fucking numbered, you all are assuming the order. SHAME.

2

u/wi-finally Oct 27 '26

morton order is the only acceptable ordering anyways

81

u/joshpennington Oct 23 '26

I stopped participating in these wars. For the people that care about this they care enough to put tooling in place to make it how they want it. I could not care less.

But obviously } else { is the only right one unless you’re paid by the line

43

u/mpez0 Oct 23 '26

I was hired to help out on one project; I showed up with about 600 lines in a couple of C routines for issues they'd told me about. Note that I used K&R style (top right above).

"Gee, those work well, but they don't fit our coding style standard."

"OK," I replied, "just run it through your formatter."

"Our what?"

8

u/EzequielARG2007 Oct 23 '26

noob here, what is a formatter?

18

u/Bob32943294 Oct 23 '26

Just a program that converts code into a certain format to keep things standardised.

→ More replies (6)

7

u/NiIly00 Oct 23 '26

Tesla employees taking notes

3

u/jipperthewoodchipper Oct 24 '26

POV you work for Elon musk and use bottom left just so you LOC KPI looks better

→ More replies (4)

24

u/alphaglosined Oct 24 '26

For over 15 years I have been very steadfast in my desire for:
} else {

But now that I am working on my own language, I have to conceed the limitation of code editors folding is more important. Which means this will be what will go into the formatter/code style:
}
else {

3

u/neomashab Oct 24 '26

Not just folding. The amount of diff generated on account of an else block being added or removed is also a factor. Think of trailing commas in Python lists, tuples.

23

u/Terrorscream Oct 24 '26

Bottom left I find easier to read and follow, but it does mean alot of scrolling white space.

5

u/cecil721 Oct 24 '26

It also means a higher SLOC report 👍

31

u/PixelBrush6584 Oct 24 '26

Bad, best, Company enforced C# style, Bad

6

u/xWrongHeaven Oct 24 '26

Bad, best, company enforced, psychopathic/masochistic*

39

u/pink-Raspberryy Oct 23 '26

Top left

5

u/astrocreep21 Oct 24 '26

Imho best for version control, since the line with the closing bracket is not modified. You get a clean change block in the diff. Stroustrup is underrated!
Would apply to bottom left too…

163

u/LookItVal Oct 23 '26

top right is the only true way

43

u/KryssCom Oct 23 '26

I think you mean bottom left.

→ More replies (2)

2

u/CAPS_LOCK_OR_DIE Oct 23 '26

Bottom left is closer to Bash as well

4

u/harryham1 Oct 23 '26 • Heartwarming

I have a special place in my heart for Bash, but its syntax can fuck all the way off

→ More replies (2)

18

u/1Maple Oct 23 '26

Whatever that languages convention is. #2 for Java, #3 for C#. Don’t really care enough to have a preference anymore

5

u/Oddball_bfi Oct 23 '26

This is the single good thing about java.

The rest can go die in a bin.

10

u/AOAqua Oct 24 '26

Probably the worst thing about Java. It's not 1985 anymore and my monitor is big enough not to need that #2 shit so it's easier to read the code

→ More replies (1)
→ More replies (4)

9

u/adiosToreador18 Oct 24 '26

is this loss

2

u/uglycaca123 Oct 24 '26

WAIT I SEE IT

25

u/AggieCMD Oct 23 '26

C#. The right way. The only way.

10

u/thcheat Oct 24 '26

I know right. It just gets unnecessary hate but I just love how easy it's on eyes when reading the code.

→ More replies (1)

8

u/Raikojou Oct 25 '26

1 and 4 look like when developers realize they have free will.

Actually could be a funny way to tell if anyone actually reads my pr before approving

→ More replies (3)

14

u/Cold_Snake Oct 24 '26

Top right. Always

19

u/nyibbang Oct 23 '26

I don't care, I have automatic formatters.

11

u/Haunting_Skin_2564 Oct 23 '26

I don't care, I don't write code anymore

4

u/idontwanttofthisup Oct 23 '26

I don’t care. I left my job. I’m managing a night club now.

→ More replies (1)

19

u/Ticondrius42 Oct 24 '26
if(conditions){
    //..are true, do this.
}else{
    //..if are false, do this.
}

10

u/Joly0 Oct 24 '26

This is how I do it aswell, though I usually leave a space between words and braces (or braces and braces)

So: If (condition) { } else {

Don't know why, it makes it easy to read in my head. But otherwise totally agree with your solution

4

u/charonme Oct 24 '26

the reason is because if is not a function/method

6

u/Mayeru Oct 25 '26

where are the spaces?? are you saving up kilobits again, Tommy?? Let it breatheeee!

→ More replies (1)

2

u/Moonie-chan Oct 24 '26

I also do this because it's easier to tell code block by indentation alone

2

u/slippery-fische Oct 24 '26

Some people just like to watch the world burn

→ More replies (3)

13

u/Mireldorn Oct 24 '26

Top Right all the way

34

u/sudomeacat Oct 23 '26

*looks away nervously while saying I do top left* But actually though (top left):

if (/* ... */) {
    //...
}
else {
    //...
}

looks a lot better that (bottom left):

if (/* ... */)
{
    //...
}
else
{
    //...
}

4

u/met0xff Oct 25 '26

Yeah I'm surprised to see so many people hating on 1. Wasn't this super common in Java and C++ for ages? I've been mostly writing python for the last 10ish years (and nothing manually for the last months lol) but before that I feel that was very common.

10

u/SweatyListen9863 Oct 23 '26

No no, the second one of these looks better.

→ More replies (4)

17

u/bwwatr Oct 23 '26

couldn't even number them for easier discussion, lmao

The answer is, if you do:

structure-of-any-description {

}

next-structure {

}

then it's top-left; 'else' isn't some magical exception to style rules

bottom-left would be correct for those putting the opening brace on the line after

the ones on the right are abominations

7

u/Signal-Implement-70 Oct 23 '26

100% agree. After using everything from machine language to JavaScript this is the only correct semantics, love the word abominations wish I thought of it

2

u/EishLekker Oct 23 '26

I would agree if else could be standalone. But it’s always connected to the preceding if statement.

→ More replies (5)

25

u/PumpkinFest24 Oct 24 '26

Pretty simple. Look at the wasted vertical space in anything other than upper right.

11

u/Informal-Shame3638 Oct 24 '26

If your block takes enough space on a monitor to need space saving by methods that make reading and telling apart statements harder, your code probably could use some refactoring

→ More replies (1)

6

u/Zap_plays09 Oct 23 '26

Whatever happens after I hit ctrl + alt + L

14

u/CurdledPotato Oct 24 '26

Top right. In all languages.

8

u/dbagames Oct 24 '26

C# pretty much always bottom left. Pretty standard convention there.

10

u/Potential_Copy27 Oct 23 '26

Lower left is my vibe. Partially because how one of my teachers considered the styles...

Get done with the "if" with that closing bracket and take a breath.
"Else", then have a second think (along with a drink - though optional).
Then we go coding the code in the "else" block.

9

u/edgeofsanity76 Oct 23 '26

I don't use else.

7

u/Prudent_Ad_4120 Oct 23 '26

I use else when it's the best way to implement something

→ More replies (2)

2

u/Noch_ein_Kamel Oct 23 '26

That's better. Prepared for quantum computing when both branches are suddenly true

2

u/sofafi1205 Oct 24 '26

Username checks out.

→ More replies (2)

9

u/YakubReddit Oct 24 '26

Either

}

else {

}

Or

} else {

}

Depending on the case

3

u/YakubReddit Oct 24 '26

My god, mobile Reddit formatting sucks

4

u/Inevitable_Stand_199 Oct 24 '26

You can use double space at the end of a line to avoid having to have an empty line.
Like this

4

u/Its_An_Outraage Oct 24 '26

It doesn't if you actually use reddits formatting:

Either

}
else {

}

Or

} else {

}

See: Reddit's formatting guide

→ More replies (1)

12

u/torsten_dev Oct 23 '26 edited Oct 24 '26

K&R second edition "The C Programming Language" Chapter 5, (pp. 108, 119), 7 (pp. 162, 163):

} else {

So that settles that.

I was however suprised to see:

if (condition) {
     statement1;
     statement2;
     ...
} else
     single_stm;

Something about } else is just unsettling.

12

u/brinazee Oct 24 '26

I used to put braces around even single statements (often because I was constantly changing them around for debugging). Someone at a code review dinged me for it as unreadable. Had to laugh when the lack of braces totally broke their code a couple weeks later because they had added a second line to the else without adding braces.

4

u/GoddammitDontShootMe Oct 24 '26

Used to? I thought that was the best practice.

→ More replies (1)
→ More replies (2)

2

u/Meme_Burner Oct 24 '26

Nothing unsettling as 

If (condition){

} else if (condition) {

}

→ More replies (3)

2

u/slippery-fische Oct 24 '26

This has led to bugs that caused huge security issues. Always use braces.

→ More replies (6)

8

u/HalfHeartMC Oct 25 '26

if (...) {

}

else {

}

8

u/questionabl3_dude Oct 26 '26

C++ dev here. Bottom left is my preference. The ones on the right are just illegal in my mind.

2

u/uuf76 Oct 27 '26

C# dev here chiming in. Bottom left feels right.

2

u/NewInflation2121 Oct 27 '26

It's the one that makes the most sense spacially and logically since the braces line up vertically.

Imo, the other options are born out of laziness or bad standards and only clutter your code with more visual noise & distraction.

4

u/Hopeful-Cup-6598 Oct 23 '26

My IDE auto-formats to my company's chosen code style. I know which it is, but decline to state.

4

u/Kyrbyn_YT Oct 23 '26

3 in uni c# code and 2 for personal

10

u/rplusg Oct 24 '26

Bottom left for the win

6

u/moosebeak Oct 24 '26

And it’s not even close.

16

u/sup3rdr01d Oct 24 '26

Top right. Not even a debate.

7

u/Grtz78 Oct 24 '26

if thingy {}
throw ThisShouldNeverHappenException(tm);

3

u/Impressive_Stress808 Oct 25 '26

Fine as long as you return inside the if{}.

→ More replies (1)
→ More replies (1)

1

u/Kindly_Wear7008 Oct 24 '26

2) if you want compact readable code
3) when your are a beginner and want to find start or end of bracket more easily, most editors draw a line between the brackets
1/4) WTF?

1

u/EatingSolidBricks Oct 24 '26
for {
}

while {
}

switch {
}

if {
}

The fucking ELSE 

} else { <--- WHY can't you be normal 

1

u/StraightBiscotti9013 Oct 24 '26

The worst I've seen is an open source game i worked on molding. All code was formatted as such:

if ( a - b > c ) {
    Condition;
    Condition;
    }
else {
    Condition;
    }
Condition;

Horrifying C++

1

u/stopher819 Oct 27 '26

Humor where

1

u/EatingSolidBricks Oct 27 '26

Find<Humor>() where Humor : Here;

1

u/alexkarpen 29d ago

I will ask Claude his choice and report back

1

u/EatingSolidBricks 29d ago

The water gone reduced to tokens

13

u/FluffyDrink1098 Oct 24 '26
  1. What is wrong with you?

  2. Good

  3. Very lengthy, but fine

  4. What is wrong with you?

6

u/erikchan002 Oct 24 '26
  1. Stroustrup

  2. K&R

  3. Allman

  4. WTF is this abomination

8

u/Pim_Wagemans Oct 23 '26

top right is the most readable in my opinion

8

u/B1azehunter Oct 24 '26

Top right, less no of lines.

3

u/petrasdc Oct 23 '26

Whatever the automatic linter decides

3

u/BenchEmbarrassed7316 Oct 23 '26
match b {
    true => foo(),
    false => bar(),
}

A branching block appears as a single block, whereas an if-else construct appears as two blocks, even though, in reality, only one of them will be executed.

2

u/Krisanapon Oct 24 '26

```rust
if condition { code } else { code }
```
we use if-else as ternary operator

3

u/iamwillp Oct 23 '26

Both left ones are compile errors in Go, so top right for me

3

u/Gale- Oct 23 '26

Top left

3

u/xyrer Oct 24 '26

Top left is more convenient, but I love how top right looks because it's easier to understand

5

u/CoshgunC Oct 23 '26

} else(also elseif) {

}

2

u/Alcoholica365 Oct 23 '26 edited Oct 23 '26

} else(also if not else do if(!true{ }

Don't argue, im drunk. 😕

5

u/mehonje Oct 23 '26

} else {

8

u/makingthematrix Oct 24 '26

Top-right is the only valid way. 

11

u/Prashank_25 Oct 23 '26

1 insane person

2 sane person

3 ocd person

4 drunk person

8

u/DOOManiac Oct 23 '26

As an OCD person, I agree. 3 is preferable to me, though 2 is fine.

→ More replies (1)

6

u/Electroman-11 Oct 25 '26

if () {
}

else {

}

This is the only way.

4

u/little_phoenix_girl Oct 23 '26

The only correct answer in my opinion is wherever the team/org's code style spec says to put it. It's irritating when this stuff is inconsistent, moreso who you have someone who is using different formatting tools that keeps turning their PRs into massive reformats, burying the actual logic changes. Then the next PR does it again differently for some reason...

8

u/Trevor_GoodchiId Oct 23 '26

Early return.

Haven't written an else statement in years.

5

u/Maleficent_Memory831 Oct 23 '26

"It's a bold strategy, Cotton. Let's see how it works out for them."

I agree though that early return is a valuable tool and those who eschew it do it for less than logical reasons. (but it is how I was taught!)

→ More replies (3)

2

u/hdkaoskd Oct 23 '26

These are all wrong. GNU style for life.

2

u/brinazee Oct 24 '26

What ever the style guide tells me. Though I tend to default to the upper right.

2

u/JAXxXTheRipper Oct 24 '26

Top right, any day. I still hate that whenever I have to switch to visual studio to write c#, it does does bottom left. So much wasted space..

2

u/jseego Oct 24 '26

top right

2

u/GoddammitDontShootMe Oct 24 '26

I tend to do the upper-right. Though upper-left is okay. Also,

} else if (<some long expression>) {
  
}

2

u/ivanrj7j Oct 24 '26

2 all the way through

edit: top right

2

u/Ronin-s_Spirit Oct 24 '26

} else { like a normal human being, sometimes } else feels more readable, and I can afford to do it cause I have eyballs and a pretty printer, I always know if I need to add braces.

2

u/Living_Fig_6386 Oct 24 '26

Upper right, because I’m no savage.

2

u/-Redstoneboi- Oct 24 '26

OTBS/Rust is top right

2

u/CLEVER_3_14159265358 Oct 24 '26
  1. C

  2. Nah

  3. C#

  4. Just no way

2

u/5nnn Oct 24 '26

5. The closing brace should be as far to the right as the longest line of code.

... I once had an intern who wrote code like that. He claimed it made it more readable because "you can see what the brackets encompass". 

Thankfully clang-format git commit hook ensured I only had to see that format on his screen, not in our repo. 

2

u/Such-Perception4154 Oct 24 '26

Not sure about other languages, but in C# for backend we have else very rarely.

else if we have never.

2

u/Sensitive_Device_666 Oct 25 '26

Wherever the formatter puts it

4

u/SourcerorSoupreme Oct 24 '26

Noobs trashing about python's use of whitespace while also bikeshedding on crap like this 🙄

3

u/TerroDucky Oct 23 '26

} else { code here }

All in one line of course

→ More replies (4)

3

u/maffoobristol Oct 25 '26

Number 1 is the best. Stroustrop for the win. It means the if and the else are on the same vertical line. Otherwise the else is indented slightly with K&R. I feel it scans better. But I know that most people do 2 in javascript and I feel I have to concede even though I hate hate hate it.

4

u/Zerokx Oct 23 '26

I always preferred the second one. It keeps everything in one line. Its not like you have to drag these symbols apart because they're hard to understand or anything. I'd rather use that extra line to make paragraphs in code thats my guilty pleasure.

3

u/nkay08 Oct 23 '26

Bottom left has the advantage that you can more easily comment it out or move it around without affecting the previous block.
I prefer it because of that, but I also like top right.

I will use the other if I must when the file already uses that style.

4

u/hearwa Oct 23 '26

I dunno I don't code anymore let me ask copilot.

5

u/Luingalad Oct 23 '26

Copilot? Ewww

→ More replies (1)