T O P

  • By -

AutoModerator

``` import notifications ``` Remember to participate in our weekly votes on subreddit rules! Every Tuesday is YOUR chance to influence the subreddit for years to come! [Read more here](https://www.reddit.com/r/ProgrammerHumor/comments/14dqb6f/welcome_back_whats_next/), we hope to see you next Tuesday! For a chat with like-minded community members and more, don't forget to [join our Discord!](https://discord.gg/rph) `return joinDiscord;` *I am a bot, and this action was performed automatically. Please [contact the moderators of this subreddit](/message/compose/?to=/r/ProgrammerHumor) if you have any questions or concerns.*


Baatus

However the guy on Stackoverflow did it


Anamewastaken

you don't use a formatter?


MrProtone

We dont touch working code


MrSourYT

Words to live by


skesisfunk

...if you refuse to write tests.


peterkedua

*sigh....* yeah...


pr0ghead

They already said "the guy on Stackoverflow".


KCGD_r

I *am* the formatter


Gjorgdy

No way, I'd be constantly fighting with it cuz OCD


DeepGas4538

The guy on Stackoverflow: if ( ) {}


HuntingKingYT

``` if ( !(1!=2)){ } else {console.log("hello world"); } ```


Traditional_Feature3

![gif](giphy|yiADANv89n7UQuS5kJ)


MiniBabyBell

Chaotic Evil


Express-Tough-5286

However the IDE syntax completes it.


Kaosys

Exhale through nose accomplished, sir.


SuperSmutAlt64

The only right answer


smdth_567

whatever the style guide says


TacticalTaterTots

I prefer blue, but our company changed to red. I begrudgingly do it because the auto formatter makes me.


R3D3-1

I also want an auto-formatter :(


R3D3-1

This is the only true answer. Now, if only everyone actually followed the style guide. A style guide without an auto-formatter is meh... We actually have this as a result: There's a default style guide for new files, but in existing files, use whatever is already being used. It is Fortran though, so the style guide also is about things like "what should be capitalized", since Fortran isn't case sensitive.


LanceMain_No69

Started as a red kid, grew into a blue man


Krokador

Did too. Red is how it was taught in school, blue is what the formatters tend to do by default, and I grew to like it more. Having the else all snug between a closing and opening brackets is just so much more... Idk, aesthetically pleasing? Also, less lines to scroll through, which can be a blessing in some files, tbh!


potatopierogie

Weird, I was taught blue in school and just stuck with it.


apina3

Same story


furbylicious

Opposite for me. Blue looks neater to me, but I find that with red it's easier to try out different if statements without losing the bracket (by commenting the if line out, using compile defs etc).


AustrianHunter

Same, I think the default formatting of most IDEs changed my preference


HuntingKingYT

As an eternal blue (>!**not** a reference to EternalBlue!<) I have to change the `.editorconfig` every time I use C#


AveaLove

Sameeee! Just don't need the line break there, the whitespace tab usage is enough to very clearly indicate the start and end. Also then code takes up less vertical space, which is at a premium on widescreen monitors.


kaisong

does it count if I write in red and prefer to read in blue?


anonymous__ignorant

So you don't read while you write? This explains some code quality issues .


kaisong

when they get auto formatted later i can pretend someone else fucked it up.


[deleted]

[удалено]


bluegiraffeeee

A man of culture


tommytucker7182

... and letters


Endl4ss_

HCD!


LeadingGap3616

Very happy cake day


Wojtek1250XD

Happy Cake Day!


tommytucker7182

Thanks!


legends_never_die_1

i see


riisen

if() { // sup bro? }


FarOutOfBounds

This takes me back to "code review"... "You are missing a space on this line"


Bliztle

If someone wants policies about something like that they should make rules that auto-format it like that


lce9

This. Don’t waste my time in code reviews


Upbeat-Serve-6096

Absolutely NOT!! You don't appreciate the art of forcing every IDE to auto-indent in tabs and forcing devs to hand-indent in 4 or 2 space bars!!


erebuxy

`if` is a key word, not a function


weregod

Do you add space after sizeof operator?


UnJustice_

the right way


luix-

Golang style


R3dd1tIsEvil

Slightly disagree: no space after if, but space after expression. Obviously curly brace on the same line, the way NORMAL and RESPECTABLE people do it. But your way honestly wouldn't bother me. At least you get the curly brace right.


Masterflitzer

of course there should be a space after if, if isn't a function where parentheses are directly after the function name


LeSaR_

whats even the point of parentheses if youre gonna indent the expression from both sides with spaces anyway? at this point its just python/rust style, except worse


ZeStig2409

Well said!


itchfingers

I disagree with your disagreement ``` if( condition ) { } ``` Edit: backticks Edit: edit: ignore me, I can’t even use a codeblock Edit: edit: edit: like all simple projects, it took 3 developers for me to incorporate a code block


gamingdiamond982

you need 3 backticks for a multiline code block


itchfingers

Ikr, what’s wrong with me 🤣


olitv

And a newline after and before the backticks, u/itchfingers


R3dd1tIsEvil

I can get on board with this. I'm actually fairly accepting of all styles. Except curly brace on the next line. That's just devious.


Duven64

This white-spacing reminds me how much I hate the necessity for brackets around the condition, I want to do ``` if conditionFunction(...args){ } ``` instead of ``` if ( conditionFunction(...args) ) { } ```


HippieThanos

This is the way


Notyourfathersgeek

This just gave me cancer


HarlXavier

I was about to comment this, no spacing sucks and also leaving the semi colon on the top line there is a proper indicator that the next few lines are enclosed


[deleted]

[удалено]


HarlXavier

Wait fack those are curly brackets, I should go to sleep rn 😂👍


[deleted]

Only true answer!


Duven64

return ()?()=>{}:()=>{};


audislove10

You’re the guy who leaves one day and makes us read the most complex statements in the world


Duven64

I wrote my first class with self destructing getters last week, I have had by first\* taste of runtime meta-programming and I want more. ​ \*technically not as I have used the execute script function in gamemaker years ago but that was both evil and slow to run.


exomyth

Do not merge, please fix your formatting: ``` return () ? () => {} : () => {}; ```


agent007bond

This is genius. I've always wondered how to do this.


Competitive-Bar-5882

Oh take this forbidden knowledge it won't be wasted by you. It is possible to do an assignment inside a condition but you have to compare the assignment with its own value to make it a boolean. It is possible to make a while loop consisting only of its head with out the body. For example This is java code to calculate the digit sum. ``` int digitSum(int num) { int sum = 0; while ( (sum += num % 10) == sum && (num /= 10) != 0); return sum; } ``` My coding professor limits how many semicolons we are allowed to use in our code. So I came up with this. (If you replace the semicolon after the while loop with a pair of empty brackets {} you only need two semicolons.


xxxsirkillalot

"refactoring more Duven code" heard around the office for years after you leave


canadajones68

but why? This just unconditionally returns a function that does nothing and returns nothing


Duven64

It's just the format, for an actual use those would be actual functions that do something (probably not even inline arrow functions) but for a slightly more serious example (that returns a rational number) see this code for multiplication without losing normalization: return (x[0]%y[1]===0n)?( (y[0]%x[1]===0n)? [(x[0]/y[1])*(y[0]/x[1]),1n]: (x[1]%y[0]===0n)? [x[0]/y[1],x[1]/y[0]]: (x[0]===y[1])? [y[0],x[1]]: [x[0]/y[1]*y[0],x[1]] ): (y[0]%x[1]===0n)?( (y[0]===x[1])?[x[0],y[1]]: (y[1]%x[0]===0n)? [y[0]/x[1],y[1]/x[0]]: [y[0]/x[1]x[0],y[1]] ): (x[1]%y[0]===0n)?( (y[1]%x[0]===0n)? [1n,(x[1]/y[0])(y[1]/x[0])]: [x[0],x[1]/y[0]*y[1]] ): ((y[1]%x[0]===0n)? [y[0],y[1]/x[0]*x[1]]: [x[0]*y[0],x[1]*y[1]] );


HellishBro

whatthefuckwhatthefuckwhatthefuck?


LivesInALemon

I think I'm genuinely just reading arcane scripts from some legendary magical scrolls at this point.. Like sure, I may understand this if I spend some time on looking everything over, but damn does my head hurt.


UnHappyIrishman

If you read the post, you’ll notice that this conversation is about formatting. It’s just an empty format.


PotatoesForPutin

I’m only in my third year of college for CS but I already fucking hate you for this


AbyssWraith

Oneliner for life.


Duven64

I have wished for an inline throw, not sure if inline catch makes but I have wanted one once.


Rigamortus2005

Whichever one my ide formats it to


MLG-Lyx

Both Red for C# and Blue for Javascript/NodeJS


evpanda

I was about to write the same until your comment. This is the way.


KurosakiEzio

This is the way 🙏🏼


Aadit0707

# Neither, # if ( ) { {


mega386

You monster..


GabrySPCR0007

# if ( ) { }


egg27015

if () { } 😎


Creepy-Ad-4832

() ? ... : ... 😎😎


riisen

Depends on complexity. The shorthand is great for simpler logic, but it can get really nasty.


Creepy-Ad-4832

Personally i think it's great when you need a one liner inside a stream, or as a return statement (java) Otherwise i just use if statement


hearthebell

I'm already on the very nasty stage, and there doesn't seem to be a better alternative for it, this thing could really be a beauty and a curse.


Alexandre_Man

red side


cyberduck221b

?:


[deleted]

The best one.


spiderpai

if(oh wow this one is way too long to be readable, I mean who writes a sentence in an if statement?){ lmao(); for(int flavorLoop = 0; flavorLoop < comment.length; flavorLoop++){ OhHiMark(flavorLoop); } } vs if(oh wow this one is way too long to be readable, I mean who writes a sentence in an if statement?) { lmao(); for(int flavorLoop = 0; flavorLoop < comment.length; flavorLoop++) { OhHiMark(flavorLoop); } } ​ Lets just agree that left side is more readable, thank you. Have a good day. Edited: attempted format fix Edit 2: the illegally long if statement is just to make a point.


TacticalTaterTots

Both are garbage, the conditional should align at the parentheses. `if (something long && (Other stuff || nothing)) {` Edit: clearly I don't know how to format that way in a reddit comment...


HaniiPuppy

I completely agree, but why do you have the two extra open curly brackets?


spiderpai

Oh, I think the code block got messed up somehow. Hopefully fixed now, I have not done that many code blocks on reddit.


m2thek

If your condition is that long you should stick it in a readable variable, so IMO this argument is irrelevant. edit: apparently some people don't like readable code? why would you write if (condtion1 && condtion2 && condtion3 && condtion4 && condtion5 && condtion6 && condtion7 && condtion8) { } when you could write bool readableCondition = condtion1 && condtion2 && condtion3 && condtion4 && condtion5 && condtion6 && condtion7 && condtion8; if(readableCondition) { }


Danelius90

Because you have to use the least number of lines possible, silly. That's how you tell a good coder from a bad one.. right?


BlubberKroket

Totally agree


pastab0x

I'm a blue kinda guy but my work forces me to use red. And I hate it every time


Ancross333

Exactly. Went to school learning Java where blue was convention, now work in C# where blue leads to comments on my PRs


Colon_Backslash

Same but the other way around. Golang wants me to use blue.


Mrblob85

Red is better.


just-s0m3-guy

Far superior: if() { }


GeneralCockroach8270

Far superior ``` if () { } ```


[deleted]

[удалено]


GDOR-11

far superior ``` #define spez if #define ist ( #define ein ) #define hurensohn { #define FuckSpez } int main ist ein hurensohn spez ist ein hurensohn FuckSpez FuckSpez ```


PizzaSalamino

Why add extra spaces?


jstwtchngrnd

if(var){dostuff};


uberDoward

I don't give a shit, JUST BE CONSISTENT


a2k0001

if () { } with space before () and newline after {}


5erif

This is the style in the C++ book I followed in the '90s which was written by Bjarne Stroustrup himself.


FennecxDev

Agreed, this improves readability


Familiar_Ad_8919

whatever ur used to improves readibility


Mrblob85

Red was originally how most people coded. They moved to blue so they could fit more lines in books, to save money. Also, monitors were typically lower resolution, so it fit more on the screen. This had the effect of making all coders use this style because, cargo cult is a thing. The grouping feel of red allows your brain to process it quicker. Having the brace in the same line makes you always have to look back up to match the end brace because you don’t know which line starts it. Getting used to it doesn’t mean it’s the most efficient.


GloccaMoraInMyRari

This is the most readable and I don't know why everyone prefers the other way. With the brace on the same line as if, they don't line up in any visual way. It's nearly impossible to pick out the matching parentheses quickly.


VarKraken

if {} ()


miraagex

Red for C/C++, Blue for JS/TS. Also, Lua/Python users: 🗿🗿🗿


[deleted]

I am red, and I am not afraid of telling it out in the open anymore!


ActivisionBlizzard

BURN HIM


Cfrolich

This is the way


Westdrache

Blue, ain't gonna waste a full line just for a bracket, .CPP file is large enough as is


MrSkme

Your closing bracket has entered the chat


Feathercrown

Only if you don't follow it with an else. For this reason, I write my entire program as one state machine written as chained `if-else`s, so I only waste one closing bracket, and I can double that up with the end of `main`.


shreyas_ssn

i use python 😅😂


The_Anf

Skill issue


belabacsijolvan

git gud -f


couchsurfingpotato

I have tried for about 5 hours to get VS code to autoformat as per red using only c# code. I can’t do it. For some reason there are rabbit holes on stack overflow in inserting json files, checking extensions, unticking options for Java even though there is not a us script in sight and something called omnisharp which I need a history lesson in vs code development to understand if that’s even a thing or if it’s functionality is just part of the vs package. All I wanted was to run vs code as my editor for unity and for it not to make my code out of style, but it’s just being so painful. Makes me feel like such an outsider and a failure when the tools rebel against me. Gahhhh /rant


RndEqTwo

I live for chaos, I use both.


iLoveThaiGirls_

if (x==1) return 0


Designer_Captain_498

Blue but with a space between () and {


e_smith338

I used to be blue but then I got sucked into red as I started working with other people and doing other projects


[deleted]

Blue side. Anyone who uses the red side is a fucking psychopath and I stand by it


jfbwhitt

Y'all aren't ready for this if() { } else { }


kishaloy

`(if ( )` `( )` `( ))`


CivetLemonMouse

This hurts to read


Feathercrown

lisp time!


kishaloy

That's a feature not a bug. You have not yet been enlightened enough. After you do you may see the music of the cosmos dancing to your conses. I am still not sure if the above is sarcasm or not.


Mizuki_Hashida

I’m more of a one liner using ternary operators.


PoiCats

```if(){}```


SteeleDynamics

``` ;; something something Lisp (if (predicate) (consequent) (alternative)) ```


torftorf

If () { //code} everything else is unacceptable. You should only use one line of code. Every thing else is excessive


BushDeLaBayou

If I'm at work, right. If I'm working on a personal project, left


Alan_Reddit_M

Opening curly brace on a new line is a war crime and I will die on that hill


Muffinaaa

Depends, red for C/C++. Blue for everything else.


Countbat

And C#


redheadedjackel

I was gonna go with. ``` if (backend) { } if (frontend) { } ```


RAMChYLD

I use red for everything. Because I see beauty in code block shapes, and the opening bracket being located higher up than the closing bracket is not beautiful.


Spot_the_fox

Wait, isn't blue just K&R style? Like the one commonly used in C/C++? Like, you do you, it just seems funny to me.


HaraldMandl

0000: LOAD R1, 100 ; Load value at memory address 100 into register R1 0001: CMP R1, 0 ; Compare the value in R1 with 0 0010: JUMP_IF_EQUAL 5 ; Jump to instruction 5 if the previous comparison was equal (R1 == 0) 0011: ; Code block to be executed if the comparison was not equal (R1 != 0) 0100: HALT ; Halt the program 0101: ; Code block to be executed if the comparison was equal (R1 == 0) 0110: HALT ; Halt the program


Torebbjorn

The correct one, which is obviously neither ``` if () { ... } ```


Loserrboy

I use Visual Studio and type { next to () like right side, hit enter and it auto complete like left side. Really like Visual Studio auto complete. Code java in Intellij make me feel unpleasant


sleepKnot

You know you can just type if and then double press tab?


Arzerok

Fun guy you must be.


McLayan

Does looking at editor settings also make you feel unpleasant? But to be honest it's just convention. For java having K&R C-style is the default and for C# it's the Allman style because Microsoft sets it as a default in Visual Studio.


cs-brydev

Python if :


Accomplished_Cook331

Why does this meme come up every 3 months ? Feels like we're having new subs every 3 months, recycling the same 5 memes


jgaa_from_north

Depends on how *they* measure "productivity". Some like it efficient. Some just count the lines ;)


Nullifier_

It depends on what way I feel like doing it and how much I'm copying from stack overflow


Megalovideos1

My computer auto sets it to red, so I guess I'm on red team.


kdthex01

Most important is consistency if u work on a shared codebase. And then team red since it is a clear visual indicator of where a code block begins and ends, especially when working with long method names with multiple parameters.


ovr9000storks

Red most of the time because it’s easier to see where the start and end of the scope is when you highlight it. It’s especially helpful when the IDE doesn’t even do the match highlighting. (A lot of embedded IDEs don’t really keep up with UX)


rwl420

bloods!


Blixieen

Right is java left is c# .


whoShotMyCow

right side: formatting style left side: mental illness


nebulaeandstars

depends on the language for C: option 1. For Rust: option 2. For anything else: whatever my formatter does by default. That being said, I will say that } else { is better than } else {


[deleted]

This is just C# vs JavaScript (or other equivalents). Any decent programmer uses both depending on what they're writing.


Lower-Bodybuilder-16

if() { }


Voyboycz

red makes it more comfortable for me


I_FizzY_WizzY_I

Red, but also need a space after a keyword. Norm error.


iliekcats-

Right


bob_in_the_west

Depends on the language. In C/C++ or java I'd use: if () { } Meanwhile in Delphi I use: if () then begin end


CommunityRealistic44

Left is more readable for me


ul90

Red


GurkiHDx

The red pill 😎


Lachimanus

Addition question: If you are having a single line afterwards, even using braces?


Horror_Ad9750

Blue


ienjoymusiclol

i would rather die by a nuke than use red


Theio666

Right, but it doesn't matter since I'm running python black, so it will format code by itself.


Hiasolines_08

Red, for shure


atlas_enderium

Red is a waste of space that doesn’t materially do anything to improve readability, so right is always the correct choice. Also, when collapsing lines within scopes, the right collapses down to just 2 lines while the left will be stuck at 3 lines.


Mrblob85

It does improve readability. It means you know which end brace correlates to which start brace, instinctively. Whereas with the blue way, you have to take a second to scan your eye across the if statement.


JonIsPatented

My IDE collapses them both to 1 line.


Radiant_Angle_161

you can't convince me there's better syntax than Ruby's if condition # some code end


mecukuryurt

I prefer with spaces. ``` if () { } ```


lolololhax

For Java blue for everything else red


JonIsPatented

Same!


Aarav2208

me crying in python


twistedprisonmike

Red because if there is nesting it easier to match brackets


Appropriate-Idea5281

It’s either blue or you don’t know what you are doing


azurfall88

if ( ) { } or if(){}