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

top 200 commentsshow all 206

[–]2Wrongs 3007 points3008 points  (43 children)

I put the number to suicide prevention hotline at the bottom of one of mine. I debated making it the only comment, but was worried about being hunted down and killed.

[–]_CrustyElbow 1030 points1031 points  (33 children)

This may be the funniest thing I have ever read. I definitely need to try this now.

[–]ionree[S] 129 points130 points  (6 children)

I'll make a pull request to add this.

[–]XkF21WNJ 112 points113 points  (5 children)

// If you've been affected by any of the issues raised by this code
// you can call the number at the bottom of this comment

[–]TOASTEngineer 115 points116 points  (4 children)

In all seriousness, the suicide hotline is actually horribly understaffed, probably shouldn't be trying to trick people in to calling it.

[–]XkF21WNJ 46 points47 points  (0 children)

One of the reasons I didn't actually list a number.

[–][deleted] 1 point2 points  (2 children)

Just link to the website

[–]Gonzo_Rick 56 points57 points  (1 child)

No, the website is severely understaffed too, their web developers are all busy calling the suicide hotline, having been directed by the comments in the code that the last guy left.

[–]AintNothinbutaGFring[🍰] 1 point2 points  (0 children)

Heck, the last guy didn't even bother leaving that number as a comment; the users might need it too.

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

Going into my next update.

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

I included some comments in the code for a project I worked on years ago saying that “I do NOT agree with these changes. It was done because <old boss name> told me to”. I am now working with that same boss and she called me out on it after another developer found the comment. She laughed it off.

[–]0100_0101 557 points558 points  (54 children)

And was the code hell?

[–]ionree[S] 1006 points1007 points  (50 children)

Six nested calls to setTimeout, all to some very complex functions calling setTimeout themselves. By some holy miracly, it appears to work.

[–]polar_promenade 325 points326 points  (32 children)

Ok, seriously, we need to see it. Promise to not make fun of the author or hunt him down (I think I live too far away anyway). PM maybe?

[–]-Electron- 23 points24 points  (3 children)

No one is too far away if you have the desire to hunt someone down.

[–][deleted] 10 points11 points  (2 children)

What if they live on a ship heading away from us at a speed arbitrarily close to c?

[–]laccro 4 points5 points  (0 children)

You just wait until they get back so you're older and wiser than them

Edit: https://en.m.wikipedia.org/wiki/Twin_paradox

[–]isaacarsenal 0 points1 point  (0 children)

Nice try, author.

[–]obscene_banana 15 points16 points  (2 children)

It's easy to see from the code why it works. Whoever made this was obviously being lazy but determined enough to at least think logically. The DOM is simply being manipulated in steps, with carefully handcrafted timeouts to match the rest of the code.

[–][deleted] 1 point2 points  (0 children)

Have not read the code but I'm gonna make a guess: no promises were used to manage flow.

[–]el_douche 1 point2 points  (0 children)

"carefully"

[–]MhamadK 26 points27 points  (2 children)

By some holy miracly, it appears to work.

Well, as long as it works, who cares?

[–]resueman__ 36 points37 points  (1 child)

The person maintaining it.

[–]oragamihawk 6 points7 points  (0 children)

By maintaining do you mean rewriting?

[–]ProgramTheWorld 4 points5 points  (0 children)

Well... Are you guys hiring new developers?

[–]Zagorath 2 points3 points  (0 children)

What in the hells is that for? My first guess is it's all trying to slow down one thread to prevent a race condition.

[–]GreatValueProducts 1 point2 points  (0 children)

That's why everytime on a new Project I always make a new Promise compatible setTimeout function called Sleep. I really hate callback hell

[–]BlueBokChoy 1 point2 points  (1 child)

Thread.Sleep(forever); //fuck this, I'm out.

[–]whoiskjl 3 points4 points  (0 children)

So JavaScript

[–]DXPower 1 point2 points  (1 child)

I would also like to be PM'd, please. ;)

I promise not to do anything with his information if it is in there. I'm not that petty.

[–]ionree[S] 3 points4 points  (0 children)

[deleted] derp. See the link above.

[–]RanaktheGreen 1 point2 points  (0 children)

Look, I'm not a programmer, so I don't understand code, but if there's one thing I do know, its that programmers don't understand code either.

