What's wrong with the left one? It's easier to read

What's wrong with the left one? It's easier to read.

Attached: 1475124870.jpg (479x310, 14K)

Other urls found in this thread:

en.wikipedia.org/wiki/Indentation_style#1TBS
kernel.org/doc/html/v4.10/process/coding-style.html#placing-braces-and-spaces
en.wikipedia.org/wiki/Indentation_style#Whitesmiths_style
twitter.com/SFWRedditGifs

idgaf, I'm not a picky princess, whatever the project's convention is.

Exactly but further into the subject I would much more prefer brackets in a seperate line for readability.

left is cleaner, but I do use right when its a single statement inside

right

I use left for personal projects, but we use right at work. The only thing that tickles my autism is when people refuse to use space, for example
if(condition){
statement;
}
for(i=0;i

Right. It looks cleaner and saves a line.

this is the only correct solution but apart from that the right one saves you vertical space which, unless you have a monitor in portrait mode, is preferred

Only the closing bracket is relevant, so only the closing bracket should be on its own line.

once had some dude in a university project that never did any spaces or newlines because he thought that optimizes the code, it was in java

>cleaner
nope
>saves a line
at the cost of cleanliness

I run clang-format over my files, so they'll have whatever style is defined in the local .clang-format config.

you should murder your pajeet classmates and then KYS

>saving vertical space is preferred
Nigger, no. There's a reason why the width shouldn't exceed 80 characters. And actually, I'd argue that placing brackets on a new line will make the programmer think a bit more before making a new block, in order to save space.

Also, placing opening brackets on a new line makes it easier to match brackets and thus identify blocks when you're reading code. Thirdly, it makes it easier to change the condition (or comment it out entirely).

Because programmers on a 80x24 can only see 24 lines a screen.
You act like you aren;t even iving in the 70's with questions like that.

Left is C style, right is Pajeet Java style. Prove me wrong.

not exceeding 80 is very hard, I moved it to 92, then 100, I never go over 100 even if I have to make separate methods instead of overloads

Left is useful if you're changing functions as you can just triple click or use a keyboard shortcut to change the line without having to deselect the last space and bracket.
But I think right looks better and personally find it easier to scan through multiple functions. So whatever, really.

>not exceeding 80 is very hard
If you're writing lines that long, you need to break them up. If you're nesting that deep, you need to split up your code into helper functions. Not exceeding 80 characters is a very good guideline, and it also helps dramatically when going through git log and diffs in the terminal.

Pic related is the best one.

Attached: uwu.png (222x148, 2K)

You still need to actually select what's in the parenthesis though. Unless you're changing it from an if statement to something else, but that will usually also involve changing the whole block of text underneath it.

he dropped out by now

who cares? its same tjing

ITT: Bike shedding

right is more convenient/faster to write, same as dense oneliners, nested ternaries, etc.
writing code constitutes about 5% or so of the time you spend programming.

left is a lot easier to read and parse (mentally).
reading code constitutes the other 95% of the time you spend programming.

>inb4 muh vertical space and any other retarded arguments
the venn diagram of js koders who loooove dense kode like that and js koders who can't read their own kode two days after writing it is just a circle. hence their tendency to constantly throw things away and move on to newer toys.

Attached: 1563938526401.jpg (680x670, 50K)

if you have autism

You don't? How do you deal with the extremely tedious and menial job of staring intensely at instructions on the screen, running the program over and over with various prints and/or in a debugger, trying to find out where it all goes wrong without autism? Do you use drugs like me?

>Do you use drugs like me?
1

You're wrong.
Left is how function definitions should look like, right is the one true brace style used by everything else which involves blocks delimited by braces.

en.wikipedia.org/wiki/Indentation_style#1TBS
>When following K&R, each function has its opening brace at the next line on the same indentation level as its header, the statements within the braces are indented, and the closing brace at the end is on the same indentation level as the header of the function at a line of its own.
>The blocks inside a function, however, have their opening braces at the same line as their respective control statements; closing braces remain in a line of their own, unless followed by a keyword else or while.

>1TBS
Pig disgusting. Allman style or gtfo, pajeet.

bool b = (bool)420;

Would this compile with ?

I come from civilized languages, so only left makes sense.

Yes

>following K&R
How can people make the same fucking retard mistake for 40 years, no matter how many times they're corrected?

All my stuff is on a single line until the text editor autowraps it when it runs out of room (not user set autowrap.) Anything that must be on a new line will be.

left obviously. looks better feels better for me

I never got used to the Java style. It triggers my OCD.
The left one is much more ordered - horizontally aligned brackets + two empty lines that clearly separate a block of code.

The only thing that triggers me is when an else is placed on the same line as the closing bracket

anyone who argues that left is not the superior and easiest to read way to use braces is fooling themselves or a shitposter.

Especially when it makes managing code blocks and debugging so much easier

You also forgot the mindless K&R cocksuckers.

>Calling braces brackets

Attached: 1300044776986.jpg (600x600, 35K)

>never did any spaces or newlines
>because he thought that optimizes the code
even if this poo dropped out, I wouldn't be surprised if a big portion of "professional" college educated programmers actually believe this is true, especially females

Attached: 1567428145371.jpg (1024x1024, 66K)

it does optimize it retard, it makes it faster to build

>pajeet
kernel.org/doc/html/v4.10/process/coding-style.html#placing-braces-and-spaces

by 1ms, maybe

Using left at work, right for my hobby projects. Both are comfy.

>using the kernel as an example of good programming style
LOL

Both are shit but left is better than right

your all doing it wrong


[[ condition ]] && {
statement
statement
} || {
statement
}

Attached: 1562090337807.jpg (800x1000, 96K)

Is this bait or do you have no sense of time whatsoever?

My uni teacher requires no spaces

Attached: 4e955f6718ab431a3df68cbc29bb065f.jpg (800x800, 75K)

based. fuck breaking conventions.

I use left, cleaner.

^KD
nothin personell, pajeets

At best you gain what, 200ms over the entire project? Fucking retard. In return for saving 200ms you get 200 hours a month of wasted time trying to read an unreadable garble.

Attached: 1562018195553.jpg (662x900, 59K)

Left is not

This, using an entire line for the opening block character is just fucking retarded.

I like right because you can fit more lines on your screen
I also do
if (condition) statement;
for short statements

when there a single statement you dont use anything, fag

python chad here
what are those weird curly things? Looks like my pubes.

This is the only correct style:
if (condition) {
statement ;}
for (i = 0; i < n; i++) {
statement ;}

left for functions and classes, right for everything else, but no space after the paren

wow what the fuck? truly, no one aligns their brackets like this?

if condition {
statements
}

>;}

