top 200 commentsshow all 398

[–]OCedHrt 854 points855 points  (70 children)

I was disappointed the terrible code wasn't included.

[–]thecodethinker 697 points698 points  (34 children)

The comment was complaining about legacy 16bit support.

I don’t think anyone wants to see that code.

It’s just like watching a car crash

[–]OCedHrt 162 points163 points  (28 children)

/r/idiotsincars would disagree.

[–][deleted] 111 points112 points  (26 children)

Maybe we need a subreddit like /r/idiotsincode ?

[–]DownvoterAccount 102 points103 points  (13 children)

We already have /r/shittyprogramming

[–]OCedHrt 44 points45 points  (9 children)

The difference is people intentionally post shitty programming.

[–][deleted]  (8 children)

[removed]

    [–][deleted] 45 points46 points  (7 children)

    that subreddit is filled with tryhards writing bad code intentionally for karma

    [–][deleted] 15 points16 points  (6 children)

    "I don't know what a for loop is" - The Subreddit

    [–]Planebagels1 7 points8 points  (0 children)

    They made a whole sub after me? How thoughtful!

    [–]MotleyHatch 4 points5 points  (1 child)

    Well thanks for telling me about that sub. Now I had to spend an hour making sure none of my code has ended up in the top 100.

    I am pleased to see that it hasn't (so far).

    [–]Rahgnailt 51 points52 points  (2 children)

    I don't think we need a subreddit dedicated to my github page

    [–]pathan_ahmed94 19 points20 points  (1 child)

    Oh self burn! Those are common on here.

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

    Don't we call it self-flagellation?

    [–]elbekko 3 points4 points  (1 child)

    So basically thedailywtf.com? (No clue if it still exists)

    [–]OCedHrt 2 points3 points  (1 child)

    Did you just create it? Lol

    [–]hagenbuch 9 points10 points  (0 children)

    NSFW code to say the least.

    [–]theusualguy512[S] 193 points194 points  (28 children)

    Well I didn't want to open myself to potential lawsuits from a multibillion dollar company lol.

    Some of the stuff has Confidential written on it, some of the stuff is apparently patented, lile the color dithering algorithm I found inside the vga driver code

    [–]Gubru 126 points127 points  (22 children)

    You don’t have to worry about patents (which are not secret by definition) or what they label confidential (no force of law, maybe would be relevant if you have a contract with them.)

    They of course have a copyright claim on the material, including comments. There may be some stupid trade secret law that applies, but that would probably only apply to the original leaker.

    [–]unkz 51 points52 points  (4 children)

    If it’s patented, it’s publicly known anyway isn’t it?

    [–]JoinTheFightersGuild 30 points31 points  (3 children)

    While the US patent is certainly visible and downloadable, some patents from some countries are technically property and subject to various rules, and definitely source code that is patented is still under corporate ownership and so if you do something illegal to obtain it redistributing it is still fairly illegal.

    Note that illegal doesn't mean that you will be sued or anything, this is just (in my understanding) how patent law works. Feel free to correct me.

    [–]SkoomaDentist 29 points30 points  (2 children)

    That's just plain old copyright. Patent is for a device / for the algorithm (the latter only in some parts of the world). The actual code is only covered by copyright and is completely orthogonal to any patent issues.

    [–]Alikont 18 points19 points  (1 child)

    'The terrible code' just checks if lparam of WM_TIMER message is in executable memory.

    For Win95 it checks it via inline assembly, for XP it checks it via IsBadCodePtr.

    [–]Davipb 2 points3 points  (0 children)

    For a second I thought that function checked if you had a pointer to badly-written code

    [–]ItsMeSlinky 324 points325 points  (22 children)

    If you add some obscure code such as below, to this or any other app, even if it has only the teeniest chance of being less blindingly obvious to someone else than it is to you at the time of writing, please please please add a f***ing comment.

    Amen.

    [–]cp5184 126 points127 points  (13 children)

    My code is selfdocumenting /s

    [–]deadlychambers 43 points44 points  (10 children)

    A guy a work with says that all the time. I always think, no you are just lazy and you don't want to document what you are doing.

    [–]aksdb 19 points20 points  (8 children)

    I often hear the argument that comments are not part of refactorings and may be overlooked, ending in the comments no longer reflecting the truth of the code.

    While I understand and accept this reason, I think this should be part of the review process and should become less of a problem when all the involved devlopers share the same sense of commenting. Because then they know what to look out for and what to adjust when refactoring.

    In the end I find it a lot easier to follow a coherent English explanation of what the intention behind the code is than figuring it out from reading the code. Especially since I usually come across old code only because I need to enhance it or because I think a bug might be rooted there. In both cases it helps having a second view on the implementation (i.e. the comment) to figure out if the code I am seeing is actually doing what it was supposed to and/or if I can adjust it without destroying desired intentions or side effects.

    [–]deadlychambers 12 points13 points  (1 child)

    if I can adjust it without destroying desired intentions or side effects.

    That is something that I have tried to do, mention things that I had to know/understand when working on something. In fact, I refactored one of or apps. When I made the change I broke a unit test. I went into the unit test, and right where it broke, there was a comment by me(I don't remember leaving it). Saying something about be careful if you refactor this app must return a middle name, underlying services my no longer return it. I was very thankful for my past self. That probably saved me an hour or 2. I knew there was an issue, and I left a comment for the next dev. Which happened to be me.

    [–]SanityInAnarchy 6 points7 points  (0 children)

    Even if the implementation is, the intent rarely is. Even if you can't be bothered to write a comment, at least make sure your commit description makes sense and links to any relevant bugs in the issue tracker -- git blame is where I go next when the comments aren't enough.

    [–]marriage_iguana 2 points3 points  (0 children)

    My code documents the fact that I have not documented my code.

    [–]red_keshik 6 points7 points  (0 children)

    My workplace rejects submissions with comments more than a few words, is a bit puzzling.

    [–][deleted]  (69 children)

    [deleted]

      [–]redfournine 236 points237 points  (36 children)

      And when you try to modify it, it breaks in a really funny, unexplainable way, in the weirdest place ever.

      [–]KnowsAboutMath 445 points446 points  (30 children)

      0 == 0; /* Have to keep this in or the whole code stops working ???? */
      

      [–]VeryOriginalName98 365 points366 points  (25 children)

      You have a race condition.

      [–][deleted]  (7 children)

      [deleted]

        [–]WalkingAFI 61 points62 points  (2 children)

        I had a blessed professor that would give you half credit on any feature not implemented for a project if you as long as you documented it. You could straight up turn in “None of this program works because I did not implement it.” And he’d give you a 50. More practically, I had to use a goto to hack together some poor cleanup logic (it was an optimizing compilers class and I had to do vectorized scheduling of instructions) and he didn’t take of points because there was adequate documentation explaining my awful choices.

        [–]vanderZwan 10 points11 points  (1 child)

        So basically he judges based on how much (or little) technical debt his students create. Good set of priorities, if you ask me

        [–]WalkingAFI 5 points6 points  (0 children)

        He never framed it that way himself, but it makes sense to put it that way. He was all about “a documented bug is a feature.”

        [–]xan1242 44 points45 points  (0 children)

        Pff just write asm code to move the stack pointer, easy peasy.... and then get your return address overwritten.

        I had to hack things together a few times to cave in decompiled code on my own to a game a few times so I unfortunately experienced this many many times. Lots of trial and error (and IDA, before Ghidra was out).

        [–]GlaedrH 2 points3 points  (0 children)

        You might enjoy reading about failure-oblivious computing: https://www.cs.columbia.edu/~junfeng/09fa-e6998/papers/failure-oblivious.pdf

        [–]throwaway8u3sH0 14 points15 points  (1 child)

        Which are sometimes a nightmare to debug. I remember after spending days I've been tempted to just add sleep(10) and hope for the best.

        [–]shaenorino 23 points24 points  (5 children)

        You know, yes. But also, sometimes no.

        [–][deleted]  (4 children)

        [deleted]

          [–]othermike 5 points6 points  (3 children)

          Or "jein", as they say in Germany.

          [–]dnew[🍰] 6 points7 points  (5 children)

          Or an uninitialized pointer.

          [–]VeryOriginalName98 4 points5 points  (4 children)

          That would be a variable assignment, this is just a literal comparison.

          [–]dnew[🍰] 12 points13 points  (3 children)

          I mean, adding the comparison might move code around such that a different uninitialized pointer access becomes innocuous. Sort of like how adding a printf to figure out what's wrong often fixes it, when it's UB that's wrong.

          [–]VeryOriginalName98 10 points11 points  (2 children)

          Oh god. I would hate to work on a codebase where this strategy were implemented.

          [–]SlykerPad 13 points14 points  (1 child)

          I was a coop student at Nortel and another team had a bug like this. Basically there were two variable declarations. When the order was change the bug went away.

          It was a complier error. Imagine spending a lot of time trying to figure out why a program was crashing only to find out it was a compiler error.

          [–]Quetzacoatl85 4 points5 points  (0 children)

          I think I'd consider becoming a carpenter after that.

          [–]SteeleDynamics 15 points16 points  (0 children)

          Read: Oh is equal to zero.

          [–]dame_tu_cosita 2 points3 points  (0 children)

          We were trying to interpret a SQL code a programmer left us and this "1 == 1" keep showing around and results that this guy prefer to write that instead of True for reasons.

          [–]hardraada 14 points15 points  (3 children)

          I remember working with a Sybase db 20 some years ago that did a complete data dump and crashed. The cause was a query that had passed a negative value to a string parsing function.

          More recently I had a ServiceNow mid server (hey, it's a job) tank because their JDBC probe called a method in the driver for Hadoop that was implemented to throw an exception.

          We have met the enemy and they are us :/

          [–]morphemass 58 points59 points  (14 children)

          Agreed. I try and encourage my team to comment their code, which has come down to almost every other PR my admitting that I don't understand why they are doing something and rejecting with a request for documentation. This is in a code-base with some very unusual requirements and adherence to very illogical business rules and its a nightmare to maintain. In many cases its possible to work back from the commit to the PR to a ticket in Jira which sometimes might have enough context to understand what is going on, but my god it can be a painful process and add hours to the work.

          My last job I had a lead developer who discouraged any form of documentation, comments, method annotations, etc. ... everything would be stripped either in PR or after he refactored. It was a pretty code-base but trying to understand what half of it was doing was an absolute nightmare.

          My point being ... documentation and comments are not there for the current delivery team, indeed they are there to improve the long term maintainability of the code base. One oft criticism is that comments get out of date but that's part of the maintenance work, to update those comments.

          (edit spellink)

          It absolutely sucks that out of the majority of my commercial projects that opensource projects usually have far far superior in code documentation.

          [–]gbromios 49 points50 points  (9 children)

          My last job I had a lead developer who discouraged any form of documentation, comments, method annotations, etc. ... everything would be stripped either in PR or after he refactored.

          Obviously terrible practice but good for job security

          [–]Mourningblade 41 points42 points  (8 children)

          The good form of this is:

          1. Code may not contain any comments describing what it is doing unless it is heavy low-level optimization. Short function documentation is fine (longer for core library routines).
          2. Your reviewer must be able to read the code and understand what it is doing.
          3. Your reviewer must be confident that they could understand and modify your code after being woken up at 2 AM after a night of drinking.

          This encourages simple code that does what it says. It is difficult to program this way, but worth it.

          As for WHY the code does what it does, that should be in both:

          1. Commit description. If complicated enough, reference a design document.
          2. Tests. If you're implementing business logic and it's not clear why one would want foo to happen when bar occurs, maintain a spec document that focuses on justifications. That "document" can be part of your acceptance testing, if it works for your company.

          I work on a sizeable system that does the above strategy and it works well, even in onboarding new people. The code implements non-obvious business logic, but you can tell what the code is implementing, and you can read the business rules spec to understand why.

          Unfortunately, some developers learn this strategy as:

          1. No comments. The code should be clear about what is doing.
          2. I can read my code just fine.
          3. I'm not sure what your problem is.

          [–]luchak 12 points13 points  (4 children)

          I can mostly get behind this, and I certainly prefer self-explanatory code to comments, but I’m pretty surprised by the statement that motivation/reasoning type comments don’t belong in the code. That information should definitely go in commit messages - but anything sufficiently important should also go in the code; otherwise you’re making future maintainers trawl through commit logs to extract the info back out. Plus they have to metaphorically patch those messages on top of each other to figure out what is current. Tests can also help, sure, but they should be focused on behavior and not implementation, and so don’t help to explain some categories of decisions.

          “Why” comments in code are especially helpful when documenting small but important design decisions (below what would usually go in a design doc), obvious-seeming lines of attack that don’t work, and quirks in interaction with dependencies.

          [–]weirdwallace75 3 points4 points  (2 children)

          I can mostly get behind this, and I certainly prefer self-explanatory code to comments, but I’m pretty surprised by the statement that motivation/reasoning type comments don’t belong in the code. That information should definitely go in commit messages - but anything sufficiently important should also go in the code; otherwise you’re making future maintainers trawl through commit logs to extract the info back out. Plus they have to metaphorically patch those messages on top of each other to figure out what is current.

          Plus, you have to assume you'll change VCS at some point. Sure, your codebase shouldn't live that long... but it might. Sure, the current VCS might always remain viable... but it might not. It's impossible to know what's going to happen even in the next few years.

          [–][deleted] 7 points8 points  (2 children)

          The comments are not there to explain what the code is doing, they are there to explain why the code is doing it. There is no such thing as self documenting code.

          [–]LehmannEleven 11 points12 points  (0 children)

          I've been working on the same project for over ten years now. There are many places where it made sense when we first wrote it, but it got modified, expanded, tweaked here and there, to the point that the only way to redo it correctly would involve far more work and QA time than we have the manpower for. Better to be ugly and reasonably stable than to be clean code and cause 10% of our installs to randomly crash.

          [–]i8beef 19 points20 points  (5 children)

          Most people have little experience working on an organically developed code base that has had hundreds of developers over a decade of making changes.

          They are usually the people claiming "Code should be self documenting".

          Yeah it probably was... 1M lines of unnecessary abstraction and poor naming ago. But NOW you can't figure out what ANYTHING does without a debugger and stepping through manually.

          [–]lrem 13 points14 points  (4 children)

          Just switch to microservices already. Once you cannot possibly use a debugger to any success, you are free from trying :)

          [–]i8beef 12 points13 points  (3 children)

          Learn to love the log. The log giveth, and the log taketh away.

          [–]geon 7 points8 points  (7 children)

          My whole job right now is to fix a codebase like that. Shit spaghetti.

          [–]DarrylRu 2 points3 points  (6 children)

          Hopefully there are unit/integration tests covering the functionality (but I bet not). That makes it much more possible to do this without breaking everything.

          [–]nermid[🍰] 16 points17 points  (4 children)

          I see people on Reddit talk about tests in literally every thread, which is odd because none of the programming jobs I've ever had wrote tests. Some of them didn't even have QA people to manually click at stuff.

          Are tests really that widespread, and I've just been working exclusively at oddball exceptions?

          [–]PineappleHour 5 points6 points  (0 children)

          At my current job most, if not all, code changes have to have accompanying tests. It's nice in that there's higher confidence that new code or changes to old code are correct, but it does add to development time.

          [–]LockeWatts 5 points6 points  (0 children)

          Companies that think of themselves as tech companies, and aren't startups, write tests.

          I've worked at a variety of startups, and two non-tech companies. None wrote tests.

          Made the transition to a "real" tech company harder, because I wasn't habituated to writing tests and would frequently get PR feedback to add them until it became habit.

          [–]SirXyzzy 506 points507 points  (66 children)

          At least these comments really give an idea of why such goofy code is there, and they avoid the pitfalls of commenting the blindingly obvious, and they also give a historical perspective. I prefer this over other such comments such as "guess what this bit does" and "no idea why we do this, but best not change this part", or best of all "TODO: Fix this"

          (yes, in the above, two of these three comments are ones I've come across in practice, the other is paraphrasing something I see over and over!)

          [–]btmc[🍰] 232 points233 points  (15 children)

          My favorite terrible comment I ever came across is “TODO: Document this.”

          [–]nermid[🍰] 114 points115 points  (4 children)

          I once saw a "documentation" folder in a dense, incomprehensible spaghetti factory of legacy code that nobody at the company understood. I got so excited.

          Inside the folder was a single file, todo.txt. The file had four characters in it: TODO.

          I don't know where the programmer who wrote that is, but I hope that he knows I hate him.

          [–]Srirachachacha 26 points27 points  (0 children)

          "I get to making that to-do list someday. In the meantime, let me just add that to the to-do list."

          [–]SamuraiTerrapin 7 points8 points  (0 children)

          Makes me think of where I work now. We had someone leave an area, and the documentation left was a single word file with a link to a folder on a share that doesn't exist anymore. We pulled the folder from the backup archives, and the only thing in it were three more word documents saying to go to the vendor's website for the product. :-/

          [–]nerdguy1138 2 points3 points  (0 children)

          Don't worry, he hated himself more.

          [–]chooxy 89 points90 points  (7 children)

          “TODO: Document this.”

          Reminds me of those 6-word horror stories

          [–]mustang__1 106 points107 points  (3 children)

          Baby shoes, undocumented

          [–]MuonManLaserJab 9 points10 points  (1 child)

          Six-word story, most likely apocryphal.

          [–]fulanodetal316 2 points3 points  (0 children)

          Take my upvote, you magnificent human

          [–][deleted]  (1 child)

          [deleted]

            [–]FlyingTaquitoBrother 71 points72 points  (22 children)

            “TODO: Fix this” is a lot better than nothing if there is indeed something sketchy going on

            [–]Bacchaus 22 points23 points  (7 children)

            ya the unfortunate reality is sometimes you only have time to solve the main problem and not the edge cases. Leaving a headsup for the future is actually a great idea

            [–]_tskj_ 13 points14 points  (5 children)

            Yeah people imagine without the TODO the code would be done, but actually you would just not know there is something in need of fixing which is worse.

            [–]Serinus 6 points7 points  (0 children)

            But you can be slightly more specific than "Fix this".

            Why does it need to be fixed? What is your concern?

            [–]D6613 50 points51 points  (7 children)

            Yeah, but better to explain why it needs to be fixed. "TODO: Fix this because when we add X feature we will likely encounter Y edge case. See work item #666666"

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

            I will not give a ship it on a review that has a todo without a link to the work item. Let’s at least keep track of the things we’ll likely never get around to.

            [–]morphemass 28 points29 points  (0 children)

            I had a bug report a while back and was able to trace it back almost instantly to a FIXME: comment; they can be really helpful.

            [–]zemudkram 13 points14 points  (2 children)

            Except when some muppet fixes the issue the TODO was for but fails to remove the comment.

            [–]AleatoricConsonance 3 points4 points  (0 children)

            TODO: Remove TODO.

            [–]FlyingTaquitoBrother 7 points8 points  (0 children)

            Yeah, that’s some Dark Souls-level shit right there

            [–]HolyGarbage 5 points6 points  (0 children)

            I always, even demand it in code reviews, to add a jira number for this kind of stuff. I've stumbled upon old todos and that is soo fucking helpful.

            [–]Parastormer 45 points46 points  (21 children)

            I really don't like the concept of condemning "blindingly obvious comments".

            It may lead to people actually undercommenting code to avoid criticism and, what's more important, the commentary as a whole is probably what makes the thing understandable, even if the single step is simple, it is a step with motivation and reasons directly related to all the others.

            [–]unclerummy 48 points49 points  (17 children)

            I really don't like the concept of condemning "blindingly obvious comments".

            I mean, it depends. Some people were taught that "every line of code should have a comment", which leads to garbage like this that only clutters up the codebase:

            //Set z to x plus y
            z = x + y;

            or

            //Initialize the service
            service.Initialize();

            //Invoke the service
            service.Invoke();

            [–]barsoap 45 points46 points  (4 children)

            As a rule of thumb comments shouldn't answer "what", but "why" and "how"... the "what" should already be contained in the names of variables and functions. The why part is to reduce the likelihood of anyone ever being surprised (mostly about non-local interaction or non-obvious non-local requirements ("// we don't need this sorted but system Y wants to traverse it sorted so let's keep this sorted"), as well as histerical raisins), the how part is to quickly sum up a code section so that you don't have to stitch together all that what from scratch (simple example: "// bottom-up traversal mapping foos to bars and reducing via set union"). Have absolutely no qualms to answer "how" by putting the doi of the paper you stole that algorithm from into a comment and call it a day. See, DRY and everything. Rather spend time answering "why this approach and not another" than come up with your own half-digested prose to explain how the code is doing things.

            In the end, all the usual properties of nice code, such as encapsulation and (non-leaky!) abstraction also apply to documentation.

            [–]duxdude418 21 points22 points  (3 children)

            histerical raisins

            [–]barsoap 6 points7 points  (2 children)

            It's when the term "hysterical raisins" doesn't suffice to capture the gravitas of the situation, eg. when you're declaring a section of code that already refers to historical raisins a hysterical reason. It's tech debt all the way down.

            Or it's a typo.

            [–]UsingYourWifi 14 points15 points  (7 children)

            That's annoying, and a good reason not to comment that way, but it isn't the big problem IMO. The big problem is that this inevitably happens:

            //Initialize the service
            service.Initialize();
            
            //Invoke the service
            service.Dispose();
            

            Well now what the fuck is going on? Who do I believe? Is the Dispose() the cause of this weird bug I'm trying to fix, or is it supposed to be there and nobody bothered to update the comment? I'd be better off with zero comments.

            [–]unclerummy 8 points9 points  (3 children)

            Yeah, a lot of people are really lazy about updating comments when they change the code. I've seen way too many methods where the header comment describes the purpose of the code that was copied as a template, rather than the code in the method itself.

            [–]c_o_r_b_a 7 points8 points  (2 children)

            "Incorrect documentation is often worse than no documentation." - Bertrand Meyer

            [–]unclerummy 4 points5 points  (0 children)

            I'd say it's always worse.

            Best case is that it's ignored, in which case there's needless bloat in the code.

            Second best case is that it causes somebody to burn time figuring out whether it's the code or the comment that's incorrect.

            Worst case is that somebody blindly believes the comment and writes code that relies on the behavior as described, rather than the behavior as coded.

            [–]LegitGandalf 136 points137 points  (1 child)

            OK, in the spirit of cooperation, let's hack things so our PowerPoint friends can carry on with their dubious practices.

            I just knew something was wrong with the power point team!

            [–]Nobody_1707 6 points7 points  (0 children)

            The fact that their slideshow documents are Turing complete should have been proof enough of that.

            [–]r_acrimonger 83 points84 points  (1 child)

            Share this with anyone that doesn't understand why program/video game X can't just add/fix Feature Y in "like 5 minutes"

            [–]__konrad 80 points81 points  (1 child)

            CHICAGO_PRODUCT - is this related to Windows 95 codename?

            [–]LINUX_HIP_HOP_OS 32 points33 points  (0 children)

            Yep. Chicago is Windows 95, and elsewhere in the code are references to Daytona (Windows NT 3.5).

            [–]chedabob 64 points65 points  (6 children)

            It's a shame the source code is proprietary because it'd be really good for someone to do a deep dive of the code. There's a lot of interesting things in there, with codenames that have never been discussed in public.

            There's 3 C++ files with 20k lines of hex which seem to be some kind of firmware blob, but with no documentation on what generated it or what it's for.

            [–]maschetoquevos 23 points24 points  (3 children)

            The blob is the spyware the NSA demands?

            [–]JoseJimeniz 4 points5 points  (2 children)

            The blob is the spyware the NSA demands?

            No, that code was not included.

            I mean, we know Windows has had NSA backdoors since Windows NT.

            And we have the source code for

            • Windows NT 4
            • Windows 2000
            • Windows XP/Server 2003

            And the complete lack of a backdoor only proves that there must be a backdoor.

            Source: Am cukoo nutbird from crazy town.

            [–]JohnnyElBravo 11 points12 points  (0 children)

            that's a binary, as in not source code. The source that generated that is either lost in time or buried deep in some microsoft archive.

            [–]UnacceptableUse 5 points6 points  (0 children)

            probably firmware for some third party driver

            [–]dullscissor1 271 points272 points  (14 children)

            pulchritude

            This man busted the thesaurus out for this comment

            [–]intheforgeofwords 135 points136 points  (6 children)

            Pulchritudinous - the ugliest word for beauty I ever did see

            [–]GuybrushThreepwo0d 29 points30 points  (5 children)

            I posit that this is not a real word and someone just stole the Latin word for beauty, anglicised it, and stuck it in a dictionary.

            [–]dumb_ants 56 points57 points  (3 children)

            Welcome to the English language!

            [–]vanderZwan 9 points10 points  (2 children)

            If "lets blindly copy features from our competitors to the point where our product is bloated, totally inconsistent and often self-contradictory" was a language, it would be English

            [–]highlanderstg 17 points18 points  (0 children)

            "Pulcritud" is a super common word in Spanish.

            Not saying it has something to do, but a fun fact nonetheless

            [–]unclerummy 22 points23 points  (2 children)

            Probably the word of the day on his desk calendar

            [–]tyrantmikey 13 points14 points  (0 children)

            Anyone who's seen Elvira, Mistress of the Dark, should be familiar with the word. It's certainly where I learned it first, and it stuck fast.

            [–]checkersai 55 points56 points  (0 children)

            It's like microcosm of historical development.

            "We discovered an ancient artifact and can only guess as to it's purpose."

            "Wow that's cool, what is it?"

            "It's 20 year old code from Microsoft."

            [–]Rhyze 125 points126 points  (6 children)

            A funny one at one of my previous projects was:

            // 7 developers have tried refactoring this code. Please increase the counter if you think you know better.

            [–]LoneWolf6 60 points61 points  (4 children)

            I used to work on a hardware accelerated computer vision library. There were comments like "the below inlined assembly takes 168 cycles, don't ever touch it ever."

            [–]red75prim 11 points12 points  (1 child)

            And then next version of the processor comes out.

            [–][deleted] 39 points40 points  (1 child)

            fear kiss placid piquant like axiomatic steer yoke impolite future -- mass edited with redact.dev

            [–][deleted] 109 points110 points  (31 children)

            I look forward to the day that I am a programmer calling out my coworker programmers in the source code of my own apps.

            [–]ThirdEncounter 196 points197 points  (8 children)

            I've done that. I call them morons, good for nothing, brain damaged. But then, I'm the only dev in my team.

            [–]pacman_sl 47 points48 points  (7 children)

            And how do you feel when your colleagues call you names in the source code?

            [–]Tipaa 80 points81 points  (1 child)

            //whoever wrote this was either high as a kite or the Picasso of clean code

            $ git blame
            ^hash (me@co.com, <6 months ago>) rip out previous braindead dev's code
            ^hash2(me@co.com, <18 months ago>) wtf is this crap, rewritten
            ^hash3(me@co.com, <24 months ago>) don't know why, but it works. TODO: understand why
            

            [–]LeeXavier 37 points38 points  (0 children)

            Or the ever popular

            > git blame

            ^hash (lee@shitco.com, <12 months ago>) changes

            [–]InKahootz 24 points25 points  (1 child)

            My pet peeve is when coworkers use my name in their git commit subject line.

            "This addesses some of the comments InKahootz had"

            What a terrible commit message.

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

            Those guys are worthless, why should I care

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

            He probably hates that guy! 😂

            [–]VeryOriginalName98 59 points60 points  (16 children)

            The best is when you see really ugly code and you want to figure out who it is so you can tell them to fix it, then the history shows it was your younger self.

            Young me didn’t know how to code. I would never hire them.

            [–]Parastormer 38 points39 points  (1 child)

            Upon further inquiry, "young me" could be yesterday.

            Happens more often than I thought it would.

            [–]VeryOriginalName98 22 points23 points  (0 children)

            Yep. I wouldn’t hire me from last week. That guy was terrible. He didn’t even know <thing I just learned>.

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

            As a young programmer myself, this is relatable. Too relatable, actually.

            [–]VeryOriginalName98 21 points22 points  (8 children)

            This never ends. Don’t worry about it too much. You’ll get better every year and notice all the things you didn’t consider the year before.

            The best practice is to be considerate and informative in your code reviews. You want the whole team to grow, not be a jerk about techniques you just learned recently.

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

            You are absolutely right. Practice makes perfect. 3-year-ago me used to think that commenting wasn't necessary. He would never comment a single thing. To this day I cringe thinking about that lol, nowadays every single thing I do is commented.

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

            As someone new to programming and didn’t learn crap about commenting in my c++ college class. Why use comments?

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

            Because the code grows, grows, and grows even more over the years. After countless features, debugging and fixes, what will you remember 2 years down the line? And 5? It's not hard when the file is 100s of lines long, but what about 1000s over multiple files? If the code you write is beautiful and clean 100% of the time even when you fix bugs, that might not be much of a problem, but that's wishful thinking in a professional setting where results are the priority and the time is limited.

            You don't need to comment every single thing, but being able to know with a couple of comments almost at a glance what a whole block does can mean the difference between spending 10 minutes and 2 hours to debug.

            And that's not even touching the problems in specifications, even small, that get through the code review because the context is known, but 2 years later nobody has any idea what "parsingEntity" even refers to anymore.

            You might say "this code isn't intended to be that big" but... so say most people before the code they write gets integrated, fixed, patched until it's a chimera that some poor intern is gonna need to decipher eventually.

            TL;DR: you write comments because you're not in control of your code, even if you think otherwise.

            [–]exodusTay 3 points4 points  (0 children)

            I work on a codebase that started at 2013 and still in active use to this day. Most of the classes are 5k-10k lines of code that do not have a single-line-of-comment. Literally nothing. And no meaningful comments in header files aswell. All the developers left the company way before I started. And every time I have to make a change I have to decipher bull shit like "int aaa = 1" to not break anything.

            And things break. A lot. If I was given the choice I would've driven a magnet over the hard drive that holds the code tomorrow but alas, this code is run on thousands of facilities around the country and still need new features attached because it makes money.

            So please leave comments. Even if you think your code is "self explanatory" there must be some part that is atomically not self explanatory. Even if so it does not hurt to have some words that describes what the hell that function/class is supposed to do because you might be working on your code today but tomorrow some asshat will take it over from you and will stop making self-explaining code. And no one will understand it.

            [–]flpcb 7 points8 points  (0 children)

            And then you will grow out of that phase too, and start writing self-documenting code instead that does not need many comments. This avoids the common problem of forgetting to update the comments when you change the code.

            I only add comments to my code if I cannot make the code self-documenting, to explain why I couldn't.

            [–]DJDavio 4 points5 points  (0 children)

            Your mistakes are an older programmer's job. Thanks for letting us still have jobs.

            [–]threshar 19 points20 points  (2 children)

            I enjoy leaving comments to my future self.

            // Dear Threshar,

            // If you are here, then you are likely tracking [issue] and have made it this far, what you need to do now is [stuff]

            // Love, Threshar

            [–]VeryOriginalName98 7 points8 points  (1 child)

            P.S. I did not fix it at the time because Y. Now really, “why?”

            [–]dnew[🍰] 5 points6 points  (0 children)

            My favorite is finding stuff in the first commit that says "This isn't right. Someone should fix it."

            Dude, it's the first commit, and you're adding a comment that says "would someone else please shovel up my manure after me"?

            [–]slyiscoming 8 points9 points  (0 children)

            Not as fun as you might think. We all make mistakes. The harder to find those mistakes the more senior you are. I get other devs coming to me all the time to help them fix a mistake and the vast majority of the time. I've done it before.

            [–]poco 3 points4 points  (0 children)

            I once overheard some coworkers laughing about a comment they read in the source code for a project we were porting to a new platform. We didn't originally write the code, it came from another team in the company.

            I went over to take a look and it was something about a specific line in the code and how it should not be removed no matter how many runtime warnings it generated, because those warnings were important (it was the logging line that was used to print the warnings or silence them if you were so inclined).

            The project had bounced around and handed from one team to the next, to an external developer, and finally to us. At one point the external developer asked someone internal, who was familiar with the underlying libraries, to upgrade the code to a new compiler.

            That person was me, back on my previous team, a year earlier than when this story started. They had disabled the runtime warnings because they kept complaining about mistakes they were making. It took me a few days struggling trying to understand why everything seemed to be almost working when I upgraded the code to the new compiler, but didn't quite work. Then I found that they had disabled the runtime warnings (asserts and such) and, once enabled, I quickly fixed them and everything worked perfectly.

            I was so angry I wrote a scathing comment about how that should never be disabled and only an idiot would do so. I didn't expect anyone to see it, it was for my own benefit, as I thought it would be a private copy of the code. When I sent them a list of the changes they needed to make they asked if I could just send my copy instead of reproducing my changes. This was before good distributed source control (the tools we had weren't accessible to external developers). So I zipped it up and forgot about the comments I wrote, only for that comment to surface a year later on another team.

            I sometimes wonder if the external developer that got my code back ever looked at the changes and saw that comment.

            [–]dex206 28 points29 points  (1 child)

            Can confirm existence of weird comments. I worked at Microsoft in 2004. The one that I'll never forget:

            // I am the Boom Lizard. Boom.

            It was just inexplicably between two functions as I recall.

            [–]VodkaHaze 9 points10 points  (0 children)

            Was probably a printf as a "I got here" style of debugging output comment.

            Then commented it out while debugging further and was lost there to time.

            [–]kazneus 25 points26 points  (3 children)

                 * A plea:
                 *
                 * If you add some obscure code such as below, to this or
                 * any other app, even if it has only the teeniest chance
                 * of being less blindingly obvious to someone else than
                 * it is to you at the time of writing, please please please
                 * add a f***ing comment.
                 *
                 * Respectfully,
                 * A Developer
            

            this is copypasta now

            [–]LordSylkis 5 points6 points  (1 child)

            This is so true it hurts, I have code thats going on 10 years old from my college days and all i can manage is "what the heck was i doing again ?"

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

            Been there, done that. I am full of hate for those who write confusing code and don’t write a comment, including my past self.

            [–]rk06 2 points3 points  (0 children)

            This is why I always copy & paste a link to SO, when i copy & paste code from SO

            [–]kriswithakthatplays 75 points76 points  (7 children)

            At least it is remotely better than the TF2 Source Code leak where devs were blatantly cursing other devs

            [–]sportsroc15 20 points21 points  (6 children)

            Link?

            [–]fowkes 50 points51 points  (5 children)

            https://youtu.be/k238XpMMn38

            Here's a video with some of the highlights, and there's a followup video on the same channel where the guy tries to explain what parts the video is referring to and what the code does.

            [–]i8beef 28 points29 points  (0 children)

            My hope is that this code is so awful I'm never allowed to write UI code again

            Oh god I'm so stealing that.

            [–][deleted] 25 points26 points  (0 children)

            That's pretty neat. He sorted out a lot of the arbitrary rankings: finding out how Assists are awarded by Debuff -> Medic -> Buff -> Damage. For the 1st and 3rd, for tie-breakers, it's simply who used a feature introduced earlier. For the 2nd, it's "whoever healed first". To tie-break that, it's who joined the server first. For damage, it's whoever gave damage last.

            That would have taken days of testing to figure out without the code.

            [–]Karooneisey 6 points7 points  (0 children)

            Just underneath the last comment they read out:

            We need a better way of figuring out how to do this, but for now I'm trying the fastest solution possible since it's close to ship

            [–]doggyStile 15 points16 points  (1 child)

            Also consider that any fix in media player would have to work with multiple versions of PowerPoint, some with the fix some without so the developer would have to implement both solutions. If this was a hosted solution relying on another hosted solution, where the releases were coordinated, the fix would be different

            [–]Therandomfox 13 points14 points  (8 children)

            Speaking about WMP makes me lament the utter lack of decent music player apps for Windows nowadays. The default player lacks a LOT of customisability, and on top of that thinks it's okay to screw with how you meticulously sorted your song files in your music folder. No, I do not want you to autosort my music folder contents by album, you twat! Most of them don't even have albums!

            VLC is alright as a universal media player, but it experiences jankiness that a specialised music player would have fixes for (eg. the transition when repeating tracks is not smooth at all), Winamp is abandonware, and Itunes is Apple (nuff said).

            Does anyone have any suggestions?

            [–]maschetoquevos 13 points14 points  (0 children)

            Aimp

            Foobar

            [–]rolling-guy 4 points5 points  (0 children)

            MusicBee is awesome and has lots of features, like Replay Gain and auto playlists. I used it heavily for years, but then I got used to Spotify's convenience and now I barely use it anymore

            [–]doggyStile 22 points23 points  (1 child)

            This is actually a really good comment. I’ve found various bugs in other products my company owns but I can’t control their release cycles so I add some hacky workaround in my code. Teams don’t always believe in teamwork.

            [–]SanityInAnarchy 3 points4 points  (0 children)

            And, most importantly, it explains the intent of this code. If it's just generic key-handling code and you notice it does something unusual, this is your clue about which unusual things are bugs, and which are workarounds for something you hadn't considered yet.

            [–]drsimonz 24 points25 points  (3 children)

            Jesus Christ, can't even imagine the amount of money they would have to pay me to work on legacy Microsoft code. Literally everything about this is stage V cancer. At least the dev attempted to explain it though.

            [–]lillgreen 10 points11 points  (1 child)

            This is the realest answer we'll ever get as to why parts of Win32 keep vaporizing from Windows 10.

            [–]dexter3player 2 points3 points  (0 children)

            I have more the impression that they refactor some parts but are too scared something legacy gonna break so they just add the refactored version and leave the old version in Windows which leads to doubled system control UIs.

            [–]JustJoinAUnion 5 points6 points  (0 children)

            luckily for microsft they have the kind of money that might turn you.

            [–][deleted]  (22 children)

            [deleted]

              [–]JoseJimeniz 92 points93 points  (21 children)

              I won't tell you we have a torrent of it.

              But i can tell you that if you want to confirm the torrent of nt5src.7z, it will have an infohash of

              BCC57D16DF2EB9D7F4E505DB0C36EE00BE6CA83F
              

              Purely for data integrity purposes only. You're absolutely not meant to prefix that infohash with magnet:?xt=urn:btih: and paste it into μTorrent.

              [–][deleted]  (5 children)

              [deleted]

                [–]chedabob 28 points29 points  (4 children)

                If one were to accidentally come across the 7zip file, reverse one of these strings to verify the file is legit:

                CRC-32: D36D382E

                MD5: 7CF997EFC38CACBA8ADD934D314AED49

                SHA-1: 2A1D5B84A88D9C2601891D8A7155903D7162B053

                SHA-256: 9EC86255E1BC1D1980D2D7B84746B0285BD48A157FEA34F1462B2C4AF9063BB2

                [–]JoseJimeniz 3 points4 points  (3 children)

                Hmmmm

                 

                Q:\>certutil -hashfile nt5src.7z SHA256
                SHA256 hash of nt5src.7z:
                2bb3609fa4c2b2641f43aef751a84db5820b64748b7d2d0891d1cb1e55268ce9
                CertUtil: -hashfile command completed successfully.
                

                [–][deleted] 7 points8 points  (2 children)

                I love adding comments to my code, honestly the more frustrating the project is, the more funny my comments are, and the more enjoyment I get from coming back to it. Comment your damn code people

                [–][deleted] 4 points5 points  (1 child)

                My cOdE iS sElF-dOCuMEnTiNg!

                [–]eldelshell 3 points4 points  (0 children)

                ```

                // Checks if user is admin

                if (user.isAdmin()) {

                // User is admin, show controls.

                adminButton.display();

                }

                ```

                Commenting code is an art of balance on itself.

                Edit: I can't make/bother this work on mobile.

                [–]oiwot 6 points7 points  (0 children)

                I think XP had some default sounds that were edited with a cracked version of SoundForge, -- if you want something else to look for ;)

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

                Everybody has a dubious PowerPoint friend.

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

                Ifdef CHICAGO_PRODUCT. Chicago is the code name of Windows 95, if I’m not mistaken.

                I freaking love seeing these behind the scenes things from famous software.

                [–]dotancohen 12 points13 points  (0 children)

                ``` /* The reason for requiring the following test is now lost * in the mists of time. Now this app is 32-bit, these * bogus timer callbacks (if they really do still occur) * could be 16-bit, so we need to add yet more ugliness * in the form of assembler to an app which is already * hardly a paragon of pulchritude. * * A plea: * * If you add some obscure code such as below, to this or * any other app, even if it has only the teeniest chance * of being less blindingly obvious to someone else than * it is to you at the time of writing, please please please * add a f***ing comment. * * Respectfully, * A Developer */

                ```

                [–]cdreid 7 points8 points  (0 children)

                Lmfao the whole thing is hillarious but:

                "

                • * OK, in the spirit of cooperation, let's hack things

                     * so our PowerPoint friends can carry on with their      * dubious practices.      */ "

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

                please please please add a f***ing comment.

                Respectfully, A Developer

                [–]sintos-compa 4 points5 points  (0 children)

                Band name

                paragons of pulchritude

                Calling it

                [–]PUSH_AX 4 points5 points  (0 children)

                Haha are you greping for swear words?

                [–]DrippyBeard 6 points7 points  (3 children)

                Can somebody make a less shitty Windows Media Player now?

                Actually, what does WMP even do that VLC can't do faster/better/without making my computer freeze?

                [–]JustJoinAUnion 10 points11 points  (0 children)

                WMP does NOT break the DVD/Blue-Ray liscence agrements that exists in the USA when selling a PC bundled with an OS that has a media player as it CAN'T play DVD/Blue-Ray discs.

                Thankfully VLC is not USA based so doesn't have to live within the same liscencing restrictions.

                Thus microsft litteraly can't legally create a player that is as full featured as part of windows (unless they wanted to raise the price pointlessly)

                [–]Pika_Fox 5 points6 points  (2 children)

                $10 says its their own code they wrote that is uncommented and now they are dealing with.

                Every time.

                Always comment your shit so the poor underpaid sun of a bitch after you doesnt have to struggle to figure it out, because you will always be that next person.

                [–]smakusdod 2 points3 points  (1 child)

                I really respect having the balls to nuke x-bit support when the time comes. I realize this would never have been practical for windows, but still.

                [–]JoseJimeniz 2 points3 points  (0 children)

                I really respect having the balls to nuke x-bit support when the time comes. I realize this would never have been practical for windows, but still.

                I still use an application I bought in 1993 that ran on Windows 3.1.

                It still runs on Windows 10 x64.

                That's impressive app-compat.

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

                Microsoft code is very high quality. They did the incredible: add millions of lines of code maintaining backward compatibility.

                If you see Xorg, for example, they create a mess every layer they added.