Okay niggers, let's settle this once and for all
Which one is superior A or B?
Please note, javascript pajeets are not welcome to voice they're opinion, you have to compile C++ on an UNIX like OS in order to post ITT
A is the only correct answer
>>61301487
What's the font
>>61301487
B for functions, A for everything else
>>61301492
menlo regular
>>61301496
mixing is the worst
>>61301487
A
A takes less lines and is more aesthetically pleasing
>>61301512
maybe but it triggers my autismo
B. It's easier to read and separate.
>>61301487
they're both wrong you cock eating faggot
>>61301487
always B.
>>61301487
B is the clearest
>>61301539
so what do you propose, this:if(poo==loo){
pajeet();}
>>61301556
>>61301554
>>61301537
>>61301496
I used to be like you, when I was in my first year of programming and I had been taught nothing but C#.
B is objectively bad. There is no reason to have a whole line wasted on a semi-colon. Are you mad?
>>61301487
A, but remove the spaces from the brackets.
>>61301584
And put a space between ) and {
>>61301582
lol what?
Good luck reading A with nested ifs
B, clearly
>>61301597
>nested ifs
Good code doesn't have this problem.
>>61301511
>>61301582
You can't put a function inside of a function.
>>61301613
i'm talking global scope
pajeet ? street : loo
>>61301487
O shit you wrote nigger? O shit... Man you're a badass.
>C++
>not a pajeet language
Depends on the language anyway, for non-languages like JS I use A, for real languages I use B.
A because is easy to read. And some editor left the open bracket when you want to collapse the function.
>>61301487
B looks disjointed
>>61301487
A is superior apart from for functions which deserve another line.
There should be a space between if and ( and ) and { but none between nigger and ()
>>61301612
Sure, let code javascript with no more than 2 nested bracelet.
>>61301511
Its not mixing though. A is for control flow, B is for a heading; which is basically what a subroutine/function is
>>61301612
have you ever worked on a huge software? This stuff does happen and usually nesting ifs is the best solution to the problem there is
>>61301487
A looks better and takes less lines
B is more logical
i prefer A
neither
function pooLoo(street) {if(!(poo in loo))
{return pajeet};
}
>>61301764
Get back to garbage company my friend.
>>61301487
it just depends on whats standard for the language you're working on and whatever style guide your development team uses
i use c# a lot and B is standard, A is very common in java and javascript, don't be a pajeet and get too hung up on it
>>61301487
A
But its irrelevant because I only use python. Lmao
if (nigger == nigger) nigger();
>>61301487int main() {
char const * const op = ">>61301487";
const int faggot = 8; /* 8 is a faggy number */
if (*op & faggot) {
puts("op is a phaggot");
}
return 0;
}
I choose option C.
>>61302091
Godspeed...
>>61302044
this
>>61301496
This.
4 space tabs also.
K&R masterrace
>>61301487if nigger == nigger:
nigger()
>>61301698
Nesting shitloads of ifs is never the best solution. Never.
>>61301487
>using braces for a single statement
jej
>>61302248
>using a language that lets the programmer choose
hwh
>>61302263
>getting cucked by a computer program
ayy lmao
If you don't do it like this you're a mental incompetent.
needs to be center alligned
>>61301487
>those spaces
youre filth
>>61302181
i wouldn't put the semicolons there, but it looks kinda neat. makes me miss Python. is there a plugin for this or something? tell me you don't do this shit manually.
pajeet tierif( stuff ){
only sane wayif(stuff) {
>>61302350
>only sane way
>if(stuff) {
THIS. THANK YOU.
>>61301582
Why are you ni/g/gers so jewy about number of lines?
>>61301487
same result so however you fucking like.
>>61302371
because my screen can have only so many lines in showing at once
>>61302247
I mean, you should simplify as much of the boolean logic as you can but sometimes nesting is unavoidable if you want to write efficient or readable code.
>>61301597
I have no problem reading nested ifs. Perhaps you should get your eyes checked.
>>61301487
typical racist white
>>61301487
stop it you mongoloid nigger cucks
https://www.kernel.org/doc/html/v4.10/process/coding-style.html
B is better. But whatever you're doing, remove the spaces after opening and before closing brackets. Also, put a space before opening curly if you're using A.
if (nigger) {
>>61301487
a space belongs between if/for/while/switch and (.
they're not functions, and a conventional stylistic difference in invocations is intentional, you dumb nigger.
>>61301613
Actually, with gcc you can
>>61301487int main(int argc, char **argv)
{
if (foo == bar)
{
baz();
}
}
Idk I always do B because it's more readable imho
But A is more aesthetically pleasing though
But if it's just one line I've begun doing
if(cond)
doSth();
>>61301487
>that spacing
Both are pajeet tier.
>>61301487
*thier
>>61302962int main(int argc, char **argv)
{
if (foo == bar) {
baz();
}
}
fixed your shit, including your spaces, you dumb nigger. kys or stop koding.
Neither. I don't use profanity in code.
I use the second one. But for such small blocks I wouldn't use brackets at all.
Most likely I'd probably just write it on one line. But I've been known to mix those styles.
Sometimes I just feel it gets too long. Regardless of if the line is less than 80 chars
>>61303003
Disgustingly inconsistent.
>>61302845
if: (cond)&&todo
if else: ()?:
functions: new Function(function code)
B, easier to see where scopes start/end at a glance or when you're scrolling.
>>61302962
lose the curly braces around baz(); and you got yourself a winner
>>61303067
I prefer to avoid any possibility of agoto fail;
>>61303003
Yuck man. How do you even justify this? The moment you ever have to copy/paste you have to remember where the fuck you are and you're more prone to error. Just hit enter, always, FFS.
>>61303021
fuck you.
also see: >>61302858
>>61303103
>k&r is right
While I agree there needs to be better motivation.
>>61303103
Cool non-justification.
>>61301597
>>61301687
>>61301698
>>61302792
The Linux code style uses 8 spaces specifically to counter warn when code is nested too deep.
>In short, 8-char indents make things easier to read, and have the added benefit of warning you when you're nesting your functions too deep.
>Heed that warning.
https://www.kernel.org/doc/Documentation/process/coding-style.rst
>>61302936
no it doesn't, dumb faggot.
I prefer many line breaks. Like this;if
(OP == racist)
{
gtfo();
}
>>61303142if
(
OP
==
racist
)
{
gtfo
();
}
>>61303075
>using goto
>main.cpp
pls b b8
if(
cancer thinking if is a function
>>61303156
Why even indent at this point?
>using {} at all in this case
>not using far superior (condition)?nigger():nonigger()
>>61303175
>missing the point
>>61303204
>not using an auto source code formatter
are you also thicc in the bottom, or just the head?
>>61303185
how about or
if (a == b) {
do();
}
Spaces before parens for macros, no spaces for functions.
>>61301487
If(nigger==nigger){nigger ();}
Fight me
>>61303254
>Spaces before parens
dumb faggot poster.
>>61303265
if is not a function.
>>61301487
follow the official doc of the language
>>61303273
>thinking there's difference between calling function or macro
dumb blub programmer.
>>61303260
I though you can ignore bracket if your code has only one line?
something like
if (a==b) dosomething();
>>61301487
If you use B you're fucking retarded.
A is:
1) more readable
2) easier to write and shortens time(no need to newline)
3) lowers file size
>>61303288
There is. Function calls should not resemble control flow constructs. They are a special form, so they should look special.
>>61301582
>There is no reason to have a whole line wasted on a semi-colon
It's called organizing
Try having over 60k lines of g-code and deciphering it when all the lines are ass to mouth
>>61302380
> over tens of thousands of lines in a program
> complain when 6 lines are "wasted" on your screen
>>61301487
A, though the spacing triggers me a bit.
>>61303315
Yeah "special" snowflakes like you should never be let anywhere near any codebase.
if x
then y
else z
>>61302091
i would like to see this actually being used in production
>>61304060
eww, like EWW nigga don't pls!
>>61301487
>>61302091
is this how python was created ?
>>61304199
>end
It's shit
>>61301487
if(nigger = nigger) {
nigger;
}
Masterrace
>>61301487
You only have one line in that code block, bro, and a particularly short one at that.if (nigger == nigger) nigger();
>>61301597
>he can't use monads to collapse nested ifs
A is the superior style in all aspects.
(when (niggerp nigger)
(nigger))
What's the problem?
>>61302181
This one is good for a laugh. I should write a plugin to convert all of my code to it.
>all these pasty white people using nigger left and right
real edgy guys, you're really cool. kendrick the best, amirite?????
>>61301487
Write everything in one line
>>61301487
B for functions, A for everything else.
C when it is more readable.// C
if( nigger == nigger ) nigger();
If the content needs a separate line, it needs a bracket.
>>61304358
You're a pretty cool guy.
>>61304327
>all these niggers thinking that the word nigger is somehow reserved for them
Nothing is sacred and you are faggot for being nigger, faggot.
>>61303265
>>61303288
oh boy, what a dumb faggot...
if is not a macro but a keyword.
also, only pajeet tier programmers write "if("
>>61304401
If you care about this, you must have a great life.
>>61301487
Fucking B
>>61301487nigger();
is enough.
>>61301487
+[------->++<]>.-----.--..--.+++++++++++++.
>>61304262
> assigning nigger to itself
>>61301491
FPBP
A is superior
B is niggerlicious
>>61301603
shut up nigger
Use KNF, as God intented.if (nigger == nigger)
nigger();
>>61301613
C with gcc allows it :P
>>61301487
Superior wayif cond:
func()
>>61304073
Write a program that converts to this form. It's absolutely trivial to write.
>>61301487
if (nigger.stole(iphone)) {
jamal.giveit(back);
}
>>61301487
PHP programmer teaching C reading K&Rif (cond)
{
func();
}
I suferred each time he wrote code on the blackboard. As an autist I always corrected his mistakes when copypasting C, using double scanf() and getch() when getchar() sufficed.
>>61305217
the point is not seeing actual code being formatted this way, but people actually using it for some shit
if (nigger == true) { nigger(); }
orif (nigger == true) { nigger();
pajeet();
jew(); }
>>61301487if (
nigger
)
nigger();
>>61305380
the sad part about this is that I've actually seen code like this
>>61301487
The second one is standard for C#. The first one is standard for Java. I think the first one is also standard for Javascript. It honestly is a matter of standards and you should OBEY STANDARDS whether you like them or not because nobody wants to deal with that one hipster fucking programmer who refuses to obey standards. Nobody wants to hire a dumbfuck like that. Nobody wants to cleanup after such a cunt. Please, I seriously hope you guys don't do this.
Call me retarded, but I strictly use A because if I get lost I can trace back up from the closing bracket to the "if" and see that it clearly closes that "if." Just makes more sense to me.
>>61302181
Delete this!
>>61301582
>whole line wasted.
what are you using a 1MB drive? the extra character takes exactly one byte, there is no reason to jew about it.
>>61301597
>using nested ifs ever
>>61301557
i'll be billing you for the chemotherapy.
>>61301492
lil nigrumps
>>61301487
B is just wasting fucking space!!!
A is the only plausible way.
>>61305471
what fucking cleanup?
>haha i said nigger
>>>/pol/
>>61301557
I propose this:
if(poo==loo){pajeet();}
>>61302181
Triggered!
>>61305598
could just say
if(poo==loo) pajeet();
the correct way isisNigger && kill
>>61305584
triggered nigger.
>>61305471
>>61305583
If someone in a given organization decides to apply their own shitty style to the code, despite the fact that it contradicts the current style-guide, someone has to eventually fix it up due to the inconsistent readability of the code.
The number of posts here suggests that neither really has a substantial advantage.
The only correct answerint
main(int arrgc, char *argv[])
{
if(statement)
do_things();
if(multi_line) {
do_things();
do_other_things();
}
return 0;
}
>>61305584
You sound upset nigger, are you ok?
>>61306528
How do you declare a function that returns an int*?
[spoiler]also, arrays as function arguments are wrong.[/spoiler]
Let's try something different.
>>61308368
the last two dont return anything if the code doesnt return
xddddddddddddddddd
>>61302276
Go away heartbleed
>>61301487
It doesn't fucking matter.
For solo projects, you use the one you prefer, for team projects you use the one the team decided on.
>>61301512
You do realize lines aren't a finite resource right? B is much more pleasing, the blocks of code stand out 10x more because all the brackets line up with each other. There is no choice, B is superior.
>>61301487
Depends on how low level you see it. The second example represents blocks as scopes instead.
>>61308577
qft
>>61308577
Lines ARE a finite source, a new line character still takes up space.
>>61309789
Only as much as a space character.
>>61309806
And?
>>61301487
They are equally awful.
>>61301487
A is superior. Although proper syntax should be
if (nigger == nigger) {
nigger();
}
The only true syntax.
I like A
>>61309915
>the only true syntax
>semicolon tabbed out
pick 1
>>61302962
I would really hate working with this. It just fills your code up with so much fluff. OPs A example will give you much more compressed code.
>>61301487if (nigger)
nigger();
Or better yet, since nigger isn't defined and nigger is obviously "true" in this case:nigger()
but... what if nigger wasn't true?!!?!?!?!??!?!?!?!?!?!?!?!??!?!?!?!?!??!?!?!?!?!??!?!?!??!?!?!?!??!?!!!!!?!?!??!?!(x-files theme song)?!?!?!??!?!?!!!!!!!!!!!!!!!!!!!!
In that case!!!!!!nigger == not_nigger ? /*do nothing*/ : nigger();
>>61304514
AND THEN THERE'S THIS FUCKING GUY.
>>61305184int func() {return 0;}
int main()
{
int cond = 1;
return !cond ?: func();
}
>>61301496
>>61302169
Based K&R
>>61308577
Dude, you have to be careful with your lines. Do you know what happens when you run out? An entire file, on one line.
Can you even imagine?
Can you even get this through your head?
May God have mercy on your soul if you then run out of new files as well. Typing every line of code from a large program into the command line will just destroy your keyboard
And then you'll run out of letters, and have to buy a new keyboard, in addition to the new computer you need to buy.
Why can you doif(true) whew(lad);
but not something likeint whew(int n) lad(n);
Pretty gay i m o.
>>61301487
whichever one is required by the codebase im working in, although I prefer a
>>61301487
First one wastes more lines.
>>61301487
Depends on the programming language
B is for niggers so A.
>>61301487
B is easier to read but every professor/book I've had says to do A
>>61301487
>he really thinks he's gonna be able to format his code however he wants if he ever gets a job
lmao yeah right, even the linux kernel has a code style
>>61301582
>There is no reason to have a whole line wasted on a semi-colon.
lmao what kind of retarded b8
>>61304420
this is the only acceptable answer
>>61301597
>he uses 2 spaces indentation
>>61301687
>lets code javascript
let's not.
>>61301487
Useless thread, now fuck you
>>61305653
Honestly, I prefer this toif (poo == loo)for one liners.
pajeet();
At least it makes it clear that the if block only has one instruction.
B
>>61317393
i think your code has a bug in it
>>61312060
Do you meanint whew(int n) { return lad(n); }
Use a fucking formatter if you find anything you don't like
>>61308577
>the blocks of code stand out 10x more
they stand out just as much and look less clean. You can still lined up your closing bracket with the start of its function, loop, whatever because everything within it is indented correctly
>>61308577
>lines aren't a finite resource
Yes, they objectively are.
>>61303003int main(int argc, char **argv) {
if (foo == bar) {
baz();
}
}
Fixed it further for you.
>>61302091
int main(int argc, char **argv) {
if (foo == bar) baz();
if (foo == tar) {
bez();
} else if (foo = har) {
fuckit();
} else {
ordont();
}
}
Lines matter. The more you have on your screen, the less time you waste scrolling and flipping around. If it is a short single-statement block, one-line it, no braces. If it needs a line, wrap it in braces. Always. No exceptions.
I've been debating collapsing multiple lines of close-braces, just to save *even more* space. It still looks weird enough that I don't do it by habit.
int main(int argc, char **argv) {
if (foo == bar) {
baz();
} else {
fez();
} }
>>61301487 (OP)
This is fine.
This is totally fine.
Except for the part where it calls the nigger function three times, but totally fine.
>>61301491
this, niggas
I like both..
>>61301496
What about classes?
>>61317933int main(int argc, char **argv)
{
return foo != bar ?: baz();
}
>>61318028int main(int argc, char **argv)
{
foo == bar ? baz() : // if foo = bar then baz()
foo == tar ? bez() : // else if foo = tar then bez()
foo == har ? fuckit() : // else if foo = har then fuckit()
ordont(); // else ordont()
}
>>61318295
The ?: ternary operator is the most patrician of operators.
Basically, the only one with which you can actually do compile-time computations with the preprocessor.#define RES_X 640
#define RES_Y 320
#define DEPTH_BITS 8
#define QUOTIENT(a,b) ((a%b==0) ? a/b : (a/b)+1)
#define PITCH_SIZE ((DEPTH_BITS < CHAR_BIT) ? QUOTIENT(RES_X, CHAR_BIT) \
: QUOTIENT(RES_X*DEPTH_BITS, CHAR_BIT))
#define PIXBUF_SIZE (PITCH_SIZE * RES_Y)
(which calculates the size in bytes of a pixmap buffer given resolution and depth)
>>61318383int main(int argc, char **argv)
{
foo == bar ? foo == tar ? foo == har ? baz() : bez() : fuckit() : ordont();
}
>>61318712
Equivalent, but in a different order.foo == bar ? baz() : foo == tar ? bez() : foo == har ? fuckit() : ordont();
vsfoo == bar ? foo == tar ? foo == har ? baz() : bez() : fuckit() : ordont();
It doesn't really fucking matter, it all gets compiled in to bytecode anyway. It's also not like any of you jobless neets work with anyone else on your code so just use whatever you like.
>>61318854
>bytecode
>>61318712
How about emulating if...else blocks with the ternary operator?int main(int argc, char **argv)
{
(foo == bar)
?
(
(foo == tar)
?
(
(foo == har)
?
(
baz()
)
:
(
bez()
)
)
:
(
fuckit()
)
)
:
(
ordont()
);
}
>>61318854
>not caring about style
>b y t e c o d e
get out to your designated shitting street pajeet, i can do that WHILE i'm at work
>>61318903
>my eyes
see
>>61318383
>>61318903
>>61318928
I didn't compile this to see if it works, but I suppose you could do this for multi-line conditionals.int main(int argc, char **argv)
{
foo == bar ? {
bar();
baz();
} : foo == tar {
baz();
} : foo = har {
bez();
baz();
fuckit();
} : {
ordont();
}
}
>>61318985
disgusting
delete this.
B is perfect. You exactly see where the code starts and where it ends. A is horrendeus.
>>61319136
Are you, by any chance... mad, friend?
>>61301582
Why dont you write your code in one line faggot
>>61301487
A.
If you newline everything, you end up wasting way too much space. Mixing is horrible, so just pick A.
>>61301487
I use A for css because I'm lazy, and B for any C-like language because I want that shit to be readable.
>>61301487
>if( condition )
Pure cancer
>>61301487
> whitespace is for the programmer
> muh extra line
B you fucking javascript pajeet shills....Always B
None.
if (nigger == nigger) nigger();
if nigger.IsAlive() { nigger.Execute() }
>>61301582
>a line wasted
surprised you didn't attract more sperglords
>>61301487
I used to be an A anon, but then I started writing way too much C++ code and started using B for functions/classes because I like having an empty line after a declaration anyway.
>>61317715
Yes. But without the curly brackets.
I'm laughing at the trolls and 'programmers' in this here thread.
B is the correct method, A is something you'd see from a college student.
>>61323353
kys
>>61324355
t. First year computer science student
>>61324601
t. grade schooler
>>61324635
t. Sperm cell
B is Industry standard
>>61324659
t. twinkle in daddy's eye
>>61301487
Holy shit, kill yourself.if (nigger == nigger) {
}
OpenBSD KNF is the ONLY style one should use.
>>61324672
t. Space dust
>>61324835
t. quantum bubble existing before the universe itself
>>61301487
>nigger
Fuck off ans back to your containment board
>spaces inside brackets
Go fuck your mom, OP.
>>61301487
It literally doesn't matter if you can't write anything other than fizzbuzz anyway.
>>61302091
Real talk, if I started doing this at my job, would it get me fired?
>>61301613
Yes you can you fucking retard
if(condition==value){function();function2();return NULL;}
>>61301487
B is the only correct answer.
A is for niggers.
B is a lot cleaner and clearer.
>>61301487
I prefer
if(nigger == nigger)
{
nigger();
}
>>61301487
a, but both are wrong to use == ever
#include <stdio.h>
int main(int c,char**v) {
char *s="B+p:ubYBGG0,|M3B=1*0N\n"
"it's touring complete\n",*k[]={s+21,--s};
return c?({while(main(!k,k))putchar(**k^*k[1]-10);0;}):(v[1]++,*++*v);
}
>>61302076
Ruby lel
saged
all code should be saved and shared as ASTs, with the editor imposing your personal preference for reconstruction of said AST as plaintext
>>61301687
>javascript
shiggy
>>61301487
B. Period. In all languages.
>>61301487
B for me bud. It looks more appealing, I think.
>>61301487if (aVar == bVar) {
afunc();
}
>A
>What editor/theme
C:
if (condition) {
}
also,
int
victim()
{
}
tabs all day
looks cleaner and also easier to document
i also hear its slightly faster (by a fraction of a fraction of a second lol)