Well?

Well?

Other urls found in this thread:

kernel.org/doc/html/latest/process/coding-style.html
gng.z505.com/stallman-good.htm
twitter.com/SFWRedditGifs

i dont program but left

if (condition)
statement

left for functions right for if statements and stuff

if (condition);
statement();
Is the only correct solution

>OOP
lol

if (condition)
single_line_statement;

if (condition) {
multi_line_statements;
}

if (condition) {
single_line_statement;
} else {
multi_line_statements;
}

Only way to fly

I use left for C++ and right for Java.

left if more readable when nesting.

a good thread had to die for this piece of retarded shit
kill yourself

left is more readable.

>line bloat
>more readable
No.

Whatever's the standard in the environment I work in. Say, on work I use left one since I'm doing C++ stuff, when I write Java or Go I use right style.

The only thing I care about is consistency, anything else is supeficial.

Right is how you spot Pajeet.

>a good thread
right, like your retarded Sup Forums-tier graphics card threads. kys

>if (condition);
>;
baka

Did you forget to wear pic related, user?

I only use the ? operator and or single line if statements.

If it's multi line it should be a function.

>>>/loo/

No, it's supposed to be there, you degenerate.

My man

My ocd kicks in when I see right one.

{

code
{
moar code
}
}

Is how I envision statements. A pieces of blocks nested inside.

This

left makes it clear which parenthesis closes which without having to look at the end of the lines

so left