No, the proper way is:

if (condition)
{statement;
statement;
statement;}


Anything else is either illegible or unnecessarily dogmatic.

It looks neat in examples like that but results in needless scrolling and makes if-heavy code look like a double-spaced high school term paper.

Right is both easier to read and more compact.
You're braindead if you choose left.

>K&R were wrong
>Linus is wrong
>random Jow Forums shitposter is right
ok ok

>trying to emulate python syntax by shoving C syntax elements out of the way

You use left for function definition blocks and right for everything else, as per K&R and Linux coding style guide

if (condition) {
/* some code */
} else if (condition) {
/* some code */
} else {
/* some code */
}

these are real programmers, the rest are roleplayers

>Linus is right
yes, gotos and 8 space indentation are so good, right.

>K&R is right
Both Linux kernel and K&R are standards from the 80s, you are a boomer.

Right is easier for me to read

constructor(
private moduleX: ModuleX,
private someRandomServ: SomeRandomServ,
private blah: Blah
) {
// ur code here bb
}


I wrote my DI's like that when I worked on some Angular shit.

oof, the last bracket is one tab too far tho

Is there some way to declare a preprocessor directive so that stuff like
if (...)
while (...)
... fun(...)

gets an opening brace implicitly added
(and writing end is equivalent to a closing) ?

Attached: 1564801961181.png (752x648, 296K)

Not him but if you have a problem with 8-space indentation it's likely because you don't know how to structure a program and have a shitton of nested loops so an indent of 8 would make your code not fit on your screen.

not to mention making newlines without a continuation symbol like & or \ automatically getting semicolons added

this means you could do

int dostuff(int n)
int x

x = sqrt(2*pi*n)
printf("this style is pretty bae\n")
return x
end

Attached: 1539980324262.gif (320x180, 179K)

8 space indentation is fucking retarded. You might as well use tabs at that point, but that's not what the Linux coding standard says. It says to use 8 spaces.

ITT: yuropoors with no practical coding experience

or even
int dostuff(int n)
int x

x = sqrt(2*pi*n)
printf("this style is pretty bae\n")
return some_calculation1(x) + &
// comment
& some_calculation2(x) + pi
end

nobody say its wrong its just look like a pajeet coding flavor

This is how NIM got started.
Why not use just that. It's pretty dope.

so transpiling C to nim and then nim back to C like an absolute madlad ?

Attached: jofsfofos.png (337x309, 143K)

neither, i follow the gnu style

Cargo culting is not the road to success, user.

no

fp
bp and this cringe, right is better.
having a line per bracket doesn't help readability retard. It makes it work since you waste a line for style like retards doing redditspacing.
Like other languages don't even use brackets.
But then, there is the biggest nigger of all them, the one who uses both in the same project:

>baby's first intro to C
>wow the ancient braces on their own line is so elegant

Here where I work it's used to indent everything in the statement
if(condition)
{
statement;
}

Ok fuck it I don't know how to codetext

Attached: 1547038389594.png (667x720, 134K)

Attached: 1443295967027.png (553x759, 58K)

en.wikipedia.org/wiki/Indentation_style#Whitesmiths_style

Attached: 1559272633445.jpg (640x737, 168K)

...

You'rerightbroweshouldntbewastinganyspaceweneedmaximumefficiencyafterallitdoesnthelpreadability

How you space your source code doesn't affect how hard the code is to understand, so long as the spacing doesn't affect how hard the code is to read.

When I type I don't give a fuck about syntax, I'll have everything all mangled together, spaced out, uneven brackets, everything.

Then when I hit control + s, I let Prettier handle it for me. Life is bliss.