Sup Forums /btfo/

Sup Forums /btfo/

Other urls found in this thread:

youtube.com/watch?v=HvYjApa01bk
github.com/id-Software/Quake-III-Arena/blob/master/code/game/q_math.c#L552
twitter.com/NSFWRedditVideo

Stallman, plz go.

...

>I code like the pic on the right
Maybe this tranny comp sci meme has some grounds. I don't understand why other guys have to make their code so ugly and illegible.

> comparing fast inverse square root to a bloated max
triggered so fucking bad

Isn't that code on the right John Carmack's code for Doom?

> if (a > b && b < a)
> women coders

>if A is greater than B and B is less than A

Confirmed retarded.

girls actually coding.... MUAHAHAHAHAHAHA
no

>max(2, 2)
>returns 5

This must be satire , r-right?.

that roastie whore is useless at """"""""""""""programming""""""""""""""
let me explain the difference between the two examples
her "code" is retarded
the first if statement is decent, it returns b if b is larger than a
else if statement does one redundant comparison, but in the end returns a if it is larger.
THE FUCKING FUNCTION RETURNS 5 IF a = b WHAT THE FUCK

now the leftfunction is an elegant implementation of a fast inverse square root function i.e. 1/sqrt(x)
the number 0x5f3759df is a real marvel in 32-bit computer science

she is literally stating that guys are better programmers than girls

Just make indentations and put concise comments it's enough. You're not supposed to comment every fucking line, only the complicated ones

looks like babbys first code. Good that your past "hello world" and on lesson 2

The code on the left is

die

>2 Planes are at 20,000 feet
>Which altitude is higher?
>5
>Both planes crash when they reduce their altitude to -995 feet

at least men aren't writing plane code

I meant left I'm just retarded

No matter how many times I see this image i still get mad

I've been taking an intro comp science class for less than two months and even I can tell she's retarded

The worse thing is that you didn't recognize that those are two wildly different problems being implemented and that the right code is tidy but contains more bullshit than that.
Writing tidy isn't the problem, writing SHIT is.

the right code returns you the greater number of 2 OR the number 5 because lolsorandumb which can be shortened into 2 lines of code

the left code calculates the square root of a number and I have no idea how it works but it works and it's a smart and short implementation

whoever coded the right couldn't even begin to code the left

>code on the left

Uncommented magic number bullshit

>code on the right

Non functional and utterly retarded

I mean obviously left is superior because it works, but praising left requires some seriously low standards.

im glad u can sort numbers senpai

youtube.com/watch?v=HvYjApa01bk

>but praising left requires some seriously low standards.
>it works
>comments wouldn't even explain it anyway
>low standards

u wot m8

But it's not even returning an array of the same type.

Code that works and has comments is objectively better than code that works and doesn't have comments.

Code that makes no sense to the casual observer and has no comments either is just bad.

i pretty sure the code on the left is a function from doom, its well known to be a "magic function", its works, don't touch it!

the code on the right is a fucking joke.
comments like this are USLESS.

> author
don't care

> this a function
no shit, guess thats why you called it max

> ^__^
yeah no!

> this function returns an int
no shit i can see that

> an int is a number without a decimal
i know, why are you telling me. its like your impressed you've remembered the most basic fact of programming.

> fucked up indentation
ffs, go python somewhere else!

> returns ...
all these comments say EXACTLY what the code does, it adds NO VALUE.

> this is the end ...
this is the point this bitch would get fired.

> see you guys later!
like she's proud of her work.

> see you guys later!
No you wont!

int max(int a, int b){
return a > b ? a : b;
}

>objectively better
only the person who writes it ever looks at it, the compiler literally skips it
and if your a retard let me again state: COMMENTS FOR THE QUICK ROOT METHOD WOULD NOT EXPLAIN IT

This really barbeques my burgers.

>KKK1Germany
Sorry for admiring my own id.

This actually triggered me.
I hope it's just a joke.

>code by girls
>very first thing is "hi it's me I made this! ^_^"
checks out

I envy you having a job where no one ever looks at your code except for you. Unfortunately in larger projects it is almost guaranteed that your code is going to be seen by a dozen people and you're going to get really sick of listening to people chew you out for not commenting your shit.

Even a single line comment that says the function is calculates the square root is superior to fucking nothing.

I don't see why that code is so praised, the guy just used a bit operation with some number that he probably found with an error minimizing alogrithm. Its not like theres some ultra mathematic wizardly reason behind it.

here is red pill fan boy.

