Programming class

>programming class
>doing an assingment
>show it to the teacher
>says that my formatting is bad
>PROCEEDS TO MAKE MY BEAUTIFULLY BRACKETED AND FORMATTED CODE LOOK LIKE SPAGHETTI
>finishes and says here it looks simpler
>mfw

Attached: 1536571439538.gif (828x828, 1.09M)

Show it.

This is just an example of mine
int main()
{
int n;
for(blahblahblah)
{
int thisisafuckingexample;
}
return 0;
}

You're indenting the for loop too much, you do it correctly after int main

Why on earth is return line unindented?

Let me guess, you're taking CS 101? Nobody gives a shit how "pretty" you make your code look you idiot, only if it's readable

I'm on a phone right now

>allman braces

plz no

is this a troll post?
disgusting

int main() {
int n;
for(blahblahblah) {
int thisisafuckingexample;
}
return 0;
}

fixed

In any serious project there will be an agreed upon standard format you have to adhere to. It doesn't matter much what the formatting is, just that everyone does it the same way.

jesus christ, what is wrong with you?

Doesn't even fit on the screen you fucken retard

Attached: Screenshot_Waterfox_20181015-090842.png (480x800, 71K)

post before and after or it didn't happen faggot.
also that's shitty formatting.

None of the projects in college are serious outside of the grade you get

Jesus I didn't even notice this. That is fucking awful and your professor should've failed your bitch ass

int main()
{
int n;
for(blahblahblah) int thisisafuckingexample;
for(fuckfuckfuck) int fuckyou;
//and it goes on
return 0;
}

That's horrible. He's right.

int main()
{ //good
int n;
for (blahblahblah) { //like this you tard
int thisisafuckingexample;
}
return 0; //this stays indented
}
[\code]

It was unindented because I'm on my phone and forgot to indent it

forgive the wrong slash, I've been writing latex for the last 14 hours

>not newlining the next statement in a for loop
>not bracketing the body of a for loop
absolutely disgusting

that's largely inconsequential compared to your disgusting bracketing style for your for loop

there should be spaces after the // and before the comments

Sure thing faggot

No offense but you seem mentally deranged and your teacher is probably correct.

normally I don't comment on the same line like that either

Once you hit the industry, you'll start to see way shitty code. Get used to seeing shitty code, you're going to run into a ton of it. I don't even think I code that great honestly but there's just some objectively bad coders out there with jobs.

int main(){
int n;
for(blahblahblah){
int thisisaexample;
}
return 0;
}

This the proper way too do it.

Doing the lord's work.

