Frontpagify this code snippit and win a prize!


  • sockdevs

    Continuing the discussion from Not to be compared to a number:

    @Dragnslcr said:

    @accalia said:
    ```
    for (int i=0; i < 2limit; ++i++) {
    //some code
    //about half wayu through
    short j = i/2;
    // more code using j this time, and some that uses j
    2
    }

    
    Why isn't this on the front page?</blockquote>
    
    Now there's an idea.
    
    Alright then. I'm offering a bounty of $40 payable through a google wallet transfer or Amazon Gift Card (your choice) to the person who submits the most frontpagiest frontpagification of the code snippit i found in production. Submissions will be accepted through [Noon on 10/27 (local)](http://currentmillis.com/countdown/?millis=1445961600000&text=Submission%20Deadline) with the winner to be announced no more than twelve hours after submission deadline.
    
    Special prizes may be awarded to particular spectacular entries in addition to the grand prize.

  • Discourse touched me in a no-no place

    @accalia said:

    ++i++

    twitch


  • sockdevs

    @antiquarian said:

    twitch

    that was my reaction too. you can be sure that the developer responsible for that code was justly showered with a hail of automatic NERF fire from a highly modified RapidStrike CS-18



  • My submission follows:

    Once upon a time, WTDWTF user @accalia found this code in production:

    for (int i=0; i < 2limit; ++i++) {
    //some code
    //about half wayu through
    short j = i/2;
    // more code using j this time, and some that uses j
    2
    }

    >and wow that code is bad. The end.
    
    Just so that I can win by default if no one else enters.


  • @accalia said:

    CS-168

    You accalia'd that.

    I don't even like Nerf, I just googled it


  • sockdevs

    @anonymous234 said:

    My submission follows:

    Once upon a time, WTDWTF user @accalia found this code in production:

    for (int i=0; i < 2limit; ++i++) {
    //some code
    //about half wayu through
    short j = i/2;
    // more code using j this time, and some that uses j
    2
    }

    >and wow that code is bad. The end.
    
    Just so that I can win by default if no one else enters.</blockquote>
    
    that's not very frontpagified.... 
    
    in fact it's not very frontpagified at all....
    
    can i accept such an unfrontpagified entry in a frontpagification contest?
    
    i'm going to have to take that one up with the judges...
    
    OI! Accalia, accalia and ACCALIA! We gots a question for you!

  • sockdevs

    @rc4 said:

    @accalia said:
    CS-168

    You accalia'd that.

    I don't even like Nerf, I just googled it

    <_<

    looks fine to me.....

    >_>



  • Can someone explain the WTF to me? I'm a decent writer but a shitnon-programmer. If they do I can take a stab at it.


  • sockdevs

    @rc4 said:

    Can someone explain the WTF to me? I'm a decent writer but a shitnon-programmer. If they do I can take a stab at it.

    ++i means "add one to i, save the new value in i and use the new value"

    i++ means "use the current value of i, then add one to the stored value"

    ++i++ means "accalia will shot you with NERF.... a lot."



  • Hmm. Still don't quite get it.


  • Winner of the 2016 Presidential Election

    @accalia said:

    ```
    for (int i=0; i < 2limit; ++i++) {
    //some code
    //about half wayu through
    short j = i/2;
    // more code using j this time, and some that uses j
    2
    }

    
    @rc4 <a href="/t/via-quote/51959/10">said</a>:<blockquote>Hmm. Still don't quite get it.</blockquote>
    
    According to <a href="http://en.cppreference.com/w/cpp/language/operator_precedence">this</a>, that:
    0. Doesn't do what's intended, and
    1. Is still valid.
    
    Postfix-version has priority, so if I remember things right, that means the prefix-version is only going to operate on a copy of the value.  Meaning that the for-loop only increments by 1 when the appearance suggests it should increment by 2.  That is, ++(i++) is the order it should be evaluated in, and since the inner operation returns a copy of the value, the outer operation is effectively a no-op (in context).


  • Ah. That's what I had thought but I wasn't quite sure since that seemed like a fairly minor "oh wow that was redu­mbdant but whatever" thing to me. :laughing:


  • Winner of the 2016 Presidential Election

    What language even allows such nonsense? My gcc compiler hates you for trying that, Javascript kills itself... like, really now, what language are you writing in?

    Also: Ideones compiler hates this, too:
    https://ideone.com/ZDZjcE

    Filed Under: So... yeah... rewrite in MUMPS, pls!


    @rc4 said:

    That's what I had thought but I wasn't quite sure

    Pretty sure the author playing around by making i twice as high as the limit and then dividing it by 2 to use it (and sometimes use it multiplied by 2) is also pretty :wtf:

    Also, correct me if I am wrong, but isn't a short for j a terrible data-type here? If limit is high enough (unless that is also short... but then why would i be an int?) j will overflow, right? I mean, maybe the limit-logic doesn't allow for this but still...

    Filed Under: this is pretty bad code, alright?

    Addendum: totally :hanzo:'d @Dreikin

    second Addendum: :hanzo:'d him by posting a :hanzo:


  • Winner of the 2016 Presidential Election

    Wait, no, running it here fails. Pre-increment needs an lvalue, and that is apparently not what post-increment returns.

    Dangit, :hanzo:d



  • What you you people talking about with all these ninjas? I already covered it.


  • Winner of the 2016 Presidential Election

    :hanzo:-ception! But you were in another dream so that doesn't count :smiley:

    Filed Under: Still unsure whether or not I should try to write something up for this just for fun!



  • I haven't done this style of writing before, it feels really awkward.


    Alice A. was hired on as a consultant for Winston & Turner Facilities to "smooth out" production issues. It sounded off, but she needed the money. W&TF provided various rentable facilities for various purposes, and it was important to be able to search for the kind of facility you needed near the place you needed it. It just so happened that that particular functionality was broken, and Alice's first task of the day was to fix it. She logged in, checked out the code, and ran the application. All the search result descriptions were correct, but the search result titles were duplicated in pairs of two.

    "Hmm," she thought, running the SQL query. Nothing wrong there.

    "Hmm", she thought, running the client side code that called the query. Nothing wrong there.

    Then she noticed a warning being emitted from the area of the code she was investigating:

    com/wtf/facilities/search.cpp:9042:32: warning: non-standard extension -fincrement-rvalue used
    

    On a whim, Alice disabled the feature:

    com/wtf/facilities/search.cpp:9042:32: error: lvalue required as increment operand
      for (int i=0; i < 2*limit; ++i++) {
                                    ^
    

    "It's going to be a long week," she thought.



  • @LB_ said:

    I haven't done this style of writing before, it feels really awkward.

    Harder than it looks, isn't it? Makes me have more respect for the front page writers.


  • Winner of the 2016 Presidential Election

    Btw, fixed it for you:

    #include <iostream>
    using namespace std;
    
    int main() {
    	for(int _ = 1; _ <= 20; ++++_) {
    		std::cout << (_ >> 1) << std::endl;
    	}
    	return 0;
    }
    

  • area_deu

    Where is my cornify?


  • Winner of the 2016 Presidential Election

    Counting makes you a better programmer <!-- titles are hard! -->

    Bob worked for his company WTF-tech for quite a while now. He had seen many a coworker come and leave and sat through a lot of managements decisions - the good as the bad.
    Today was one of the days where both events happened at once. A new coworker joined the crew and not just anyone. Management had - according to the meeting last week - spared neither time nor money to find the best candidate HR would approve of.
    The newcomer was called John Doe, which on it's own is not a particularily interesting name, but his last name bore a striking resemblence to the CEO Jonathan Doe. "Must be a coincidence", Bob thought to himself and started his routine workflow. It was not the first time that Bob had been wrong. <!-- for example, he thought he'd do this job for the rest of his life... but I am getting ahead of myself -->

    About an hour later (and 55 minutes late according to company practice) the new super talent entered the cubicle farm for the first time. Bob knew this because the cubicle next to him had been free for a while now and since it was the closest one to the windows it was promptly reserved for the newcomer.

    Bob sighed, stood up and looked over his cubicle wall to at least greet his new neighbour. Maybe this could be the beginning of a new friendly work relationship, or at least turn out to be a good excuse to stop working and get some new coffee.
    As he looked over, opening his mough to utter a simple greeting, he was interrupted by a greeting from the other side:
    "Hey, I am new here. My name is John Doe. I am a programmer! Pretty good one, if you ask me. I am currently settling in and might have some questions for you right now. Could you help me out with a pet project of mine? That'd be great, thanks! Just come over. Come on. Come on."
    Periods were merely a vague suggestion of pauses and there was no point in time where Bob could have interrupted John. <!-- I thought about not adding periods at all! This is all for your enjoyment, reader! -->
    Slightly overwhelmed by the flow of words coming from the other side Bob muttered his "hi" and then agreed to meet John in 5 minutes after he had gotten himself some coffee.

    5 Minutes later Bob had collected himself once more. The coffee definitly helped and he was ready to tackle the newcomer once more!

    "So, whats this project about?", said Bob. That seemed like a good way to start a conversation. He could probably just zone out for a bit and ignore the swall of words that would try to explain some random project he had no stakes in.
    "Doesn't matter what it's about right now", John exclaimed, "I am trying to compile this masterpiece and it won't work. This compiler must be broken!"
    Bob looked at the retina display in front of him.

    SecretProjectDoNotSteal.cpp:5:28: error: lvalue required as increment operand

    was flashing on the console window <!-- true story: I have a google-drive folder that is called "SUPER SECRET GOVERMENT FILES DO NOT STEAL.. I hope the NSA can take a joke... -->
    "Let me take a look at the code", said Bob while reaching for the Laptop.
    "NO!!!!!!", his wrist was hit by Johns hand, "you just want to steal this code for yourself. To make all the money that rightfully belongs to me! It will not go this way.Just tell me what is wrong. I'll fix it myself"
    Bob was slightly perplexed. "You asked me to help", he said, "How am I supposed to know the error if I can't see your code?"
    This apparently was the straw that broke the camels back. What could have been a friendly collegial relationship turned sour within the first 6 minutes. John started pushing Bob out of his cubicle while yelling something about unprofessional behaviour and terrible work ethics.

    Confused and slightly angry Bob returned to his desk and finished his work.
    For the rest of the week, John refused to acknowledge Bobs existance and at the beginning of his next week John didn't arrive in his cubicle anymore.
    Bob asked some of his coworkers and from what he could pierce together John had complained to management that he could not work with such unprofessionals and was promptly placed in the higher programming tier, usually reserved for Gurus and highly paid consultants.

    When going back to his desk, Bob walked past Johns old cubicle and noticed the macbook still sitting there, the status LED still burning. He walked inside and moved his finger over the touchpad. And wouldn't you know it, the macbooks display came back to life and showed an IDE with the program John was working on still loaded up. <!-- I am so totally hoping nobody with a macbook calls me out on this and tells me you can't boot it back up by moving the mouse or something! -->
    Bob couldn't resist, he just had to take a look!

    // Johns first program! DO NOT STEAL!
    // Copyright John Doe FOREVER!!!!!!!!
    #include <iostream>
    long limit = 1000000;
    for (int i=0; i < 2limit; ++i++) {
    // there must be an error in the following lines:
    short j = i/2;
    std::cout << j;
    std::cout << j
    2;
    }

    Bob wasn't sure what to think of this. Maybe it was for the best that he didn't have to directly work with John. Maybe there was a reason John wrote this code that made everything crystal clear. Maybe there is a need for people like John?
    Only one thing was clear for Bob, now that John had ascended to the upper programming tier, there was no reason for Bob to not update his CV.

    Filed Under: Yeah, it's probably terribly written. I don't really feel like entering this contest, either. Also, there are a lot of grammar and spelling errors. I apologize but it's getting late and I had a hard time writing this :D

    Addendum: Added some secret flavour for @aliceif :D



  • @Kuro said:

    Also, there are a lot of grammar and spelling errors.

    I'm betting they're intentional to impress the judge!



  • Even PHP gives a parse error if you try ++$i++.


  • Winner of the 2016 Presidential Election

    Damn, you found out :smiley:

    @Dragnslcr said:

    PHP

    TRWTF! Why would you even attempt this? :smiley:
    But wait, if no sane code ever accepts this, did @accalia just frontpagify her own code to make us frontpagify it further?

    Filed Under: The mystery deepens


  • :belt_onion:

    @Kuro said:

    Bob walked past Johns old cubicle and noticed the macbook still sitting there

    Unbelievable coincidence? You must have learned from the best.

    So when can you start working as a front-page author?


  • Winner of the 2016 Presidential Election

    He even has HTML comments.

    I think he already is...


  • Winner of the 2016 Presidential Election

    @JBert said:

    Unbelievable coincidence?

    Thats what happens if you just start writing stuff and need to bring stuff to an end later on :smiley:
    To be completely honest, the story was supposed to go a different route that focused more on the multiple WTFs. But then I remembered that most frontpage articles don't do that, either so I went at it more liberally.

    @Onyx said:

    I think he already is...

    Do I need to add @Remy to my long name?
    Filed Under: I am pretty sure I used like 5 different front page articles I read a few years ago as reference ... and I still messed up :D



  • And I'm sour about no sick references...


  • Discourse touched me in a no-no place

    @rc4 said:

    Hmm. Still don't quite get it.

    Using both forms of increment together is undefined behavior--which executes first, the preincrement or the post? (in this case I think it doesn't actually matter because it's the third part of the loop, but I'm not positive.)


  • sockdevs

    @FrostCat said:

    (in this case I think it doesn't actually matter because it's the third part of the loop, but I'm not positive.

    it does actually matter though.

    if the postincrement evaluates first the result adds 1 and if the preincrement evaluates first the result adds 2

    assuming the compiler will accept it. Most won't.


  • Impossible Mission Players - A

    @FrostCat said:

    crement

    Wow. My flash-read parser keep reading these as "excrement".


  • Winner of the 2016 Presidential Election

    @FrostCat said:

    Using both forms of increment together is undefined behavior--which executes first, the preincrement or the post? (in this case I think it doesn't actually matter because it's the third part of the loop, but I'm not positive.)

    @accalia said:

    if the postincrement evaluates first the result adds 1 and if the preincrement evaluates first the result adds 2

    In this case, there is a defined OoO (post- then pre-). But that results in passing the wrong category* of object to pre-increment, which is a compiler error. (If my memory and interpretation of testing is correct, that is).

    *: pre- and post- require an lvalue as input, but the return of the post-increment is not an lvalue.

    EDIT: Linkified.



  • Code snippet prompts investigation

    A dangerously incompetent code snippet discovered by @accalia in a production environment has prompted an investigation into coding practices at an organization. The snippet not only implemented a loop using non-standard algorithmic strategies, but also involved an apparently illegal combination of operators.

    @accalia is reported to have said that she felt justified in , "...turning around and unloading an entire clip [...] at the developer who wrote that."* Other developers reported similar feelings; one suggested the use of "a highly modified RapidStrike CS-18". The news asked authorities for more information about this weapon but did not receive a response by deadline.

    The Code [city] police are seeking to identify the unnamed developer who created the snippet. There is also an investigation into whether the entire incident is the result of a conspiracy; and a separate inquiry into whether any of the developer threats constitute a crime. Also, the FBI is considering whether any of these events are of national security concern.

    A bounty of $40 has been offered for an information related to an appropriate analysis of the snippet.

    * It is true that @accalia did not exactly say this, but what is a front page story without a deliberate misquoting?



  • @accalia said:

    frontpagiest

    I assume you mean "Featured Article" frontpagify, and not CodeSOD frontpagify?


  • sockdevs

    @Lorne_Kates said:

    I assume you mean "Featured Article" frontpagify, and not CodeSOD frontpagify?

    your would be correct as i consider featured articles to be more frontpagy than CodeSOD

    ;-)



  • @Lorne_Kates said:

    I assume you mean "Featured Article" frontpagify, and not CodeSOD frontpagify?

    I'm gonna assume she meant "Yahoo clickbait" frontpagify.


    Filed Under: You Will Not Believe What This Developer Found In Her Codebase, But It Will Break Your Heart



  • Huh. I guess I'm never poking fun at clickbait again, this shit actually works.


    Filed under: hope you two enjoyed your everyday dose of zombo.com



  • <!-- Not realistic ... you have been warned -->

    Matthias Ginglehern had been at CooKuClok Corp. for 22 years. High in the mountains of Westphalia, the employees of Seekayseatoo (as it is affectionately known) worked tirelessly to design the very best of software for the most particular of clients - grape harvest management software for customers in the Loire valley.

    One inauspicious Wednesday <!-- Wednesday, really? Don't all bad things happen on Mondays and Fridays? Is *nothing* sacred any more? --> afternoon, after a fine lunch of strudel and bratwurst Matthias was just propping up his feet for a customary half hour nap when a co-worker knocked on the door of his well-lit corner office. "Matthias, we have a problem".

    Two hours later the plane touched down at Château Légèrement Moins Rigide

    "Pierre", Matthias inquired, "just what is going on here?"

    «Je ne sais pas mon capitaine, mais j'ai la quivering runs» replied the normally stoic Pierre, his gestures indicating that the bowel trouble had been relentless.
    «Voila, ici».

    The ancient Mintel terminal glared back at Matthias. He sighed, and proceeded to sign in.

    Château Rigide was one of Seekay's biggest and oldest clients. A prominent force in the region winning them had been key to Seekay's success. It didn't help that the president's daughter had been the one to land the contract. Much had been promised them and much had been delivered in a flurry of activity and shifting priorities that Matthias was very glad were long behind him. The installation was custom even for CKC2's clients and had not been touched since it was installed 21 years ago. So why had a system which had chugged along so valiantly decided to act up right in the middle of the busiest time of the year?

    The hours turned into days. The brie and raspberries gave out, and his welcome was flat as a four day old French '75<!-- :cocktail: if you're wondering -->. The sweet cherie responsible for landing the contract sweet-talked the owner into giving him one more day. Late that evening, as the bells of nearby Saint-Martin des champs were tolling eleven he nearly spewed his coq au vin all over the monitor. «Feuervögel», he exclaimed, "who on earth ..."

    There was no source control, no way to find the culprit - the mystery would haunt him:

    for (int i=0; i < 2*limit; ++i++) {
        void* vp_d = ck_gw_tank_expiration(**i);
        short j = i/2;
        if (ck_gw_tank_unlocked(*j) && j*2 --> j+j) ck_gw_set_rotate_date(*i, **i, vp_d)
        else gw_ck_set_rote_date(*j, **j)
    }
    

    There was no way he could fix this. There were no tests, and after days of searching through the code he was certain of only one thing - any changes made would result in a bevy of additional bugs rearing their ugly heads. With one last sigh, he reached over and flipped the monitor off. As he walked out of the dark basement and into the light of the early morning he did the only thing he could do. «Schnucki», he said cheerfully, lifting his phone to his ear, "pack your bag, pick up those tickets for Martinique and head for the airport. I'm retiring".



  • @accalia said:

    int i

    @accalia said:
    short j = i/2;

    Dividing by two halves the number of bits. You didn't know?



  • @svieira said:

    Mintel terminal

    doubt many of those around here have seen that marvel: have a ++


  • :belt_onion:

    Do you mean the Minitel terminal?



  • Oh god yes! The first image looks like the exact damn device I used


  • Winner of the 2016 Presidential Election

    For a front page article, we need more misspelt foreign names. Also, you didn't accidentally confuse different European countries/cultures. 7/10



  • @ben_lubar said:

    Dividing by two halves the number of bits. You didn't know?

    :wtf:

    I hope you're jesting. Taking the square root halves the number of bits. Dividing by two only reduces the bits by one bit.



  • :checkered_flag:


  • mod

    Obviously in this embedded system, there aren't luxuries like binary; everything's in base-1 to save space.


  • Discourse touched me in a no-no place

    @CoyneTheDup said:

    Taking the square root halves the number of bits.

    Actually, it's going to a short that halves the number of bits. This is because normal tall bits can't be used, and dwarf bits have to be used instead. Unfortunately, these dwarf bits are microaggressed so much that it takes two of them to add up a full bit, and the effective number of bits is halved. :straight_ruler:


  • Winner of the 2016 Presidential Election

    @ben_lubar said:

    Dividing by two halves the number of bits

    The logical conclusion is that this is an embedded environment with no file system, and it uses 2 bit ints and 1 bit shorts, for space.

    Sometimes of course, you need more space. That is what long (256 bit) and long long (4096 bits) are for



  • @CoyneTheDup said:

    "...turning around and unloading an entire clip [...] at the developer who wrote that."*
    ...

    • It is true that @accalia did not exactly say this, but what is a front page story without a deliberate misquoting?

    Oooh...nice flamebait.


    Filed Under: INB4 MAGAZINENOTCLIP


  • sockdevs

    tick tock tick tock

    the time is almost upon us!

    Submissions are due at 12 noon Eastern Time Today! (that's just two and a half hours from now!)

    Winners will be announced not lessmore than twelve hours after submissions are due!

    Thank you to everyone who has (or will) submitted a frontpagification!


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.