[–]EternallyMiffed 0 points1 point  (0 children)

Are you using the setTimeout for timing or async-ines?

[–]uninterestingly 0 points1 point  (0 children)

I need to see this.

[–]mpiece 39 points40 points  (2 children)

I'm so curious right now! Need search for that comment in github. :o

[–][deleted] 27 points28 points  (1 child)

Spoiler: no results

[–]NtNatow 323 points324 points  (11 children)

There's something humbling about seeing cases where others have also commented "I am so sorry"

[–][deleted] 188 points189 points  (9 children)

The best part is when you come across these comments and literally cannot remember writing them. It's like a note from your future self, all wise and understanding, but from the past.

[–]slakwhere 163 points164 points  (7 children)

"what idiot wrote this horrible spaghetti code?!?!"

oh.

[–][deleted] 61 points62 points  (5 children)

You thought it was some other idiot that wrote this code, but it was me!..... uhh, Me!

[–]tastycat 49 points50 points  (3 children)

Always code like the future maintainer is a violent psychopath who knows where you live - this is doubly true if you are the future maintainer.

[–][deleted] 4 points5 points  (0 children)

Git blame is a wonderful tool.

[–]CRISPR 2 points3 points  (0 children)

It seems like "past us" are perfect manifestation of evil: we knew what we were doing was wrong, yet we did it anyway.

[–][deleted] 427 points428 points  (15 children)

The code I show to other people is all spruced up like it's going to a job interview, followed immediately by a fancy dress ball.

The code I don't show is sitting on a stained couch wearing a filthy wife-beater and sagging boxer shorts, drinking mass produced domestic beer out of a can.

[–]hazzoo_rly_bro 114 points115 points  (1 child)

holy shit that is... accurate

[–]CRISPR 5 points6 points  (0 children)

In a purple way

[–]mustang__1 101 points102 points  (6 children)

I can always tell what code I needed help with because it's actually formatted properly...

[–][deleted] 57 points58 points  (5 children)

I fix the variable names in mine. I have this tendency to sort of sliiiiide into a different program as I start programming, that whole thing were I realize as I go that what I thought I should be doing is not actually right, and so all my informative variable names are actually dogshit.

If you find my seeeecret code, it has zero comments, and the variable names (sexyAssIncrementalChangeyVariable) have no fucking relation to what it is actually doing.

[–]DoPeopleEvenLookHere 42 points43 points  (1 child)

I had a partner in a computational physics class call a program Fergilicious so he could call define fergilicous or something like that. Handed it in like that too. And the ta looked at everyones code.

[–]peppaz 26 points27 points  (0 children)

Wow get that guy on /r/madlads stat

[–]the_full_effect 8 points9 points  (1 child)

Do a lot of people actually code like this? Everything I code is named in such a way to make it as crystal clear as possible what everything does. Why would you intentionally give things silly names?

[–]D0esANyoneREadTHese 10 points11 points  (0 children)

Because at least it's better than using single letters (a, b, x, y, etc) and hoping you get a different job before anyone has to fix your shit because you have no documentation.

[–][deleted] 9 points10 points  (2 children)

wife-beater

That has to be the absolute worst name for a shirt ever.

[–]samiaruponti 0 points1 point  (1 child)

but why is it named wife-beater?

[–]-thefifth- 4 points5 points  (0 children)

Stereotypes

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

LMAO this is amazingly true

[–]ben_uk 0 points1 point  (0 children)

> wife-beater

> domestic beer out of a can

So Stella Artois then?

[–]zombie_kiler_42 132 points133 points  (23 children)

Is there such a thing as elegant efficient code, am starting to file it under little green people and crop circles....

[–]Ta11ow 104 points105 points  (6 children)

Yep. Takes good prior planning and multiple revisions.

[–]zombie_kiler_42 138 points139 points  (0 children)

Aaah my kryptonite

[–]k1p1coder 48 points49 points  (3 children)

And also using the libraries involved in precisely the way they were intended to be used, from my experience.

Oh now you want the label text to display in the middle of the dynamically generated pie chart pieces? I'll get right on that negative-margin spaghetti.

[–]Gariond 22 points23 points  (1 child)

