• P (unregistered)

    Jerry did not hold his mutex correctly, hence why he was let go.

  • bvs23bkv33 (unregistered)

    real wtf is link in article going nowhere

  • Hans (unregistered)

    Did Jerry use CI to (try and) build his code? Else why would he commit code that doesn't compile?

  • Alistair (unregistered) in reply to bvs23bkv33

    https://thedailywtf.com/articles/butting-in

  • (nodebb) in reply to Hans

    C++ takes forever to compile, so the obvious "clever" solution is to let CI handle the compiling and work on something else to reduce "unnecessary" downtime. Although I don't quite get why one would actually pass on an opportunity for more coffee breaks.

  • (nodebb) in reply to a person

    C++ takes forever to compile

    Heavily templated C++ takes forever to compile. If you can reduce the number of template instantiations, you can speed the compilation. Of course there are various things that "hide" templates inside, such as std::string and std::cout.

    If you're trying to use the maximum quantity of the features of Alexandrescu's "Modern C++ Design", then you're going to disappear down a vicious rabbit-hole of time lost watching your code fail to compile because it blows out the compiler's template limits.

  • -to- (unregistered)

    If anyone wonders, you can declare your mutex "mutable" for this sort of situation.

    https://en.cppreference.com/w/cpp/language/cv

  • (nodebb)

    The gap between the worst code and the best code in the world is wider than the distance to the Moon.

  • Pietro (unregistered)

    Funny how, in the end, C++ provides enough facilities to render "const" meaningless. Just stick "mutable" in front of class members, just cast away constness. Same thing with private members, just have "friend"s and voilà, private means nothing anymore.

  • TruePony (unregistered)

    How could Jerry’s code be wrong? It compiled! Dana ought to have submitted a bug report to the compiler vendor. https://thedailywtf.com/articles/Flawless-Compilation

  • SPiT (unregistered)

    I think my favorite ever was when somebody implemented a whole class using locally declared mutexes in each method and they had no idea why that was wrong.

  • maurizio (unregistered)

    The real wtf is C++. OK, i am a Java programmer ....

  • I'm not a robot (unregistered) in reply to Mr. TA
    The gap between the worst code and the best code in the world is wider than the distance to the Moon from the Andromeda Galaxy.
    FTFY
  • Robert (unregistered)

    The real WTF is a high-level employee implementing CI principles incorrectly. I guess he doesn't believe in Test-driven development or build servers for what he was attempting to do.

  • VI (unregistered)

    I don't understand (or speak C++) - if the function can't change anything, does it actually need a mutex (or for that matter, exist at all)? Or is Jerry redefining lock() for all of Mutex in that magic?

  • sizer99 (google) in reply to Pietro

    C++ is a spinny ball of sharp bits. In exchange for high speed and low memory use it will very happily let you hang / cut yourself. All the const modifiers make perfect sense. You declare to the compiler with const that nothing meaningful in this class will change, so it can work on it at high speed without some of the protections. Then you may need to tell the compiler that this 'unimportant' bit of the class is mutable. If you lied about that mutable thing still letting the class be idempotent, well, you're screwed. Like so many other things in C++.

    If you didn't need the speed and low memory use then you'd be much better off just using C#. Or there's Rust as a compromise.

  • Raj (unregistered) in reply to Robert

    With Jenkins scripts and cheap EC2 instances it's becoming increasingly tempting to do "CI-based debugging". Just commit stuff and wait for the notification. It's almost like buying scratch tickets (OMG it compiled!).

    I'm not saying it's a good thing, but it's easy so it's not going away anytime soon.

  • Butt Police (unregistered) in reply to Hans

    Correct. Most of the team used local environment for development (with incremental compiles it was “fast”, took minutes). But Jerry never managed to make his work, and despite our many offers (a container? A VM? You can SSH to one of our machines?! We can SSH on your machine and install it for you?!?!) preferred instead to use the tried and true method of committing to master and waiting an hour for the CI build process to complete.

    The only occasions when he didn’t break master for hours every time he committed was when the feature was big enough he accepted it required a feature branch. We would configure CI for the branch and he would happily break it instead.

    By the end we had mostly mind tricked him into using a “feature branch” for his development, but that had its own troubles: his friend lost months of work in a functionality because he had branched months ago and never rebased, so the code was irreconcilable.

  • Butt Police (unregistered) in reply to VI

    The thing that the function was changing was a sort of logger object. In C++ output streams aren’t thread safe. I don’t remember exactly how the object was set up (whether the logger was mutable or the logging function was const), but the whole thing was horrible: standard for Jerry.

  • I dunno LOL ¯\(°_o)/¯ (unregistered)

    TRWTF is checking in code without compiling it locally. (but TRRWTF may be template spaghetti so thick that it takes forever to compile and encourages morons to do this)

  • (nodebb) in reply to -to-

    Yep, the mutable keyword exists specifically for synchronization objects, cached computation results and intrusive reference counts. I have yet to find any other "legitimate" use for it.

  • o11c (unregistered) in reply to Steve_The_Cynic

    Heavily-templated C++ can be made to compile faster if you use extern template appropriately.

    This, of course, is much easier if you have forward declarations of all your classes in one place.

  • (nodebb) in reply to Steve_The_Cynic

    Someone should tell every C++ programmer out there that just because you can (ab)use C++ Templates as a form of functional programming with ugly syntax, it doesn't mean you should do that.

  • (nodebb) in reply to VI

    The answer is yes. If the object has multiple instance variables and they need to be logically consistent in some way, you need to make sure that, when you read them, nothing else is halfway through modifying them.

    Imagine for instance, an object that represents a linked list. You want to read the 10th item on the list which you can only do by traversing the list until you reach the 10th item. Although you are not changing the list in any way, you don't want to be traversing the list while some other thread is in the middle of inserting a new element anywhere before the 10th one.

  • fintux (unregistered) in reply to Pietro

    It's also funny how scissors get dangerous when you start running around with them.

    So yes, these features can be dangerous. But you should only use them when you know what you're doing and do things correctly. When you know how to use them, they will be useful. Just like scissors.

Leave a comment on “Compiled Correctly”

Log In or post as a guest

Replying to comment #:

« Return to Article