Giving a curly bracket its own line

>giving a curly bracket its own line

Attached: FB_IMG_1555625820807.jpg (500x652, 13K)

Pretty common practice that increases readability without any negative consequences on compiled languages.

plz

Attached: yash.png (921x458, 407K)

it's a waste of space for something that adds negligible results in readability. the bracket isn't any less visible when next to the main function.

not putting curlies on their own line is something pajeets do to make their java spaghetti code seem less bloated

only a pajeet would use the term pajeet to cause a shitstorm since they live in shit all the time, pajeet. your poo tactics won't work here.

Stop being so childishly picky

Curlies are on new lines for: structs, classes, objects, functions

Curlies are not on new lines for: if, else, while, do..while, try, catch, finally, etc.

Attached: qt.png (212x198, 103K)

I sit on the toilet as I read this

Number 1 or number 2?

Attached: 1468811698955.jpg (220x250, 6K)

>its a waste of space
Which means NOTHING.

If you were a curly bracket would you fuck a curly bracket? Also, would you be the start or end curly bracket?

Attached: 1495590818034.jpg (725x725, 162K)

It depends on what language you're using and whether you care about following their general practices.

For microsoft platforms (C++, C, C#) coding style favors next line. Most other languages do same line. but even then companies do whatever the hell they want and collaborators on a project should just stick to the consistency of the rest of the code.

it's that simple. now stop pretending it's this le epic war you tards

new line makes it more consistent and beautiful for me, but i'm fine either way, really depends on company's internal coding standards

if carmack doesn't do it, it's shit. and you should kill yourselves, retards

>he sits down for number 2

If Carmack jumped off a bridge, would you do it?

sorry but python is not a programming language
try again

>increases readability
How?

You can't sit down if you use designated street.

I think it leads to better spacing and clearer structure consistency. Along with a consistent indentation it makes it easier to read the code and modify it.

>herding whatever square/round/curly brackets you can into their own line

perhaps

Had a nice shit thanks.

Whitesmiths style all day erry day

Clearer notation of where the beginning and ends of blocks of code are.

>line is something pajeets do to mak
Your brain recognizes shapes first, symmetrical shapes in particular. You read the words second, maybe third or fourth.
The placement of the bracket, on it's own line, is arguably more important for reading the code, than the actual code.

These other annons can go practice writing search trees or something.

Curly braces are for faggots. All you need is (begin ...)

{ if(foo):
bar();
}


heres the solution that satisfies both camps

>hav to add one more statement
>4got brackets

It's like saying that futanari satisfies both homo and hetero.

I wasn't very serious about it but it's been a while since I saw such a perfect analogy

1TBS only!

if(condition) {

}

This is the best looking way.

>The other issue that always comes up in C styling is the placement of braces. Unlike the indent size, there are few technical reasons to choose one placement strategy over the other, but the preferred way, as shown to us by the prophets Kernighan and Ritchie, is to put the opening brace last on the line, and put the closing brace first, thusly:
if (x is true) {
we do y
}


>However, there is one special case, namely functions: they have the opening brace at the beginning of the next line, thus:
int function(int x)
{
body of function
}

>if condition is so long that you have to linebreak inside the parentheses, fucking up the appearance of your code
FUCK

int function(int x){
//that's how it's done.
}


If you disagree with this, you're a fag.

You shit standing? Respect.

>technical reasons
Compiler doesn't care. But go ahead, surprise me.

fn function(x: i32) -> i32 {
// The Chad Way
}

That's literally taken from the Linux kernel coding style.

if condition then
branch
else
branch
end

Size of the standard terminal in ancient times.

I got bullied into doing
int function()
{ return 0;
}

>using a phone to take a screenshot

based lua

not having to, ever, cos i use python

Honestly, i cant fucking stand people who put the curly brace on the same line.

>Bbut it takes up less space
FUCK YOU you dumb cunt programming is not about using as little space as possible its about writing READABLE code.

>It doesn't matter because the compiler dont care anyways
FUCK YOU TOO you are just as dumb as the first guy. IT ABSOLUTELY FUCKING MATTERS.

Readability should be above all else (even performance in most cases) and a bracket on a newline is both symmetrical AND it makes your code more organized.

People who put the bracket on the same line are the people who was taught to do it that way when they first began programming and now are too arrogant to admit that its inferior.

That explains why I only ever see that in Visual Studio shops

Except in Razor views where on line is preferred to reduce whitespace in the resulting HTML.

Either way is fine just stick with it.

>waste of space
rate my new program, its space efficient and everything!
int n=13;int main(void){for(int i=4;i3;++i)if(i%n==2) printf("%d mod %d is %d",i,n,i%n);return 1;return 0;}
no wasted space!

You can easily see blocks of code as you scroll around, without even needing to try, best advantage imo

I haven't kek'd this hard in ages

Now THIS is a top meme.

what is the purpose of then? its literally bloat

its useful as an optional keyword because it helps maintain clarity for one-liners

>throwing a hissyfit because someone made a fair point

let me guess. you're a woman?

aids/10

>people claiming giving it a line makes your code readable

instant sign that nobody here codes. it makes zero difference.

Opening curly brackets for code blocks I put on the same line.
But opening curly brackets for objects I put on a separate line.

Is this weird?

Function declarations and conditions look the same as other code when you are speed reading.
If braces are at the end of a line i have to move my eyes over to see them interrupting flow.

if(foo){
//you're a faggot if you don't do it like this
}

>aids
>fair point
its still shitposting even if you're being ironic

The superior way:

ret_t
fname(arg_t name) {
if (condition) {
// do work
} else {

}
}

Means you lose readability because you have to scroll more.
Ideally every function should fit on one screen for maximum readability, which becomes a lot harder when you're wasting screen real estate on student form nonsense.

if you need brackets to interrupt your reading flow, then you're likely reading at a pace where you aren't gonna catch errors or grasp what to do.

most likely bait but still

Attached: 323.jpg (500x378, 25K)

...

how is what he said is bait? being able to see the function as a whole on one page is more readable than having to scroll up and down repeatedly. is your IQ in the negative range or something?

>Hurrrr depr I am retarded

This is why nobody wants to hire you, now you know.

if(1 > 2)
{
Console.WriteLine("C#");
}
else
{
Console.WriteLine("is");
}
// Redundant impossible boolean case removed.

Memes aside, I've come to really enjoy the C# (with brackets) and python (without brackets) way of handling it.

see
how readable is that?

Its true you should try to avoid big functions, but thats because big complex function lack reusability. Not because they make you have to fucking scroll more.

Oh shit you really are retarded.
I am sorry.

We did not say put all the code on a single line.

Attached: programming-of-the-highest-calibre.png (597x255, 51K)

>it's a waste of space
whitespace doesn't use resources, you retarded faggot.

screen space is a resource

In that case, it's an effective use of a resource since you're utilizing screen space for readability and not cramming it all into a corner so you can post another shitty screenshot on /wsg/, you faggot.

you're implying that if a function takes up more space than whats available on the screen then you should make the code more compact in order to fit.

I'm showing you that compact code makes something much less readable.

>giving an independent syntactic element its own line
lrn2grammar

if only emacs could be made to understand horstmann style.

inb4
>hurrrrr thats not what im imlying
>hurrr in that case you should split the function up into multiple functions hurrr

You were literally advocating for using brackets on the same line (a more compact style convention). So that IS what you are implying.

except you're expanding the amount of scrolling around you're doing just to see the full extent of your code, you double faggot.

public boolean passed(char[] answers, char[] correctAnswers){
int correct = 0;
for(int i = 0; i < 20; i++) if(answers[i] == correctAnswers[i]) correct++;
if(correct >= 15) return true;
else return false;

yeah but then when shit gets more complex your lines will be like 100 characters wide

>beginning lines with spaghet
>hiding return values at the end of lines
>never used text proc in his life
based bootcamp coder

>return type on separate line
Always hated that in GNU style

it ends the conditional expression. it's just a nice looking ";" really.

{

you can grep for function names that way.

> grep -re '^func_name' src/

thats kernel style. it's so you can `grep ^funcname *.c` and find exactly where the function is defined. `/^funcname` zips straight to the definition in vim. forward declarations are normal `type funcname (paramlist);`

There's nothing wrong with legibility. There's no limit on how many lines you can have, and you can always scroll.

K&R indentation was inherited from BCPL.
Like many profoundly homosexual aspects of Anglosphere culture, it originated in Cambridge.

It's a flithy, filthy perversion and anyone who promotes it will burn in hell.

Attached: CambridgeNights.jpg (480x365, 26K)

(defun horstman-style-curly-brace ()
(insert-char ?\s))
(global-set-key (kbd "{") 'horstman-style-curly-brace)
You're welcome

what's the story behind that picture?

circa 2012, jamal kang is using his black magic to curse the fools who stole his bucket of chicken wings.

>all these retards saying "it increases legibility"
it decreases legibility

imagine a book where every "a" and "the" and "it" gets its own line. there, you have allman bracing.

"every function should ideally be less than one screen in length" is in MISRA and JPL and Linux programming standards. it's reasonable.

A better example would be a name of the chapter separated by an empty line.
And that totally makes sense.

static Conv*
protoclone(Proto *p, char *user, int nfd)
{
Conv *c, **pp, **ep, **np;
int maxconv;

c = 0;
qlock(&p->l);
if(waserror()){
qunlock(&p->l);
nexterror();
}
ep = &p->conv[p->nc];
for(pp = p->conv; pp < ep; pp++){
c = *pp;
if(c == 0){
c = newconv(p, pp);
break;
}
if(canqlock(&c->l)){
if(c->inuse == 0)
break;
qunlock(&c->l);
}
}
if(pp >= ep) {
if(p->nc >= MAXCONV){
qunlock(&p->l);
poperror();
return 0;
}
maxconv = 2 * p->nc;
if(maxconv > MAXCONV)
maxconv = MAXCONV;
np = realloc(p->conv, sizeof(Conv*) * maxconv);
if(np == nil)
error(Enomem);
p->conv = np;
pp = &p->conv[p->nc];
memset(pp, 0, sizeof(Conv*)*(maxconv - p->nc));
p->nc = maxconv;
c = newconv(p, pp);
}

c->inuse = 1;
kstrdup(&c->owner, user);
c->perm = 0660;
c->state = Idle;
ipmove(c->laddr, IPnoaddr);
ipmove(c->raddr, IPnoaddr);
c->lport = 0;
c->rport = 0;
c->restricted = 0;
c->headers = 0;
c->sfd = nfd;
if(nfd == -1)
c->sfd = so_socket(p->stype);

qunlock(&c->l);
qunlock(&p->l);
poperror();
return c;
}

What sort of bizarre code do work with where blocks are as commonplace as chapter beginnings?