Public Service Guide to not writing code like a nigger

If you do this:

void function(){
/* ... */
if(){
/* ... */
}
for(i = 0; i < x; i++) a[i] = i;
}


You weren't well taught and appear to be acting like a retard! Let me show you how it's done:

void function()
{
/* ... */
if()
{
/* ... */
}
for(i = 0; i < x; i++)
a[i] = i;
}


Follow proper style you fucking monkeys

Attached: hqdefault.jpg (480x360, 16K)

Other urls found in this thread:

pastebin.com/sTQFMsxY
mangadex.org/title/19278/ikinokore-shachiku-chan
twitter.com/SFWRedditImages

Attached: 1542047021064.jpg (657x1279, 328K)

Well...
What if I AM a nigger? What then?

um, sorry retard, actually its:
```cpp
void function(){/* ... */ if(){ /* ... */}for(i=0;i

void
function (void)
{
if () {
} else if () {
}
for (int i = 0; i < x; i++) {

}
}
Everything else is objectively wrong.

What the fuck were you even trying to do with those accent marks?

Attached: gorillas-selfie.png (540x540, 611K)

Why do you use curly braces on a new line after the function statement but not after if or for?

Reminder op is a retard
void function()
{
/* ... */
if()
{
/* ... */
}
while(a[--x] = x)
;
}

I prefer braces on their own line. That way in cases like below, the braces are consistent. Otherwise it's a bit confusing which is the statement that's run and which is part of the if statement.

if (reallyLongConditional.hasSomeLongValue() &&
reallyLongConditional.hasSomeOtherLongValue())
{
/* ... */
}

// vs

if (reallyLongConditional.hasSomeLongValue() &&
reallyLongConditional.hasSomeOtherLongValue()) {
doSomething();
}

Well done, but that wasn't the point

that's how you tag a codeblock in markdown, the cpp after it was supposed to denote c++ syntax highlighting

thinks he human

Attached: Anyone ever dealt with a chick that's difficult just to be difficult_ _ Page 4 _ Sports, Hip Ho (402x244, 907K)

>You weren't well taught and appear to be acting like a retard!
>writes a default int

ahem!
void
function()
{
/* ... */
if(test) {
/* ... */
}
for (int i = 0; i < n; i++) {
a[i] = i;
}
}

silly redditnigger

Listen to OP.

Here, let me spell it out clear as fuck:

WHEN YOU FUCKING ALIGN THEM IN THE SAME COLUMN IT MAKES THE CODE EASIER TO READ, DEBUG, AND FOLLOW BECAUSE YOU CAN FUCKING SEE WHERE BLOCKS BEGIN AND END A FUCK LOT EASIER. SO FUCKING DO IT, YOU GODDAMN JERKOFFS, AND IF SOME SMARTASS TEACHER/BOSS/OTHER IDIOT TELLS YOU TO DO IT DIFFERENTLY, TELL THEM WHAT I TOLD YOU, AND THERE IS NO OTHER LEGITIMATE WAY TO DO IT.

End of fucking argument and discussion.

OP is a fag and managed to get it exactly backwards.
Well done.

Also, "people" who leave out the braces on for loops should probably just die.

#include

int main()
{
int x=0;
if(x

The only reason why there is brackets and semicolons is that you can put everything on one line.

>reddit
github comments pages and readmes use markdown

Nice infinite loop and complete misunderstanding of printf's syntax

>omitting for loop braces
I would hang you from a tree.

Rate my code? pastebin.com/sTQFMsxY I should have used bitmask in the if statement...

Attached: poll-demo.png (480x782, 35K)

Superior
(define (function)
(when ()
...)
(for ([i (in-range x)])
(vector-set! a i i)))

Why do you even write comments nigger?
If you're going to use a font like that do have stealth comments that no one can read, don't even bother in the first place.

99% of zoomer syntax highligthing themes have this retarded invisible comment crap.

And actually some comments you can avoid
// 3 milli-second timeout

#define POLL_TIMEOUT_MS 3


There, now you don't even need a comment anymore to explain where the 3 comes from, and there is no risk that the comment goes out of sync with the actual value (which could happen if someone does not see your stupid stealth comment).

Also this...

int ERR = ERRno
STDERR ERR ERR STRERROR ERR

Thanks for the comment above this code to remind me that it's error handling, i would have had no clue otherwise.

Comments are for explaining non-obvious stuff.

Good points.

I unironically used to write the 2nd way when I learned how to program until I copied my teachers who were writing the 1st way.

I didn't understand what you just said.

all our indian coders think they get paid by the line so their code ends up looking like a fucking shel silverstien poem but also everything is shitty and wrong. god damn diploma mills.

silly githubnigger

It just looks weird in languages that use begin/end instead

if(a == 16'd1)
begin
end

this thread just convinced me I'm too retarded for this major and should switch to chemistry or just live on a farm as a hermit until I kill myself

/**
@Name: John Smith
@Date: 04/22/2019
@Time: 14:32
@Revision: 2
*/
void function()
{
/**
Comment
*/
if()
{
/**
Comment
*/
}
for(i = 0; i < x; i++)
{
a[i] = i;
}
}

The point of the comment is you don't even have to look at that block if you don't care about error handling. Maybe a bit much given it's only 3 LOC, but for larger pieces of code, that sort of thing is nice.

style guide you faggot

comply with the project's formatting guide instead of being a flaming faggot

>redditmark

Different languages do it differently. Follow the coding convention of the current using language.

#define begin {
#define then {
#define do {
#define end }
#define

If you don't enclose all if bodies with braces, you have already lost

In the case of one-liners, I find
if (cond) inst;
less error prone than
if (cond)
inst;

while still being less of a waste than using braces. Line break and braces for multi-line block.

Braces are quickly added while writing the if statement, but an annoyance if you want to add a second statement later on.
But yeah, if you insist on not using braces, go for one line.

Damn
That isn't how I was taught
I feel like a fool

Markdown is a thing that exists by itself outside of any websites. Markdown nigger would be appropriate, but there really is nothing wrong with markdown.

>no closing tag for the foor loop
>trying to define

won't #define do { fuck up with do ... while?

Maybe you should use these macros?
#define IF if(
#define THEN ){
#define ELSE } else {
#define ELIF } else if (
#define FI ;}

#define BEGIN {
#define END }
#define SWITCH switch(
#define IN ){
#define ENDSW }
#define FOR for(
#define WHILE while(
#define DO ){
#define OD ;}
#define REP do{
#define PER }while(
#define DONE );
#define LOOP for(;;){
#define POOL }

This looks like a good set of preprocessor definitions but I feel that putting a gun to your head and pulling trigger will do a better job.

There is no style in writing C.

>a[--x] = x
that's undefined behaviour, son. read up on sequence points.

#+BEGIN_SRC C++
void function()
{
/* ... */
if() {
/* ... */
}
for(i = 0; i < x; i++) {
a[i] = i;
}
}
#+END_SRC

Actually, the objectively superior style is
void function()
{
/* ... */
if()
{ /* ... */
}
for(i = 0; i < x; i++)
{ a[i] = i;
}
}

Source?

This doesn't loop at all. It is wrong on many levels.

Both of those are fucking disgusting.

int fuckyou(virginOP, chadMe){
int toreddit = 1
if(virginOP < chadMe){ //always resolves to true
toreddit = gay()
}
for(int fag = 0; i < 10; i++){
toreddit = niggers()
}
return toreddit;
}

The absolute pajeet coder.

You're fired

FRIENDLY REMINDER: SOFTWARE ANTI-PATTERNS ARE YOUR FRIENDS, NOT YOUR ENEMIES. IF YOU'RE THE ONLY PERSON WHO CAN READ YOUR OBSCURE AND OBFUSCATED NESTED RECURSIVE FUNCTIONS, THEN YOU ARE MUCH MORE SAFE-GUARDED AGAINST DOWNSIZING AND LAY-OFFS BECAUSE YOU'RE THE ONLY PERSON HO UNDERSTANDS THE CODEBASE.

CLEAN CODE === EASILY REPLACED EMPLOYEE

undeniably based and red pilled

Genius line of thinking actually. Clean code makes you interchangeable as they're likely to perceive you as just another Programmer Worker Unit. I will remember this.

Attached: 1495688498031.png (582x847, 1.04M)

No, tcl requires that the opening brace appear on the first line (unless you use \), so one should do the same in C as well. Also, whitespace is a meme for people who can't code to feel accomplished via style points. Train yourself to see in phrases and delimiters, not character by character.

You only think that because you were told that. It's not true at all.

You're not doing it right either, and you look like a fucking retard.
Here, let me fix that for you.
void function() {
// ...
if () {
// ...
}

for (size_t i = 0; i < x; i++) {
a[i] = i;
}
}

not a loop at all, just an if() statement

nothing wrong with the printf syntax

$ gcc -o g g.c
$ ./g
x is 0

Imagine unironically caring this much about what line someone puts an opening bracket on

>putting { on next line
People like you must die
It makes code unreadable

This

Egyptian braces for all things.

Stroustrup go home

Those gorillas are based

If you coded like this my professor would literally fail you with 0 points until you learned to not be a gorilla nigger.

#include
void main()
{
int x=1;
while(x

How the fuck does that loop

Move aside, plebeians.
void function()
{
int i;
/* ... */
if()
/* ... */
for(i = 0; i < ; i++)
a[i] = i;
}

>Using for loops without braces
Yeah nah

#include

void function();

int main()
{
if (/* ... */)
{
/* ... */
}
return 0;
}

void function()
{
/* do shit */
}

You are a disgusting Cfag that can't even do K&R right

void function(){
/* ... */
Boolean isTrue = true;
String trueStr = "true";
int counter = 0;
for(char i: Boolean.toString(cond).toCharArray()){
if(i != trueStr.charAt(counter)){
isTrue = false;
}
counter++;
}
if(Boolean.toString(isTrue).equals("true")){
/* ... */
}
for(i = 0; i < x; i++){
a[i] = i;
}
}

lel, that would throw an error while parsing bc you made a mistake because of
(inhale)
YOUR SHITTY CODE YOU LARPER

thats dumb

there is a manga on coding ?

>wah wah make it easy for my retard brain to read
How about you git gud?

I'm following the PSR-1 et PSR-2

It's not about programming but that's a real page.
mangadex.org/title/19278/ikinokore-shachiku-chan

Looks right to me
1. x = x - 1
2. a[x] = x
3. a[x] != 0
Where is behavior undefined?

Nevermind user, you are based and redpilled

It is you who is the nigger

Attached: 1553041369973.jpg (499x501, 44K)

>using languages with braces

mfw

int
main(int argc, char *argv[])
{
/* Always return true */
if(op == faggot) {
call_function_a();
call_function_b();
}

return 0;
}

/* never return true */
/* true fags are gay and should die */
return 1;

Attached: 1533288445345.jpg (853x480, 58K)

This. Braces on their own lines. Death to everyone else