int main(){
int n;
for(blahblahblah){
int thisisafuckingexample;
}
return 0;

What do you anons think of this?
There should be consistency between tabs or spaces when the line begins
If you slap a space before every line inside main, the you should put 2 before each line inside a for or if, because then it's under two open bracets
It's much easier to tell with a glance which lines of code belong to what functions

this is how I would do it

>CS isn't a meme

Attached: 1538610240862.jpg (362x314, 24K)

Not OP and not trying to defend him but you realize you can stretch the posting area, right?

No you can't

I think you should try using the code tags. They go in square brackets instead of angle brackets, similar to html. Without them you won't be able to indent anything.

Jesus Christ, use the fucking [.code.][./code.]

Sorry, never posted code here before

int main(){
int n;
for(blahblahblah){
int thisisafuckingexample;
}
return 0;
}


This is what I meant

Ok, thats not it, i put an extra space before
int thisisafuckingexample;
Jow Forums deleted it

holy fuck OP. i looked at all these posts, and, as a Jow Forumsiant fa/g/g/ot, i can tell you that you are the problem, it is definitely not your instructor.

sorry for the pun, but, "simpler" can "simply" mean standardized, which you clearly don't understand.


shitty formatting that everyone uses is better than "your own good" formatting.

my only nitpick is that 2 spaces is the bar minimum for an indent, 4 is my personal ideal, and 8 is fairly standard.

Fuck this garbage use \t like god intended

I personally use tab, just wanted to play along spacefags whos example I butchered

>not lining up your brackets vertically
I would hate to see any nested code you wrote

While I know in my brain that tabs are eternally superior to spaces, I can never bring myself to use them. I can't think of one actual reason not to either, other than to impose my indentaion width view on everyone who reviews and edits my code.

Shit I didn't know there are so many formatting option on a messege board
Let me try this
int main(){
\t int n;
\t for(blahblahblah){
\t \t int thisisafuckingexample;
\t }
\t return 0;
}

Hope it doesnt have a bunch of t's cause I'm a brainlet

Nah dude, OTBS. Makes grep/sed easier.

// this is a test of copying and pasting with tabs

I personally prefer a little more encapsulation:
int main()
{ goto MAIN;
RETURN:
return 0;
MAIN:
int n;
for(blahblahblah) {
int thisisafuckingexample;
}
goto RETURN;
}
Professors love it because ever since "goto considered harmful" misinformation, people have been too scared to use it even when perfectly applicable, and they see you're not just a parrot regurgitating misinfo.

More like they don't give a shit and don't even bother to read your code at all, only if it weks

pretending for a moment that the compiler didn't rearrange that code for you, what is the purpose of having 2 completely unnecessary jumps?

Trying to trigger Jow Forums tryhards.

2/10 troll harder.

What is the purpose of having a for loop, which is just a glorified goto statement? Unroll all of your loops.

You can actually gain performance by partially unrolling loops, otherwise it is nice syntactic sugar which carries a lot of meaning for other people reviewing your code. You could absolutely use a GOTO instead of for, but then you're just being a dick to everyone else.

int main() {
// Where are your comments? I can't read this shit.
int n;

for(blahblahblah) {
int thisisafuckingexample;
}

return 0;
}


My style. Your style is absolute trash. You move your brackets around so much that it's hard to track the execution.

22 of you arguing where to put a bracket

Sounds like you're unemployed lel

professor is write, you disgust me

We write code so others can read it and understand it the first time. Things like bracket placement, code comments, and indent spacing matter.
>inb4 indent spacing is retarded
You've clearly never written anything in Python before.

ok this is worse

I was taught that if you had a loop with a single line then you just put that on the next line and indent it.
Indenting was always 3 spaces, too.
As for brackets, it was:

while(condition)
{
code
goes here
}
//this is how you do this
//because
while(condition) {
code
goes here
}
//doing this is utter cancer

Allman style braces can diaf

That's way too much indenting, user. Especially the brackets.
You should do it like this.
int main()
{
int n;
for(blahblahblah)
{
int thisisafuckingexample;
}
return 0;
}

Attached: no u.png (500x750, 172K)

I use goto all the time to implement primitive coroutines. I particularly enjoy switch-jumping into the middle of my loops. Here's an example program:
#include
#include

#define for_(I) while ((I =
#define _in_(F) F) != STOP_ITERATION)
#define STOP_ITERATION -1

int range(int limit)
{
static int i, state = 0;
switch (state) {
case 0: for (state = 1, i = 0; i < limit; i++) {
return i;
case 1: ;}
}
state = 0;
return STOP_ITERATION;
}

int main(int argc, char **argv)
{
int j, i, limit;

for (j = 1; j < argc; j++) {
limit = atoi(argv[j]);
for_(i)_in_(range(limit))
printf("%d ", i);
putchar('\n');
}
return 0;
}

$ ./a.out 5 10
0 1 2 3 4
0 1 2 3 4 5 6 7 8 9

It looks like too much indenting because I wrote this post on a phone and it looks different when replying and the post itself

>unironically using GNU style
KILL
YOURSELF

GNU style is comfy

Start ptogramming in ladder op.

It is supposed to be fubar.

Also it is easy to make half assed work arounds on it, without that being your intention.

[CODE]
retard
[/CODE]

absolutely patrician

>go fmt -w=true *.go

Attached: GOPHER_MIC_DROP[1].png (1991x2154, 223K)

My eyes thank you.

Not an issue, as long as you indent (and if you don't it'll look shit anyway). Wasting a line just for a bracket is bad enough, let alone two.

Allman style is the reddit spacing of programming.

Attached: duck.jpg (665x387, 28K)

haha, good thread OP. GNU style was a mistake

indent file.c -o file2.c

let arr = [1,2,3,5,4];
let varThatIsAFunction = function((x,i) => {
console.log("Hey there's a value here in position " + i + ": " + v );
});
let output = arr.map((elem)=>elem*elem).reduce((acc,add)=>{ return acc + add + Math.floor(Math.random() * Math.floor(add)); });
arr.forEach(varThatIsAFunction);

console.log("python sucks");

>loop content on the same line as the loop header
absolutely disgusting

Good job

almost perfect but put a space between ) and {

Doesn't help that your DPI is so incredibly low

Python is alright user, but you're right, JavaScript rocks!
By the way, you should consider using `template ${strings}`

I was just trying to piss someone off.

console.log("Hey there's a value here in position $i : $v" );


like this?

`position ${i} : ${v}`

Garbage.

Patrician

int main()
{
int n;

while(foo)
bar();

while(foo2)
{
bar2();
}

return 0;
}

bar() and bar2() are supposed to be indented, Jow Forums is too retarded for 2 tabs in a row

>brackets
for me it's begin and end

Attached: 1511943750797.jpg (600x551, 60K)

int
main(int argc, char *argv[])
{
int n;
for(blahblahblah) {
int thisisablah;
// another line
}

return 0;
}
[\code]

ftfy, no need to thank me

[.code.]
CODE
[./code]