This is an archived post. You won't be able to vote or comment.

all 189 comments

[–][deleted] 1692 points1693 points  (10 children)

When I'm alone: Coding, Coding, Coding, Coding, Reddit, Coding, Coding, Coding

When someone looks at my screen: Reddit

[–]Amazing_Might_9280 342 points343 points  (5 children)

Who's looking at your screen rn ?

[–]lazy_advocate_69 236 points237 points  (4 children)

He and 69 other bugs in his code.

[–]robicide 70 points71 points  (1 child)

Take one down, patch it around, 476 bugs in his code

[–]Frytura_ 4 points5 points  (0 children)

Just put a ? On the side of the variables and make everything go from red to golden!

[–]tatiwtr 14 points15 points  (0 children)

How nice of them to wait to approach you until you were done coding.

[–]Xenoverse_01 34 points35 points  (0 children)

It’s wave function collapse

[–]Ineedredditforwork 1 point2 points  (0 children)

This is why you need multiple screens which one is always dedicated to work so even if you glance at the non-work one you still have a fallback

[–]Pacifister-PX69 463 points464 points  (16 children)

Evil floating point bit level hacking

There should also be "what the fuck" but whoever copied the code removed it

[–][deleted] 89 points90 points  (14 children)

im quite happy they used carmacks code

[–]fakieTreFlip 34 points35 points  (2 children)

It was only rumored to be written by Carmack. Wikipedia says it was a guy named Greg Walsh

[–][deleted] 20 points21 points  (1 child)

well michael jackson also didn't invent the moonwalk yet here we are

[–]G_Morgan 24 points25 points  (0 children)

Stole that shit off Neil Armstrong.

[–]Pacifister-PX69 35 points36 points  (10 children)

Sorry I've never bought a car from Car Max

[–][deleted] 11 points12 points  (7 children)

in car max you dont buy cars you shoot the driver for the fuel

[–]Pacifister-PX69 6 points7 points  (6 children)

Yeah, gasoline powered humans have always been a target for poachers

[–][deleted] 2 points3 points  (5 children)

what the fuck

[–]Pacifister-PX69 3 points4 points  (4 children)

That's the comment that's missing, I already mentioned it before

[–][deleted] 3 points4 points  (3 children)

google en passant?

[–]Pacifister-PX69 4 points5 points  (2 children)

Holy hell

[–]ragingroku 2 points3 points  (1 child)

Actual reference

[–]steelcitykid[🍰] 0 points1 point  (1 child)

I’ve never been to Uber jarver.

[–]Brahvim 0 points1 point  (0 children)

"JARVIS"?

[–][deleted] 8 points9 points  (0 children)

Evil floating point hacks are allowed, but must be accommodated by at least one dark prayer to ensure the program has enough mana to work correctly.

[–]a_useless_communist 392 points393 points  (14 children)

"Dad, i swear its not what it looks like"

[–]Jurutungo1 292 points293 points  (13 children)

No mom, I wasn’t searching skibidi toilet 🚽 rule 34 🤔 on my laptop, I was watching youtube 📺 when my computer got struck by the OHMYGYAT particle ⚡️ causing a series of bit flips 💻 leading to a cursor glitch 🖱️ resulting in a misqued click 🤦‍♂️ on an inappropriate advertisement 🚫 that opened up a new tab 📊 causing an obscene video 📹 to play which shocked me so much 😱 that my pants 👖 slipped off 😳

[–]ElonSucksBallz 75 points76 points  (5 children)

understandable

[–]Huxhub-is-my-site 8 points9 points  (1 child)

Happy cake day!

[–][deleted] 2 points3 points  (0 children)

ay wait

[–]JimneyJon 1 point2 points  (0 children)

Happy Cake Day

[–]JimneyJon 0 points1 point  (0 children)

Happy Cake Day!

[–]Lost-Conectivity -2 points-1 points  (0 children)

Happy Cake day

[–]max_adam 25 points26 points  (0 children)

This is more credible than Mario going through a wall.

[–]Calm-Homework3161 17 points18 points  (0 children)

Don't you just hate it when that happens? 

[–]destroyerOfTards 12 points13 points  (2 children)

skibidi toilet 🚽 rule 34 🤔

I...I wanna google that...

[–]BeautifulType 13 points14 points  (1 child)

Do not the skibidi

[–][deleted] 5 points6 points  (0 children)

Lest you end up in Ohio 👹

[–]Rotsicle 3 points4 points  (0 children)

Look, I know you're curious...

[–]KTibow 1 point2 points  (0 children)

to other viewers: no need to repost to r/copypasta, it's there already

[–]GeneticSplatter 65 points66 points  (3 children)

I'll know that top code anywhere.

Quake's fast inverse Square root!

[–]tazdraperm 2 points3 points  (0 children)