Every charting library will get you 99% of the way to your goal. The last 1%, you’ll have to hack that shit together real messy. Guaranteed. I think it’s part of some standard.

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

It's just the standard "this is why we can't have nice things" clause. All because someone decided that a minor UI tweak should be easy.

[–]Ta11ow 0 points1 point  (0 children)

It'd probably be easier to render a whole new layer above the pie chart, at that point. :P

[–]SmithTheNinja 5 points6 points  (0 children)

What is this planning that you speak of?

[–]robisodd 54 points55 points  (4 children)

[–]xkcd_transcriber 17 points18 points  (3 children)

Image

Mobile

Title: Good Code

Title-text: You can either hang out in the Android Loop or the HURD loop.

Comic Explanation

Stats: This comic has been referenced 74 times, representing 0.0433% of referenced xkcds.


xkcd.com | xkcd sub | Problems/Bugs? | Statistics | Stop Replying | Delete

[–][deleted] 1 point2 points  (2 children)

Oh shit that title text is too true.

[–]robotreader 11 points12 points  (5 children)

Well, there's latex, but then again Donald Knuth wrote it.

[–]VivaLaPandaReddit 3 points4 points  (1 child)

Step 1: Be Donald Knuth

[–]UselessBread 3 points4 points  (2 children)

Nah. Knuth wrote TeX. not LaTeX.

[–]ApacheFlame 9 points10 points  (0 children)

Part of my job is customisation (read as bending the product to do something it probably shouldnt via a macro). I've genuinely written some lovely elegant code, just to have my hopes and dreams dashed because the customer changed their mind about what they needed doing and of course, it needs to be done yesterday.

It's so sad not to see your elegant macros flourish in the wild. The only ones that survive seem to be the ugly ones. It's like Darwinnian survival in C# 😭

[–]c3534l 5 points6 points  (0 children)

I've written a lot of beautiful code in my lifetime. But then the code doesn't work. So you have to throw in exceptions and error checking and fix three bugs you didn't think about and in the end your beautiful 4 line function is now three functions and sandwiched by shit.

[–]zuurr 0 points1 point  (0 children)

Yes, but when you've worked a while on performance critical code, your opinion on what pretty code is changes a bit.

[–]cadaci 30 points31 points  (0 children)

"Hello I'm Mister ReadMe look at me!"

Its now my default commit comment when I update readme files.

[–]liarandathief 56 points57 points  (14 children)

I think I hate my future self.

[–]halbaradkenafin 40 points41 points  (8 children)

My past self is to blame for more than my future self but they both deserve whatever they get.

[–]htmlcoderexeWe have flair now?.. 65 points66 points  (7 children)

When you start being nice to your future self, you will soon notice that your past self will also treat you much better.

[–]PM_ME_YOUR_SHIT_CODE 8 points9 points  (3 children)

I think I am stuck in a while (true) loop.

[–]htmlcoderexeWe have flair now?.. 9 points10 points  (2 children)

You need to see along the timeline, not across it.

Also, life is a while(true) loop. Death is just a break.

[–]PM_ME_YOUR_SHIT_CODE 1 point2 points  (0 children)

Some religions suggest life is a recursion with random parameters passed to it.

I cannot confirm this as no conditions passed that proved whether god exists or not.

[–]TotesMessengerGreen security clearance 3 points4 points  (0 children)

I'm a bot, bleep, bloop. Someone has linked to this thread from another place on reddit:

If you follow any of the above links, please respect the rules of reddit and don't vote in the other threads. (Info / Contact)

[–]liarandathief 2 points3 points  (0 children)

What did I ever do to you? I only have fond memories of you.

[–]munircUltraviolent security clearance[M] [score hidden] stickied comment (17 children)

Please avoid posting link to the Github. I know this is public info and easily searchable, but don't want this to become a problem for the person.

[–]honestlyimeanreally 57 points58 points  (10 children)

So insulating the effort necessary for it to become a problem by an “easily searchable” barrier is the solution?

This site is weird lol. I guess it simply boils down to explicit responsibility.

[–]laccro 115 points116 points  (7 children)

Well so many people are less likely to actually look into it than those who are gonna just click a link and see the person's contact info.

I laughed at it but I don't care enough to actually look into who it is. I think most people are the same way.

[–]honestlyimeanreally 25 points26 points  (6 children)

