• Confuzzled (unregistered)

    TRWTF is thinking volatile has anything to do with multithreading.

  • Brian Boorman (google)

    if (Confuzzled.comment == "Comment held for moderation") post.comment ("Frist");

  • William F (unregistered)

    Where's the WTF? New person comes in, introduces modern coding practices, starts untangling spaghetti code.... He's not fired, there's no reversal of the new practices. IDGI, this is just a CodeSOD with a story hung on it.

  • Ulysses (unregistered)

    TRWTF is two missing semicolons. FAILURE!

  • spadgas (unregistered)

    TRWTF is comparing a bool with false

  • Helten (unregistered) in reply to Confuzzled

    Sorry, you're wrong :( volatile is used when dealing with hardware access (memory-mapped IO) and in some multithreading situations. Please check the available online documentation.

  • Helten (unregistered) in reply to spadgas

    No, that's a perfectly cromulent comparison. A bool is even true or false.

  • Helten (unregistered) in reply to spadgas

    No, that's a perfectly cromulent comparison. A bool is either true or false.

  • gnasher729 (unregistered) in reply to Confuzzled

    "TRWTF is thinking volatile has anything to do with multithreading."

    Clearly it does. If your compiler is stupid and wrongly assumes that because a variable is not changed in one thread it isn't changed at all, then "volatile" cures it of that stupidity.

  • pie_flavor (unregistered)

    Confuzzled: What do you mean? Volatile means that the access isn't cached. The only time you ever use it is with multithreading.

  • Chris Paterson (google)

    "TRWTF is thinking volatile has anything to do with multithreading."

    Er, the first line of https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/volatile says "The volatile keyword indicates that a field might be modified by multiple threads that are executing at the same time."

  • Harald van Dijk (unregistered) in reply to Chris Paterson

    Right. I think Confuzzled was guessing how volatile works in C# based on how it works in C and/or in C++, where it has different semantics and should not be used for multithreading. Guessing how a language works is not a good idea.

  • Sole Purpose of Visit (unregistered)

    Well, there's some fun to be had by estimating how long it would take you to figure out the problem by staring at the code. (I'm not the best at this, as many C# reviews have made clear, but it took me about 30 seconds. And I wouldn't have used volatile, I'd have used a more appropriate locking/semaphore mechanism, but that's very small beer.)

    TRWTF is, as so often, the submitter. You can follow all the "best practises" in the world, but you kind of need to keep your brain switched on when you do that. In this case the gain from best practises is to automate the build away from a local folder, and the loss is that, for no obvious reason at all, the automated build actually changes behavior by moving from a debug build to a release build.

    Which might have an incremental advantage. Which you could test on the brand spanking new test machine mentioned in the article. Which evidently was not done. (Lacking other details, there might be problems with accessing the web services, although frankly you could still mock these out to some extent.) Which means that you essentially fail at the first hurdle of an automated deployment, which is to make sure that it actually bloody works.

    Oh, who am I kidding? The actual real WTF is the use of web services in the first place. They have their role, but not as a giant unknowable abstraction slapped into place, as here, in place of a rational IPC. Web services in 2018 seem to be about as well-thought-out as Corba interfaces in the 2000s. And equally as brittle.

  • Brian Boorman (google) in reply to Chris Paterson

    I've always used volatile to indicate memory mapped hardware peripheral registers in embedded systems.

  • Medinoc (nodebb) in reply to Confuzzled

    C-language volatile has, according to the C standard, nothing to do with multithreading.

    Microsoft has a habit, in its compilers, of extending its meaning to include "multithread-proof", since at least the Visual C++ 6 days. It's natural that they would make this an official language feature when designing C#.

  • Duke of New York (unregistered)

    Sam replaced the function with inceptPassword, which encodes it twice

  • Duke of New York (unregistered)

    Oh, darn

  • Anon (unregistered)

    TRWTF is "the very first thing he did was refactor the code to actually properly handle multiple threads".

    Since the code was using an asynchronous method, but behaving synchronously to the caller, the first thing he should have done is simplify the code but make it work properly...

        client.doThing(args); // remove Async
        return "SUCCESS!" //seriously, this is what it returns
    
  • Joseph Osako (google)

    ITwerk it, yeah yeah, ITwerk it...

  • TBeholder (github) in reply to Sole Purpose of Visit

    And that's TRWTF: "we even have a test machine… but we don't actually test our releases on it".

  • TheNobody (unregistered) in reply to Confuzzled

    volatile does have a lot to do with multithreading, just typically not in a way people assume.

    volatile prevents compiler from caching value, therefore everytime you read from or write to this variable it will happen without any caching, as in if you use variable 5 times then it'll be read from RAM 5 times, but without volatile it will be read only once. But volatile doesn't mean reads and writes cannot be rearranged so it's still not suitable for synchronization.

Leave a comment on “2017: Nature, In Its Volatility”

Log In or post as a guest

Replying to comment #:

« Return to Article