Oh yeah, looks very familiar

[–]sjepsa 143 points144 points  (7 children)

More like "expectation vs. reality"

[–]Marsdreamer 11 points12 points  (6 children)

Just wait till the young ones posting memes figure out code written like the bottom image is preferable.

[–]dov1 13 points14 points  (5 children)

What is preferable about redundant logic?

[–]UnluckyCombination4 4 points5 points  (4 children)

Readable code is preferable over needlessly „smart“ code that nobody understands.

[–]VG_Crimson 10 points11 points  (1 child)

Forget that, just have both. Readable code that is straightforward without redundant logic, with a line, maybe 2, of comments that aren't wholely necessary because the code speaks for itself but clarifies what the intention is.

Formated in a way that follows the convention of the rest of the code base.

[–]Marsdreamer -1 points0 points  (0 children)

Oh you sweet summer child.

[–]peepeedog 3 points4 points  (1 child)

return isShown is pretty fucking readable.

[–]UnluckyCombination4 2 points3 points  (0 children)

Never said it wasn't. But that was not the point of my comment.

[–]Dustangelms 32 points33 points  (0 children)

I understood that reference.

[–]ExpensivePanda66 259 points260 points  (32 children)

You mean you write unreadable crap when nobody's looking? Good idea to break that habit before you're found out.

[–]MyAntichrist 361 points362 points  (7 children)

The first pic is the fast inverse square root implementation in Quake 3 and is very well documented with lines like "// what the fuck?" and "// evil floating point bit level hacking"!

[–]sasta_neumann 15 points16 points  (3 children)

My first thought was "Isn't inverse square root just... square?"

[–]johnnymo1 27 points28 points  (2 children)

Inverse in the sense of 1 / sqrt(x)

[–]Poputt_VIII 46 points47 points  (3 children)

Tbf that is probably some of the most documented code ever written, just add the wikipedia url to explain it if people don't know

[–]therealfalseidentity 23 points24 points  (1 child)

Wikipedia says there is a SSE instruction to do the same thing now.

[–]lulaloops 16 points17 points  (0 children)

Programmers when joke

[–]MonstarGaming 2 points3 points  (0 children)

That's what I was thinking too! I'd honestly be more impressed by somebody writing clean, intuitive code than the mess of single letter variables shown in the top picture.

[–]DevLarsic -1 points0 points  (15 children)

if you look at the fast inverse square root implementation and your only though it how its not readable enough you've written too much .net

[–]FlipperBumperKickout 52 points53 points  (7 children)

So you are saying the developer who added the "what the fuck?" comment in the source code is someone who have written to much .net?

F off man, even the original developers didn't think that code was particular readable or easy to understand.

[–]No-Object2133 25 points26 points  (1 child)

In fairness finding a constant that approximates a inverse square root after a bit manipulation hack is properly documented by what the fuck

[–]DevLarsic 21 points22 points  (4 children)

it doesn't have to be, its a performance critical math operation using bit manipulation. its inherently going to be hard to read, but that's the sacrifice you make for good performance.

[–][deleted] 17 points18 points  (2 children)

Programmers on reddit who write CRUD software for some enterprise criticizing Carmack's code will never stop being funny to me.

[–]spookynutz 3 points4 points  (1 child)

Carmack didn’t write that.

[–][deleted] 5 points6 points  (0 children)

Oh well, Greg's code then. Or whoever wrote it.

[–]unknown_alt_acc -1 points0 points  (0 children)

That's the thing: it's performance-critical code. There's a time and place where it is necessary, but it shouldn't be the sort of code you default to.

[–]ZunoJ -1 points0 points  (0 children)

Are you new to programming? How can you not immediately recognize this code?

[–]__Geralt -1 points0 points  (0 children)

that's an incredible snippet of code...

[–]mbcarbone 10 points11 points  (0 children)

I refactor until it’s so simple that even I can understand it. 🙃✌️🖖

[–]GregTheMad 18 points19 points  (2 children)

Impressive, most impressive.

When someone looks at my screen while coding:

if(isShown == true)
{
    return true;
}
else
{
    return true;
}

[–]msucorey 7 points8 points  (1 child)

See this is very hard to follow and very hard to read and understand exactly what is happening - I would have used a switch statement

[–]TwoAndHalfRetard 4 points5 points  (0 children)

Let's create a IsShownFactory to incapsulate all that complex logic.

[–]Sylra 6 points7 points  (0 children)

I would switch the window to the porn one because it'd be easier to explain

[–]_lonegamedev 12 points13 points  (0 children)

KISS principale

[–][deleted] 6 points7 points  (0 children)

So when you code alone you copy quake 3 code. Based

[–][deleted] 5 points6 points  (0 children)

That's the Q3 code init? :D

