- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Jerry did not hold his mutex correctly, hence why he was let go.
Admin
real wtf is link in article going nowhere
Admin
Did Jerry use CI to (try and) build his code? Else why would he commit code that doesn't compile?
Admin
https://thedailywtf.com/articles/butting-in
Admin
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.
Admin
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
andstd::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.
Admin
If anyone wonders, you can declare your mutex "mutable" for this sort of situation.
https://en.cppreference.com/w/cpp/language/cv
Admin
The gap between the worst code and the best code in the world is wider than the distance to the Moon.
Admin
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.
Admin
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
Admin
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.
Admin
The real wtf is C++. OK, i am a Java programmer ....
Admin
Admin
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.
Admin
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 ofMutex
in that magic?Admin
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.
Admin
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.
Admin
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.
Admin
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.
Admin
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)
Admin
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.Admin
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.
Admin
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.
Admin
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.
Admin
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.