Right because I like writing }else{
Also camelCase while we are at it

I learned from pajeet, guess that's the same. She forced me to write c++ on paper every week with strict grading requirements. I thought it was dumb at the time but I appreciate it a lot more now that I watch people fumble over basic bitch syntax errors on a regular basis. Would pajeet again desu.

Sign that you're an idiot who can't program at all: you bikeshed about insignificant issues like this to make yourself feel smart.

Kill yourselves.

kys

...

>Nesting
You should be nesting more than 1 or at most 2 ifs.

right

Always left. I spent a lot of years programming Windows apps using MFC, and that's the MFC style.

Also, my brain is wired to be ultra-fast at spotting matching (or mismatched) braces if they're lined up vertically. (Kind of like Rain Man could instantly count 100 toothpicks.) I line up the braces vertically so that I can take advantage of my freakish ability. If braces aren't lined up, then it takes me somewhere between 10 to 20 times longer to check if braces are lined up.

I'm right, but I understand those that are left.

condition&&(statements)

if
(
condition
)
{
statement
}
else
if
(
condition
)
{
statement
}


the only way

function name() {
...
}

class name
{
...
}

if () {
...
}

[CODE] if(condition) {statements} [/CODE]

You're retarded

Are correct

No, YOU kys.

Source: kernel.org/doc/html/latest/process/coding-style.html

Capcha gave me a sign that this is /thread

if you have to write another if in the else you do something wrong

which language?

Only point I vehemently disagree with Linus is 8-space tabs.

Right is always the right side

I can agree with that. I understand why 8, but I like looking at four character wide tabs. As long as you are inserting a \t character however, it only matters what your editor is set to. Reading the same code, I'll see four and Linus 8.

>\t
Negative, spaces are superior and tabs will be autoconverted to spaces.

One True Brace is the gayest shit in all software development.
Even gayer than

I do it like that as well..
Never thought about the 'else' brace though.. That's pretty neat, thanks user!

class Balls
{
function bool SuckEm()
{
if (tasty)
{
return true;
}
else
{
throw OutOfThroatException;
}
}
}


If you prefer this code style, take it from the bright side: you can always make the World slightly better place by killing yourself.

int
main(int argc, char *argv)
{
if(statement)
//do stuff

if(multi_line) {
//do stuff
//do stuff
}

return 0;
}

Torvald's promotes 8 space tabs? Disgusting.

He's not a pussy that uses the same C source indentation as every other brainwashed bondage and discipline C programmer. i.e. Linus torvalds 8 space tabs. Tabs are cool, but so are 2 space indentations, and lisp indentation is also interesting.

Note: as I said, not all GNG folk would agree here, many people love their 8 space tabs. I'm a fan of 4 space tabs or 2 spaces depending on the language. 8 space linus torvalds style code just has too much useless whitespace. -RMS
gng.z505.com/stallman-good.htm

statement ? return true : return false;

Yeah but GNU code uses 8 levels if indentation like nothing. Torvald claims that if you use more than 3, you might just rethink your code. C is overall good at avoiding indent.

I never followed one of these autism threads to determine what's "correct". This is the way I learned, so, what is wrong with it from a more experienced programmer's pov?

6 lines of actual content, 8 lines of brackets

Exactly.

>Using braces inconsistenly

Left for C and right for Java.

Does putting { on separate line comes from old-school C function definitions and it just somehow survived?

int main(argc, argv)
int argc;
char *argv[];
{

So much wasted space..

class Balls {
function bool SuckEm() {
if (tasty) {
return true;
} else {
throw OutOfThroatException;
}
}
}

Here lies truth, blessed with dobs, underated

The only right way:
if (x < foo (y, z))
haha = bar[4] + 5;
else
{
while (z)
{
haha += foo (z, z);
z--;
}
return ++x + bar ();
}

The Haskell way:
if (condition) { do_something()
; do_something()
; do_something()
;
}

>No blank line before } else {

So close but no cigar

Used to be left, then right. The opening bracket doesn't need to be on its own line unless you're retarded and like wasting screen space.

my imbecile embedded systems prof. made us indent C like this:
void whatever(int x)
{
for (;;) {
doShit();
}
}


he refused to look at any code that used any other indenting

doesn't emacs do some shit like that by default in c mode?

> confused
I've never had this issue. I force \t characters. Possibly vanilla installing an editor defaults to \t -> space conversion?

Right

>not using horstmann style

this + for plain C

if
{statement
statement

statement}
condition

>can't delete the brace with kdd or k$xx

Now what is that sexy colorscheme's name?

Agreed. At least in C, as most of my programming is done in C or ASM, each function should do ONE thing and ONE thing well. If you create one function that for example opens a file, reads from it, writes to it, and then closes the file, it would be rather long and a pain to read. I would rather have:

int fileoperation(void)
{
open(file);
read(file, variable);
write(string, file);
close(file);
}


With each task being its own function. Less indentation, less screen space per function, more readable, easier to understand. I don't have to look through a clusterfuck to figure out how something is read.

ITT: dyslexics
Right > left

this makes sense, but I do right for everything.

this hurts my eyes.

picked colors from kate's breeze color scheme

Obviously neither of these
/**
* @brief function
* description of the function,
* the format of the variables
* and what it returns etc.
*/
void function(type &var)
{
if(condition) {
statements
}
}

Right always. Left adds a ton of unnecessary lines, and will just straight up produce errors in some languages. Plus it feels awkward.

Even when I write C# I change it so it does right by default

I like 8 char wide tabs.

Voting with a (You)

left

BUT, it's 2017 so i use spaces instead of tabs

>BUT, it's 2017 so i use spaces instead of tabs
nice bait

hi richard

Only Left, you don't need to save paper in a book.

breaks in tcl

Literally dependent on the convention of the language.
Anybody who declares a hard difference is wrong.

Ultimately, it is 100% subjective. Kind of why this debate even exists.

The left is more space out, what is actually happening sticks out like a sore thumb, the right is very condensed, so it can be easy to miss things.

The left contains a shit load of empty space while the right makes better uses of its space.

They both have their merits and the absolute most important thing is to pick one and stick with it or follow the established guidelines within the project you're working on. Consistency trumps any instance of autistic hand-waving.

>needing all that space on the left

lel looks retarded

if (a == b) {
c = a;
d = b;
}

lw 1, 0, if # r1

It's how K&R do it, how Linus Torvalds does it, and how Bjarne Stroustrup do it. Functions place the brace on a new line because they're unique; you can't nest them in standard C or C++.

In C and C++, there is no standard convention for the language.

function he {var doesnt = do.this }

This, plus this is a requirement for the linux kernel

You're a god. Thx for this

Left, because I am not a lazy faggot.

(if condition
if-branch
else-branch)

left.

>2017
>Using programming languages with unsafe memory
>Not using an elegant modern language with zero cost abstractions which produces safe programs

>elegant

Left is the only right one.

People who use right can read left easier than right. People on left can read left much easier than right.

Which single statement should I use?
if (condition)
return x;

if (condition) {
return x;
}

if (condition) { return x; }


I actually use the last one the most.

The first one. It's criticized to use single-line statement without parenthesis but if it terminates function or loop then it's ok. (return, break, continue, err). Imo the last one looks ugly.