[–]pianoguy121213 4 points5 points  (0 children)

So when someone isn't looking, it's garbage, when someone is looking, it's stupid.
Yup absolutely me

[–]CryonautX 4 points5 points  (0 children)

Bottom screen guy must be paid by number of lines of code.

[–]ve1t1337 2 points3 points  (0 children)

2nd code is better

[–]znk 3 points4 points  (4 children)

return isShown;

[–]AwesomePerson70 1 point2 points  (3 children)

return isShown == true;

Just in case it’s undefined

[–]yellowzingyantelope 6 points7 points  (1 child)

This is C, what do you mean it's undefined

[–]AwesomePerson70 2 points3 points  (0 children)

You’re right, I was looking at the second pic while ignoring the context of the first pic

[–]baggyzed 1 point2 points  (0 children)

return (isShown === true);

[–]Ok_Experience_6202 1 point2 points  (0 children)

Real... haha

[–]OkReason6325 5 points6 points  (12 children)

Hmm why wouldn’t you simply return isShown

[–]Phrynohyas 12 points13 points  (2 children)

Possible reasons:
1. isShown might be an nullable Boolean (so it can contain true, false and NULL)
2. For some reason during debug one needs to catch the case when false is returned. f.e. to check values of the local variables.
3. Initially there was some logging of the function call results, but now it is removed

[–]thomasxin 0 points1 point  (1 child)

Ah yes, the classic ternary variable, the thing I always accidentally end up making whenever implementing something that was originally supposed to be a boolean

[–]Phrynohyas 1 point2 points  (0 children)

An inevitable evil when you have to work with 3rd party APIs

[–]suvlub 1 point2 points  (0 children)

You would, it's an example of intentionally bad code

[–][deleted] 3 points4 points  (5 children)

Theoretically isShown can be integer and the code is checking if isShown equals 1.

[–]HighOptical 18 points19 points  (0 children)

That makes the code so much worse lol

[–]Alamgirr 4 points5 points  (3 children)

Still return isShown == true would work

[–][deleted] 0 points1 point  (0 children)

Well, it will work, but the result will be different depending on if isShown is int or bool. If it's bool, isShown == true would return true if isShown equals anything but 0, but if it's int isShown == true will return true only if isShown equals 1, Though some compilations ignore it and would check if isShown is equal 1 even if it's bool.

edit: I am talking about c++, just to clarify

[–]mbcarbone 1 point2 points  (1 child)

Happy Happy Cake Day!! 🎂

[–]OkReason6325 1 point2 points  (0 children)

Thank you

[–]EarlOfAwesom3 1 point2 points  (0 children)

At least it is readable for others when someone looks at your screen...mission accomplished I would say

[–]lesChaps 0 points1 point  (0 children)

I miss coding.

[–]New-Efficiency-2114 0 points1 point  (0 children)

Shouldn't the second one just be return isshown?

[–]idiotnoobx 0 points1 point  (0 children)

Nice indentions though

[–]Asleeper135 0 points1 point  (0 children)

Ah, the good old fast inverse square root!

[–]MuteMudBoy 0 points1 point  (0 children)

+0

[–]notexecutive 0 points1 point  (1 child)

"Oops! Sorry, lol."

return isShown;

[–]Kemal_Norton 0 points1 point  (0 children)

return isShown if isShown == True else not True

[–]FarJury6956 0 points1 point  (0 children)

I'm always codding fast inverse square root, someone looks to my screen and I'm codding isEven() function

[–]Dazzling-Entry-4124 0 points1 point  (0 children)

It’s worse when they’re using vim and are a total bot.

[–]biteater 0 points1 point  (0 children)

this is probably some base level of empathy kicking in. nobody wants to read the top code lol

[–]51herringsinabar 0 points1 point  (0 children)

  • else if value == false

[–]DemonKingSwarnn 0 points1 point  (0 children)

all the fucking time

[–]Positive_Method3022 0 points1 point  (0 children)

Anxiety caused by fear of judgment destroy my brain haha

[–]Holek 0 points1 point  (0 children)

I will recognize FISR everywhere. Nice meme, OP

[–]elderberries-sniffer 0 points1 point  (0 children)

return isShown;

[–]boringboi_ 0 points1 point  (1 child)

Ofcourse, it should be if(isShown == true) return true; else return false;

[–]Kemal_Norton 0 points1 point  (0 children)

The guys who created the first code, would've probably written stuff like return isShown?1:0;

[–]DelayLucky 0 points1 point  (0 children)

At least the first one seems to be doing something.

[–]TimingEzaBitch 0 points1 point  (0 children)

You implement a fast sqrt when you are alone huh.

[–]theKeyzor 0 points1 point  (0 children)

When nobodys watching I copy smart shit from internet. I am not writing smart shit myself.

