Jump to content
The Dark Mod Forums


Active Developer
  • Posts

  • Joined

  • Last visited

  • Days Won


stgatilov last won the day on January 29

stgatilov had the most liked content!


2430 Deity


About stgatilov

Contact Methods

  • Website URL
  • Jabber

Profile Information

  • Gender

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Single Status Update

See all updates by stgatilov

  1. Bumped into an interesting piece of wisdom called Hyrum's Law:
    With a sufficient number of users of an API, it does not matter what you promise in the contract: all observable behaviors of your system will be depended on by somebody.

    1. Show previous comments  2 more
    2. stgatilov


      Love and hate are close friends 😉
      Also: there are libraries that everyone complains about and libraries that nobody uses 😁

    3. STiFU


      I'd be curious to hear some actual examples where the MSVC implementation of STL diverges from what the standard dictates and developers actually rely on that divergence. I honstely can't imaging there are any instances. The only thing I could think of is that some programmers might rely on implementation where the standard indicates "undefined behaviour", but that would be a major error on the programmers part.

    4. stgatilov


      One example from recent practice: I had to advise my colleague to not use std::hash<int>, because while it makes some useful things on MSVC, it is a plain identity function for integers on GCC. That's because standard does not control the quality of hash functions at all, so GCC decides to put the hash finalizer into the hash table. I think he just used boost hash function in the end: it has same implementation on all platforms.

      Another case is C++11 random. We all know that C rand sucks for many reasons, and different algorithm on different platforms is one of the reasons. For testing purposes, it is often desirable to have exactly the same PRNG on all platforms. For that reason C++11 generators are fully defined by the standard: std::mt19937 works exactly the same way on Windows and Linux. But the distributions are not fixed. So if you use std::mt19937 + std::uniform_int_distribution, then you'll get different results on MSVC and GCC. Reinvent that wheel yourself 😉

      Another example might be std::deque. Ideologically, people expect it to be a linked list of chunks. But it seems (I did not test this myself, I prefer reinventing such wheels) that MSVC implementation has very small size of chunks, so it boils down to be a worse version of std::list.

      In all of the cases, all implementations fully comply with the standard requirements. But as a programmer, you might expect or implicitly rely on some properties in terms of performance/reproducibility and thus depends on implementation details, which are not cross-platform.

  • Create New...