COMMENTS ARE BULLSHIT

they are for low tier programmers to fuddle along.
If you can't read code, i don't want you anywhere near my code.

GET FUCKED.

if you need this:
// assigns b plus 5 to a
a = b + 5;

YOU are the retard!

>
Code that makes no sense to the casual observer and has no comments either is just bad.
its not comments that make code readable it a mixture of things, but mainly the language its self. perl is garbage for being able to read what the code actually does.

i write code objectively faster than when i bloat it with comments and i can still understand. i don't need anyone else to understand it anyways so fuck nah.

comments are for people who can't give their variables/functions proper names

like what's the use of this

//sorts shit
void sortnshit(int[] array)
{
}

nigga i write self explanatory code its easy, although.

and if it's ever not self explanatory, eh fuck it nigga i don't care

> nu/pol/ is infested with first year state uni comp sci code monkey wanna faggots
This place literally gets worse every day

why use variable threehalfs? it's only used once, just type 1.5f

It's code from Doom iirc, Doom was pretty much one of the founding fathers of the FPS genre, so it's natural that a lot of people would praise the code especially when it is beside babbies second code in middle school girls empowerment coding class

>not including the GPL stub and your name at the top of all your files and documentation

It's like you want your code to be stolen.

Comments are also stripped by the compiler, it's not like they can do any harm. They're also good for newbies who forget things, which obviously describes this woman.

Your code today should not need comments. It should be self explanatory through a naming scheme. So yes, the code on the left is bad, but if you are still sperging by commenting on the whole code, you are cluttering up your work.

>>if you need this:
>// assigns b plus 5 to a
>a = b + 5;

I love how you take the extreme case and pretend like that's what I'm asking for. a=b+5 is an example of something that IS obvious to a casual observer and doesn't need comments. If a single line of comments for something that isn't obvious is really too much for you to handle you need to stop writing code forever.

kek

>Has never worked in software

In large systems, you'll have low level code that does so much shit or is so obfuscated because of how generic it needs to be that without comments it's impossible to discern what's going on without hours of study.

Shit like javadoc is still pretty helpful.

not sure but maybe:

> const
compiler will put it in data segment and refer to it with an offset instead of doing "load literal to register". maybe first is faster.

> (a+b)(a-b) = b(a-b)
> a+b = b
(a - b) = 0, so dividing by (a-b) is undefined

Code on the left is John Carmack's fast inverse square root. That is literally code that made graphics like we saw in Quake possible.

I'm pretty sure it's Quake III

JavaDoc and other documentation standards are amazing for libraries and frameworks.

If you had to learn the intricacies of how an ExecutorService works by examining the source code; you'd never get anything done.

>he thinks well commented code makes you a better coder

This
see my take

The problem with this is that they're assuming that the non "alternative values" are the correct ones

Can confirm. My sister was bragging about how she learned SQL statements at work and how she learnt to write code. She was writing some code to find the largest number in a set of results and after some of my guidance, pretty much fixing all her dumb logic, her code looked like that.

To be fair, the code on the left actually did have comments

github.com/id-Software/Quake-III-Arena/blob/master/code/game/q_math.c#L552

// What the fuck?

Both go in the text segment. There's no need for it to be a const.

The compiler will place the value directly in as a fixed number when the code is optimized.

I suppose it was written as a const to later allow for higher accuracy using doubles? I don't know. It's odd for sure.

I don't know the syntax and haven't coded in a while but I'm pretty sure that whole block on the right could be written something like this:

int max(int a,int b){
a > b && return a;
b > a && return b;
}

THIS TRIGGERED ME

H A R D
A
R
D

checked

>Syntax is wrong and it doesn't handle case where a==b.
return a >= b ? a : b;

>C instead C++
I mean I get that people want to start with the original stuff but I think they really GIMP themselves by not starting with C++ and learning backwards.

return (a > b) ? a : ((b == a) ? 5 : b);

int max(int a, int b){return a>b?a:b;}
>= and > produce the same result in this case

lol

Anyone got the one where a "female programmer" tries to write a function that multiplies two numbers without the * operator?

>They're also good for newbies who forget things

^_^
;D
!
:D
XD

check mine, its better ;)

yours:
> a >= b ? a : b;
mine:
> a > b ? a : b;

max of 2 numbers just needs to check if a > b, otherwise just return b, if they are equal you get the answer you wanted.

both work exactly the same, mine is 1 character sorter, i win :D