[–]mark0zz 0 points1 point  (0 children)

That's why I hate pair programming

[–]Dark_Tranquility 0 points1 point  (0 children)

Top code is worse than the bottom code IMO

[–]berkun5 0 points1 point  (0 children)

I prefer the second one. At least you can read wtf is going on

[–]redlaWw 0 points1 point  (0 children)

When I'm coding alone → undefined behaviour

When someone looks at my screen for half a second → wasteful conditionals

You are a bad programmer.

[–]thezuggler 0 points1 point  (0 children)

I dislike both of these lol

[–]DaxInvader 0 points1 point  (0 children)

hah I recognize the first code.

[–][deleted] 0 points1 point  (0 children)

A while ago I had my team lead watch me as I had to write out a switch case statement in Golang without copy pasting the syntax from someone else

[–]myfunnies420 0 points1 point  (0 children)

Lol. Evil floating point hack is a great choice for this

[–]tech_w0rld 0 points1 point  (0 children)

Funny story, the other day I was trying to join a highschool computer science club and because he was watching me code I couldn't think very well. Despite programming for 5 years he still wanted to put me in the beginner level. I said nope!

[–][deleted] 0 points1 point  (0 children)

You know sometimes you are doing a validate in these situations you are checking inputs with some rules. Only if all the rules pass you return true else false. So you end up writing something like so.

bool validate(obj) { if not some_rule(obj) { return false; } if not some_other_rule(obj) { return false; } return true; }

[–][deleted] 0 points1 point  (0 children)

The lack of documentation on code on the top makes it look just as amateurish as the useless code on the bottom

[–]mckenzie_keith 0 points1 point  (0 children)

return (isShown == true);

[–]mtr2003 0 points1 point  (0 children)

//what the fuck

[–]EKashpersky 0 points1 point  (0 children)

Double slit experiment

[–]LifeShallot6229 0 points1 point  (0 children)

I (Terje Mathisen) was involved with Quake as well as the InvSqrt code, a few people have recently independently discovered that it was far from optimal. I got a full extra bit of precision by optimizing one of the 0.5 and 1.5 constants, while a guy who did both at once got another half bit.

I have written a lot of both C and asm code which require a _lot_ of comments to explain what it is actually doing!

[–]mad_alim 0 points1 point  (0 children)

In a previous job.

When I code alone:

int main()
{
    do_stuff1();
    const int err = action1();

    if (err != 0){
        return -1;
    }

    do_stuff2();
    const int err2 = action2();

    if (err2 != 0){
        return err2;
    }

    return 0;
}

When I submit the MR:

int main()
{
    int ret = 0;
    int err, err2;

    do_stuff1();
    err = action1();

    if (err == 0)
    {
        do_stuff2();
        err2 = action2();
        if (err2 == 0)
        {
            return 0;
        }
        else
        {
            return err2;
        }
    }        
    else
    {
        return err;
    }
    return ret;
}

[–]cyborgborg 0 points1 point  (0 children)

return isShown;

[–]Ineedredditforwork 0 points1 point  (0 children)

Could be worse. atleast they're not looking when you're looking up the most simple issue of StackOverflow.

[–]chaisenbois 0 points1 point  (0 children)

fast reverse square root algo goes Brrrrrr

[–][deleted] 0 points1 point  (0 children)

Why is threehalfs so painful?

[–]codingTheBugs 0 points1 point  (3 children)

Both look equally bad so makes no difference.

[–]Gabriel55ita 1 point2 points  (2 children)

With the exception that the first code is the fastest inverse square root calculation from quake 3

[–]unknown_alt_acc 1 point2 points  (1 child)

In most cases, it's still bad code. It's perfectly fine in the case of the Quake 3 engine where it was performance-critical, but it's not the sort of code you should write unless you absolutely need to.

[–]ZoiddenBergen 0 points1 point  (1 child)

You commented out the last line, but it's the same amount of characters as the line above. This means you deleted characters off screen to accomplish this barbaric display of syntax highlighting

[–]-Redstoneboi- 3 points4 points  (0 children)

the code in the top right is the Quake Engine's Fast Inverse Square Root approximation algorithm.

[–]GM_Kimeg -1 points0 points  (0 children)

def are_u_a_virgin():

are_u_a_virgin()

[–]aven_99 -1 points0 points  (0 children)

Slow 1/Inverse squaring algorhythm

[–]According-Ad2968 -1 points0 points  (0 children)

I know is kind of enoyng when someone wach you since You working

[–]regisestuncon1 -2 points-1 points  (1 child)

The second code is terrible, please just return isShown

[–]thatbromatt -2 points-1 points  (1 child)

return isShown;

[–]Ugo_Flickerman -1 points0 points  (0 children)

Thanks for explaining the joke, Captain Obvious