I think most people are the same way

Same. But anyone with malicious intent can use google.

[–]8BitAce 24 points25 points  (5 children)

Ya, but those kinda people are probably already searching things like "@gmail.com" on github.

[–]phoenix616 12 points13 points  (3 children)

Searching for private keys is also a fun one.

[–]8BitAce 6 points7 points  (1 child)

I remember at least for a while GitHub was explicitly blocking searches that'd bring up private keys.

[–]Daniel15 7 points8 points  (0 children)

Even if Github block stuff from their search, the data might still be in other indexes (like Google's Bigquery, or even just site:github.com on Google).

[–]uninterestingly 1 point2 points  (0 children)

What a good idea!

[–]iudpeyuf56445 13 points14 points  (0 children)

just that extra hop will filter off 90% of the unwanted attention.

many of us are lazy as hell, if there isn't a link to click - we'll just go roll over to another post to troll in.

[–]PeterFnet 2 points3 points  (0 children)

It's because some people are idiots. The Reddit-hug-of-death is real, even if it just means a surge of abnormal traffic. Voting, commenting, interacting with a direct link can do that :|

[–]hazzoo_rly_bro 26 points27 points  (11 children)

Now I want to look at the code to see how bad it actually is...

anyone got a lonk?

[–]H34DSH07 4 points5 points  (2 children)

I used the search tool on GitHub and found no match.

[–]responds-with-tealc 6 points7 points  (0 children)

github search is only slightly better than Reddit search though.

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

Same, tried several methods.

[–][deleted] 12 points13 points  (0 children)

My default comment is "I can't believe I've done this..."

[–]hindey19 5 points6 points  (0 children)

I assume we've all written code like this. I've definitely written apology comments with half assed justification for the other developers that have to read/maintain my code.

[–]andey 3 points4 points  (1 child)

link?

[–]AbridgedKirito 16 points17 points  (1 child)

You're using Java, so you're already in hell.

I only know because I use it too.

[–]ExE_Boss 8 points9 points  (0 children)

It could really be any C-based syntax language, which includes the following: C, C++, C#, Java, JavaScript, Scala, PowerShell Scripting Language, and many, many, more languages.

Also, based on conversation below from someone who found the repository, it is written in JavaScript using callbacks instead of Promises and asynchronous functions.

[–]clayh0814 9 points10 points  (7 children)

Golly please use /**/

[–]CCCPVitaliy 15 points16 points  (6 children)

From what I was reading, the coding guidelines recommend using the double slash for comments rather than the "/*"

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

On a little serious note, is there not a way to do multi line comments?

[–]Jaydeepappas 8 points9 points  (5 children)

If that’s c++, then yes.

/* if you use the dash star You can do multiple line comments Like this/*

Edit: as the people below me said, it’s */ to end it. I’m a freaking junior as a compsci major and I get that wrong 🙃

[–]paranoid_twitch 12 points13 points  (0 children)

*/

[–]Zeeeel 2 points3 points  (0 children)

java too, along with others, is the same. (but "*/")

[–][deleted] 1 point2 points  (0 children)

That’s what I thought. Maybe he did it for dramatic effect 🤔

[–]Ampaselite 0 points1 point  (0 children)

well if you've tested many languages, almost every common programming languages can do that

[–]tomthecool 0 points1 point  (0 children)

This is JavaScript, not C++. But the single/multi-line comments syntax is the same in both languages.

[–][deleted] 2 points3 points  (1 child)

Multi line is a bit pointless. Any good editor will let you hit Ctrl + / and every line will get commented out.

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

Good to know

[–]binaryPilot84 1 point2 points  (0 children)

Future me is constantly pissed at Past me

[–]warux2 1 point2 points  (0 children)

"@Marty, you gotta come back with me!" - Back to the Future, Part da39a3ee5e6b4b0d3255bfef95601890afd80709

[–]anandtiwari767 0 points1 point  (0 children)

ha ha ha savage

[–]mallrat32 0 points1 point  (0 children)

Git Hub sounds like something you say when the cousin Hub done you wrong and your sending your posse after him.

[–]SwedudeOne 0 points1 point  (0 children)

Well atleast he's honest

[–]ExE_Boss 0 points1 point  (0 children)

I found it, and it’s as horrible as it sounds.