Adding comments on every line is a waster of time tbqhwufam. Just add comments before different parts of the code describing what they do and it's okay.
At least I never had any problems with it that way.

True

Better to use b < a ? a : b;

since most processors are optimized for Set Less Than.

See
Mine is more efficient.

> a > b && return a;

pls don't code like this.
its so obvously needs an if statement, daisy chaining expressions IS a sure fire way to get confusing code.

> A += 5 && B = A + 17 && func(A, B) || foo(A);
kys

Create guy code. Write 100 lines of code in the time it takes girl to create 25 lines of girl code.
Then watch girl cry about gender pay gap.

More code =/= better code

It's usually the opposite.

>Comments are also stripped by the compiler, it's not like they can do any harm. They're also good for newbies who forget things, which obviously describes this woman.
Anyone who comments code like that should be shot... the point is not to describe the operations in English. The point is to explain why you're doing certain operations when it's non-trivial.

At least we can all agree people who use hanging curly braces should be gassed

this thread is now about code etiquette

>a>b?a:b;
Mine is 6 characters shorter than yours.

More code is usually better when working on deadlines.

Depends on the language and the popularized conventions.

I personally think

if (clause) {

}

Is superior.

everything on a single line

Sure, whatever you say Pajeet Singh.

i prefer quicksort. it's a nice algorithm.

Is there something more computationally efficient than the obvious:

int max(int a,int b)
{
if (a>b)
return a;
else
return b;
} ?

Thanks anons, forgot about the conditional operator. Haven't coded in years.
Who gives a shit if the code is confusing, it's a convenience of life function. You make it once and never have to read it again.

> Comments are also stripped by the compiler
> it's not like they can do any harm

they slow down compilation massively.

your ignoring the biggest problem with comments.
they need updating too!
your literally multiplying your work load for no reason.

comments that are wrong are worse than no comment at all.

if you think:
> oh i know whats going on here
just from reading the comments, i'll say again STAY AWAY FROM MY CODE!

you CANNOT know more than exactly what your code is doing. this can ONLY be done by reading the code.

Comments suffer from bit rot too.
Nobody goes back to fix comments, whole chunks of your code base that is not tested.
This has gotten so bad, some silly cunts are writing units tests for comments.

JUST LEARN THE LANGUAGE YOU FUCKS

>fuck with your coworkers by running a script to turn all your newlines into other whitespace, before committing any code to the hub

Love how carmack's code had it's comments removed.

>since most processors are optimized for Set Less Than.
Such micro-optimizations make no difference whatsoever. The compiler for the target platform has an optimizer which knows better than you do when it comes to those things. Anyone who tries to structure C code around the instruction set of "most processors" is defeating the purpose of using C and should be shot.

just used a compressed if statement
value = number < 0 ? 0 : 1

PleaseKillMe EndMyLife = new PleaseKillMe(class GunFinder extends EndMySuffering implements EternalSilence {
@Override
public BulletToTheBrain endItAll(Guns

Computationally efficient for something so trivial is such a complete waste of time. Even wasting the time to type out your question is using more time that the computer would have used to compute that line of code in total during the entire lifetime of your program.

Computer time is cheap, programmer time is not, so don't sweat the small stuff.

Fuck off.

I'm sorry that free speech hurts your agenda. (Wait, I'm not.)

i'm not a big commenter myself, but how in the world would they slow down compilation by any significant degree? bullshit.

> 0/0 is undefined

>they slow down compilation massively.
You're making shit up.

terrible isn't it? i'd do manual labor before getting involved with some horrid OOP mess

>comments slow down compilation massively.

I wasn't sure before, but now I'm certain. You are a retard.

>Writes loops as

for (int x = 0; x < MAX; x++);

instead of

for (int x = 0; x < MAX; ++x);

It's like you don't even know how to write optimized code.

let me ask you this then.

who are you writing comments for?
if you answer anyone but, yourself, your a fool.

how am i suppose to know how much others do not?

you say my example is trivial and yet the womens code above does exactly that, state the obvious.

> returns a if a is greater than b
> if (a > b){
> return a;
> }


if you:
> pick correct descriptive names
> structure your program correctly
> DON'T go fucking nuts on OOP or any other programming ideology
> use nice readable constant syntax
you don't need comments. and others won't who read your code.

if i ever comment its more like
// @Fixme
// @Hack
etc.... more like flagging code i can search for later.

i honestly can't think of much that would ever need comments.

admittedly c++ is getting to the point its unreadable code, but comments WONT fix this.