WTF Bites



  • @Medinoc said in WTF Bites:

    You'll never actually see a letter with only the postal code and no city name,

    True, though I'd be really to wager that a letter addressed this way would likely reach its destination (with the caveat described below). In big cities (e.g. Paris), the post code is more accurate than the city name, so really specifying the city is just an habit more than anything.

    but on most French websites where you're prompted to type in an address, the site will fill the "city" field automatically once you type in a postal code.

    I think you meant "properly made" websites, as there are still far too many that require you to manually type the city name in addition to the post code. 😠

    Though the other issue here is that actually a post code may refer to many cities, or rather villages, so "properly made" websites need to include a way to select which of the actual villages you want. I did encounter a couple of times websites that half-assed it and automatically filled (and disallowed editing, of course) the city to the main (or first) of the post code, and too bad for you if it isn't the correct one. :angry:

    Most of the time it won't matter, unless the address is ambiguous because the same street exists in several villages ("Church Square", "Republic's Street" or "De Gaulle Street" (or "Leclerc") being very common...).



  • I was going to post another WTF Bite but answering the post above reminded me of a different one, so you'll get even more posts from me!

    I recently went to the main healthcare portal to try and look up some doctors close to where I live. You can fill in what you're looking for (e.g. "GP") and a location and it gives you the closest ones. Simple, right?

    Well I entered my location, which is a village with a name made of several words e.g. "Something over Forest." As I type it I get a popup of matching names where I can pick their preferred syntax (is it " over " or "-over-" etc.), no problem here -- but I mention it because it proves the website correctly recognises the location as a single location, known in their system.

    Hit search, get results. Mmmm, weird, I can see a lot of doctor's names that I had never seen before. Let's click one... it's located in a village called "Forest" which is on the other side of the country. :facepalm:

    My guess is that they correctly recognise the name in the front end but still somehow fail to pass it correctly to their query engine, which does a search on any of the words that form up the name. :picard-wtf:


    Filed under: what if I lived in Something'); DROP TABLE doctors; --?



  • And the last one:

    Browsing through a large 3rd-party code base that does geometry stuff (3D points in space etc.). Stumbling across one class that basically stores a big array of such points, with several tens of methods (:doing_it_wrong:).

    So let's see, there is a function points() that returns the stored array of points, OK.
    scroll
    scroll
    scroll
    Oh, and another function get_points() that, uh... returns the stored array of points. In the same container, with the same const/reference specifiers and what-not. :wtf_owl:


  • I survived the hour long Uno hand

    @remi said in WTF Bites:

    And the last one:

    Browsing through a large 3rd-party code base that does geometry stuff (3D points in space etc.). Stumbling across one class that basically stores a big array of such points, with several tens of methods (:doing_it_wrong:).

    So let's see, there is a function points() that returns the stored array of points, OK.
    scroll
    scroll
    scroll
    Oh, and another function get_points() that, uh... returns the stored array of points. In the same container, with the same const/reference specifiers and what-not. :wtf_owl:

    Don’t worry, the next release will deprecate them both in favor of geti_points_real()


  • Trolleybus Mechanic

    @Arantor said in WTF Bites:

    on Windows

    That's probably a bad idea. I once tried to run PHP on Windows. It crapped itself when I tried to do readdir() on a directory with filenames in different encodings (both cyryllic and western or something like that), haven't tried since. It's clearly not designed to run on non-unix-like platforms.

    Yep, it still isn't fixed.



  • @remi said in WTF Bites:

    Most of the time it won't matter, unless the address is ambiguous because the same street exists in several villages ("Church Square", "Republic's Street" or "De Gaulle Street" (or "Leclerc") being very common...).



  • @sebastian-galczynski you assume I didn’t try. The relevant Lounge thread explains the many tales of everything involved. Running on Windows was the least of the drama.

    Also, Windows uses UCS-2 under the hood so why is it surprising that it doesn’t respond well to UTF-8 filenames?


  • Trolleybus Mechanic

    @Arantor said in WTF Bites:

    Also, Windows uses UCS-2 under the hood so why is it surprising that it doesn’t respond well to UTF-8 filenames?

    That's not the problem. The problem is that when you call readdir() it returns the filenames in 8-bit encoding corresponding to some codepage. Presumably if you have, say, CP-1252 set as the system locale and only use characters from that page to name files, there's no problem.
    But if you already have "bąba_dupą.txt" and "Đ¶ĐŸĐżĐ°.csv" in one directory, it becomes impossible for PHP to correctly list both files at once.



  • @sebastian-galczynski not a problem I ever encountered and I developed on Windows as my dev machine for many years (since PHP 4.0) :mlp_shrug:


  • Trolleybus Mechanic

    @Arantor said in WTF Bites:

    @sebastian-galczynski not a problem I ever encountered and I developed on Windows as my dev machine for many years (since PHP 4.0) :mlp_shrug:

    Well, it's not something you typically encounter in normal apps. I only discovered it while trying to hack together a simple script for thumbnailing and displaying photos dumped in a directory, and it just wouldn't work reliably on Windows because of these encoding problems.



  • @dkf said in WTF Bites:

    uses a now-retired feature in an unusual way

    That's the thing C and C++ are really scarce on. As long as it ever compiled on the mainstream compilers, that is—specialist compilers often did have a handful of weird features that no longer work because the mainstream compilers never had them and the specialist once are long dead.



  • @Arantor said in WTF Bites:

    Also, Windows uses UCS-2 under the hood so why is it surprising that it doesn’t respond well to UTF-8 filenames?

    Windows uses USC-2 (or maybe better call it WTF-16) on the surface too. So if you know what you are doing, you do the conversion from whatever internal encoding your app uses to the WTF-16 and pass that and everything is fine. But if you use the 8-bit API, that's considered legacy only, so that will give you the old codepage of the system locale with no way to change it per application. Most language runtimes have learned to do that conversion for you by now, so PHP seems to be a hundred year behind the apes here.


  • Considered Harmful

    @sebastian-galczynski said in WTF Bites:

    That's probably a bad idea. I once tried to run PHP

    Ob.


  • Considered Harmful

    @Bulb said in WTF Bites:

    @Arantor said in WTF Bites:

    Also, Windows uses UCS-2 under the hood so why is it surprising that it doesn’t respond well to UTF-8 filenames?

    Most language runtimes have learned to do that conversion for you by now, so PHP seems to be a hundred year behind the apes here.

    Java, otoh, can have trouble with Windows paths where names start with u. Regardless of encoding. But, related to encoding.


  • BINNED

    @dcon said in WTF Bites:

    @dkf said in WTF Bites:

    (often in a way that was actually non-standard but which worked fine with a particular implementation)

    Ah... dragons.

    According to the metadata, this is a Manly photo.


  • Notification Spam Recipient

    @dcon said in WTF Bites:

    @dkf said in WTF Bites:

    (often in a way that was actually non-standard but which worked fine with a particular implementation)

    Ah... dragons.

    Fucking dragons! Where they be?!



  • @sebastian-galczynski said in WTF Bites:

    That's probably a bad idea. I once tried to run PHP on Windows. It crapped itself when I tried to do readdir() on a directory with filenames in different encodings (both cyryllic and western or something like that), haven't tried since. It's clearly not designed to run on non-unix-like platforms.

    🔧



  • @izzion said in WTF Bites:

    Don’t worry, the next release will deprecate them both in favor of geti_points_real()

    You're joking (or you're actually working for the company making that software in which case we probably have met...), but...:

    Another class of the same code base can return a "cage" i.e. a sort of 3D box around the points of the object.

    Computing that cage can be costly (if there is no quick heuristic and you have to scan all points, of which there can be a few billions), so to get it the first time (it's buffered internally afterwards) there is a compute_cage(). Not to be confused with get_cage(), which returns the internal buffer. Or actually computes the cage if it's not up to date. Why is compute_cage() exposed to the user (=public)? The only reason is so that you can preemptively take the cost of computing the cage at one moment in time rather than later, but then you could equally well just call get_cage() and ignore the result (and actually I'm not sure if compute_cage() always takes the cost, even if the cage is already up-to-date, if so calling it rather than get_cage() from client code would always be a bad idea).

    But, OK, not the worse design issue, especially considering that the code started as C, then became C-with-classes before being C++, all that well before C++98 was a thing.

    No, the :fun: part here is that the same class also has geometry_compute_cage() which, uh, computes... a cage... around the geometry of the object...? :wtf_owl:

    (of course there is so little and badly-written documentation that there is effectively no documentation, and I don't have access to the source code itself, only the headers)

    And while it seems they have fixed that issue as I can't find it anymore, a few years back it also also had a really_compute_cage() function. :wtf_owl:

    Because it turns out that people complained that compute_cage() was too slow, and in most cases the underlying structure of the points in the object means we can take a shortcut to get the cage, so this was done to make compute_cage() faster. Except that when you're not in "most" cases, that heuristic was wrong, so a way to still compute the slow-but-accurate cage was needed. Hence really_compute_cage(). :facepalm:


  • BINNED

    @remi from your description I’d say normal people call this “cage” a bounding box. đŸč



  • @topspin I don't want to give too many details about the software but there's more to this cage than a simple bounding box, but that's not really relevant here.

    Though it's worth noting that this software definitely was not designed by native English speakers, and that shows in a lot of places.


  • BINNED

    @remi figured that when you said it can be costly, bounding box should be fast. Also feared that the API might be French. 🐠



  • People joke about the mysql_real_escape_string being a PHP problem but it looks to this non-C programmer as if it’s defined right down in libmysqlclient itself and that PHP was just providing a thin wrapper over that.

    Blame MySQL for choosing to have the two separate for not breaking backwards compatibility, not PHP!



  • @topspin said in WTF Bites:

    Also feared that the API might be French. 🐠

    đŸ€



  • @topspin said in WTF Bites:

    bounding box should be fast.

    More seriously, even for a bounding box there's "fast" and "fast." Some of those objects can contain a few billions (usually no more than 1-2, but still) of 3D points, so even just iterating over those and simply checking min/max (for a bounding box) may take a bit of time, because behind the scene that means actually loading that information from whatever optimised storage is used.

    So yeah, it's computationally much faster than about anything you're going to do with those points, for sure, but if e.g. you're just looking at some initial guess of the bounding box to get the magnitude of data, or to initialise some display or other not-very-accurate operation, that might still be considered "not fast."


  • BINNED

    @remi I mean, you have to come up with the data at one point anyway. Maybe spend a few bytes saving the box once when you save a few GB of data.


  • ♿ (Parody)

    @Arantor said in WTF Bites:

    People joke about the mysql_real_escape_string being a PHP problem but it looks to this non-C programmer as if it’s defined right down in libmysqlclient itself and that PHP was just providing a thin wrapper over that.

    Blame MySQL for choosing to have the two separate for not breaking backwards compatibility, not PHP!

    It's always Window's PHP's fault


  • Discourse touched me in a no-no place

    @boomzilla said in WTF Bites:

    @Arantor said in WTF Bites:

    People joke about the mysql_real_escape_string being a PHP problem but it looks to this non-C programmer as if it’s defined right down in libmysqlclient itself and that PHP was just providing a thin wrapper over that.

    Blame MySQL for choosing to have the two separate for not breaking backwards compatibility, not PHP!

    It's always Windows's PHP's fault

    FTF:pendant:


  • I survived the hour long Uno hand

    @dkf said in WTF Bites:

    @boomzilla said in WTF Bites:

    @Arantor said in WTF Bites:

    People joke about the mysql_real_escape_string being a PHP problem but it looks to this non-C programmer as if it’s defined right down in libmysqlclient itself and that PHP was just providing a thin wrapper over that.

    Blame MySQL for choosing to have the two separate for not breaking backwards compatibility, not PHP!

    It's always Windows's PHP's fault

    FTF:pendant:

    ITYM Windows’

    Shirley Windows is a famous enough proper name to get the Moses treatment.


  • Discourse touched me in a no-no place

    @izzion said in WTF Bites:

    ITYM Windows’

    No, I do not. Windows is not a plural in this context, so it uses 's to form the possessive.


  • I survived the hour long Uno hand

    @dkf


  • Discourse touched me in a no-no place

    @izzion To me, the possessive singular case is audibly distinctive even when the base word naturally ends with s, so I write 's.



  • @topspin said in WTF Bites:

    @remi I mean, you have to come up with the data at one point anyway. Maybe spend a few bytes saving the box once when you save a few GB of data.

    Sure, and that's why I said that it's "much faster than about anything you're going to do with those points." But then again, there are cases where you are interested in the box but are not going to actually scan all the data (either not at all, or maybe only later).

    For those cases, scanning all points may be slow. Especially since the object is more than just "a bunch of points," there is some structure/order to them (in some complicated and very domain-specific way), so sometimes you can get whatever information you need without going through all points.

    Usually the box (and what this software calls the cage as well) are indeed saved alongside the rest of the data, whenever it's (re)computed. But it's not always there.



  • @dkf I would write it as Windows's as well.
    Just to be sure I havent't lost my touch, it's Mr Jones's car for one guy but The Joneses' car for the whole family?



  • @remi I wonder how this is implemented on the C++ side. Usually a cache for some long-to-compute value (that doesn't involve modifying the rest of the object) is one of the twothree prominent use-cases where mutable member variables make sense (the other onetwo being synchronization objects and intrusive reference counters).



  • @Medinoc The immediate answer is that it's unlikely that the code is making use of any smart C++ feature since it was initially written before C++ even was a thing. Besides, the whole thing being badly implemented with duplicated functions (in case you forgot where this started from), it's even more unlikely to be written in a vaguely intelligent manner.

    But I think that's beside the point, as I don't see whether storing stuff as mutable or in any other way would make any difference to the fact that scanning a few billions of points is always going to be significantly slower than scanning a few of those only.


  • Considered Harmful

    @izzion Would you say it's Uncle Ben's fault?


  • Considered Harmful

    @dkf said in WTF Bites:

    @izzion To me, the possessive singular case is audibly distinctive even when the base word naturally ends with s, so I write 's.

    I salute your abandonment of spelling regularization.


  • Java Dev

    @Gribnit said in WTF Bites:

    @dkf said in WTF Bites:

    @izzion To me, the possessive singular case is audibly distinctive even when the base word naturally ends with s, so I write 's.

    I salute your abandonment of spelling regularization.

    :laugh-harder:



  • Bing may provide you with some fun. LDL is short for low density lipoprotein, but Bing thinks it's a spelling error of Lidl.
    And now let's go shopping!
    Lidl-Covid.JPG



  • @BernieTheBernie ENOREPRO. I get mainly articles about relationship between LDL and COVID.


  • Considered Harmful

    @Bulb said in WTF Bites:

    @BernieTheBernie ENOREPRO. I get mainly articles about relationship between LDL and COVID.

    Regional sponsored typo.



  • @izzion said in WTF Bites:

    @remi said in WTF Bites:

    And the last one:

    Browsing through a large 3rd-party code base that does geometry stuff (3D points in space etc.). Stumbling across one class that basically stores a big array of such points, with several tens of methods (:doing_it_wrong:).

    So let's see, there is a function points() that returns the stored array of points, OK.
    scroll
    scroll
    scroll
    Oh, and another function get_points() that, uh... returns the stored array of points. In the same container, with the same const/reference specifiers and what-not. :wtf_owl:

    Don’t worry, the next release will deprecate them both in favor of geti_points_real()

    Would that be pronounced like "Yeti" or "Jedi"?


  • Java Dev

    @hungrier Yes.


  • Considered Harmful

    @hungrier said in WTF Bites:

    @izzion said in WTF Bites:

    @remi said in WTF Bites:

    And the last one:

    Browsing through a large 3rd-party code base that does geometry stuff (3D points in space etc.). Stumbling across one class that basically stores a big array of such points, with several tens of methods (:doing_it_wrong:).

    So let's see, there is a function points() that returns the stored array of points, OK.
    scroll
    scroll
    scroll
    Oh, and another function get_points() that, uh... returns the stored array of points. In the same container, with the same const/reference specifiers and what-not. :wtf_owl:

    Don’t worry, the next release will deprecate them both in favor of geti_points_real()

    Would that be pronounced like "Yeti" or "Jedi"?

    Feta.



  • This is heavily anonymized, but the main gripe I have is still in here. Have fun reading the code.
    Oh yeah, errorCode in DataException is int, not Integer.

    public class ExceptionMapper {
      public static void handleDataErrors(Exception e, String source) throws Exception {
        if(e instanceof DataException) {
          DataException de = (DataException) e;
          Integer error;
          if(Objects.nonNull(de.getErrorCode())) {
            error = de.getErrorCode();
            throw new Exception(String.format("Error code %s in source %s, ", error, source));
          }
        }
        throw new Exception(e.getMessage());
      }
    }
    
    

    For those who don't speak Java, this is how it looks when all the superfluous code has been removed (and the stack trace is kept)

    public class ExceptionMapper {
      public static void handleDataErrors(Exception e, String source) throws Exception {
        if(e instanceof DataException de) {
          throw new Exception(String.format("Error code %s in source %s, ", de.getErrorCode(), source));
        }
        throw e;
      }
    }
    
    


  • @Carnage You mean gripe besides the fact it discards the stack trace (by not setting the inner exception), the fact it does a handful of unnecessary checks (the int/Integer dichotomy is ugly in this regard) or the fact the added context does not look all that useful?



  • @Bulb said in WTF Bites:

    @Carnage You mean gripe besides the fact it discards the stack trace (by not setting the inner exception), the fact it does a handful of unnecessary checks (the int/Integer dichotomy is ugly in this regard) or the fact the added context does not look all that useful?

    Yes. And the Objects.nonNull being used. There is so much there I don't like, and all of it inflates the code size a lot for not much use.



  • @Bulb said in WTF Bites:

    @Carnage You mean gripe besides the fact it discards the stack trace (by not setting the inner exception), the fact it does a handful of unnecessary checks (the int/Integer dichotomy is ugly in this regard) or the fact the added context does not look all that useful?

    Not just stack trace; it also gets rid of the exception type and replaces it with the most common superclass, the Exception - which pretty much enforces everyone else to use the "Pokemon Exception Handling" pattern

    PS: :technically-correct: the most common superclass is Throwable, so the author definitely loses some :wtf: points there.



  • @Carnage said in WTF Bites:

    Objects.nonNull

    Yeah, the Object.notNull silently masks the fact that de.getErrorCode() can't return null in the first place. Because Java.


  • ♿ (Parody)

    @Bulb said in WTF Bites:

    You mean gripe besides the fact it discards the stack trace (by not setting the inner exception)

    I wonder what sort of cluelessness this is. Did they do this on purpose because they hate Java's famous multi-layered stack traces? Do they not understand that they're destroying useful information? Do they not know how to pass the inner exception?

    The rest is dumb but this is actively harmful.


Log in to reply