WTF Bites



  • @djls45 said in WTF Bites:

    @Bulb said in WTF Bites:

    @Gąska Yes, in Czech also. In my previous job we ended up with many methods like ActualSpeed and ActualPosition (meaning current speed and current position, of course) due to somewhat poorer command of English by the programmer who wrote them.

    As a native EnglishAmerican speaker, those seem perfectly cromulent. They could be differentiated from FutureSpeed and PredictedPosition or historical variants of the same.

    Or ReportedSpeed and ReportedPosition.

    The user is often privy to much less information than they think. We say it's for their own good. What it's actually for is cutting on the complaints about meaningless trivialities.


  • Discourse touched me in a no-no place

    @acrow said in WTF Bites:

    What it's actually for is cutting on the complaints about meaningless trivialities.

    It's about stuff they can't do anything about and won't understand in terms of anything they've been used to at that point unless they take an extensive training course.

    It's much like how one of my coworkers likes to make things configurable, and creates lots of options that people can change. But most of them are for things that users (and the rest of the team!) definitely won't understand, and the habit of throwing an uninformative exception when the config parameters are wrong doesn't really assist: we end up with users complaining that their Python code doesn't work and they can't understand why. A more sensible setup involves making everything self-adapt to the parameters that the users can comprehend, and then just warn when that results in something that might be a problem (we can only really detect if it was an actual problem for real after the fact; there's too many stochastic processes involved to do otherwise). That's far far better in practice. Over-configurability just pushes the problems that you failed to solve as a programmer into the user's face, and they're far less able to deal with it.



  • @dkf There's that.

    And then there's such things as indirect measurement of a value. Like, say, measuring the power consumption of a device. By measuring the current and voltage after the PSU. But what the customer wants to know is the consumption including the PSU. Which we can calculate via lookup from the PSU's typical efficiency graph.



  • @dkf said in WTF Bites:

    Over-configurability just pushes the problems that you failed to solve as a programmer into the user's face, and they're far less able to deal with it.

    Which is exactly why most do it. More so asking stupid questions with pop-up dialogs.



  • Representative lines from script with which we are trying to install our code on a device the customer wants:

    #rm -f is broken on the DE-VILCE thats why we need 2>/dev/null || true
    rm -rf /system/ourapp /data/ourapp 2>/dev/null || true
    
    # toybox version of find on device does not cope well with dangling symlinks.
    # As a workaround parse its error output.
    find -L "$fs" -type l -xdev 2>&1 \
        | grep -E "^find: .+: No such file or directory" \
        | sed -e 's/^find: //' -e 's/: No such file or directory$//' \
        | while read; do
    

    For :raisins: instead of some normal embedded Linux, the device uses AOSP core, version somewhere around Nougat (we don't know exactly). No, it's not full Android, it's just uses the core, so we can't do things the Android way and we can't do them the Linux way…


  • Considered Harmful

    @Bulb said in WTF Bites:

    # toybox version of find on device does not cope well with dangling symlinks.
    # As a workaround parse its error output.
    find -L "$fs" -type l -xdev 2>&1 \
        | grep -E "^find: .+: No such file or directory" \
        | sed -e 's/^find: //' -e 's/: No such file or directory$//' \
        | while read; do
    

    For :raisins: instead of some normal embedded Linux, the device uses AOSP core, version somewhere around Nougat (we don't know exactly). No, it's not full Android, it's just uses the core, so we can't do things the Android way and we can't do them the Linux way…

    I really am starting to agree with Blakeyrat about the Linux ecosystem. WhyTF is the standard practice to parse the text interface of CLI tools instead of providing an API?



  • @error said in WTF Bites:

    WhyTF is the standard practice to parse the text interface of CLI tools instead of providing an API?

    Text CLI tools are an API is the Unix philosophy from the start. It might seem kludgy and hacky and quirky and all, but it turned out to be extremely practical.



  • Because proper APIs are hard; let's go hacking!


  • Considered Harmful

    @Bulb said in WTF Bites:

    @error said in WTF Bites:

    WhyTF is the standard practice to parse the text interface of CLI tools instead of providing an API?

    Text CLI tools are an API is the Unix philosophy from the start. It might seem kludgy and hacky and quirky and all, but it turned out to be extremely practical.

    How's that script work when the user is in a non-English locale?



  • @error What's a non-English (well, non-American) locale?



  • @error said in WTF Bites:

    How's that script work when the user is in a non-English locale?

    Poorly, of course. Why should it be any different for non-English locales?


  • Banned

    @Atazhaia said in WTF Bites:

    And of course Apple just assumes you will know it's about the iPhone 12 preorders.

    You're an Apple customer. What else could you be looking for on iPhone's launch date?


  • 🚽 Regular

    This thing trips me every time.

    I can write (in a C# Linq expression) this:

    var pairs =
    	from a1 in arr1
    	join a2 in arr2 on a1.id equals a2.id
    	select new { a1, a2 };
    

    but I can't write this:

    var pairs =
    	from a1 in arr1
    	join a2 in arr2 on a2.id equals a1.id
    	select new { a1, a2 };
    

    which to me is backwards from what I usually write in SQL.

    There's some bullshit reason about this being turned by the compiler into

    arr1.Join(
              arr2,
              a1 => a2.id, // a2 not defined here
              a2 => a1.id, // a1 not defined here
              (a1, a2) => new { a1, a2 });
    

    But why can't the compiler be a little smarter and try switching it around?


  • Banned

    @Zecc said in WTF Bites:

    There's some bullshit reason about this being turned by the compiler into

    arr1.Join(
              arr2,
              a1 => a2.id, // a2 not defined here
              a2 => a1.id, // a1 not defined here
              (a1, a2) => new { a1, a2 });
    

    But why can't the compiler be a little smarter and try switching it around?

    Scala compiler is very "smart" about switching things around all over the place until everything compiles. I absolutely hate it. I want my compiler to be as dumb as possible. Dumb is predictable. I like to know what my code is going to do.



  • @Gąska said in WTF Bites:

    I want my compiler to be as dumb as possible.

    GCC with optimizations disabled is pretty good at generating stupid code.


  • Banned

    @Zerosquare imagine how many security vulnerabilities could be avoided if GCC didn't elide null checks because of unchecked pointer accesses elsewhere.


  • 🚽 Regular

    @Gąska said in WTF Bites:

    Scala compiler is very "smart" about switching things around all over the place until everything compiles. I absolutely hate it. I want my compiler to be as dumb as possible. Dumb is predictable. I like to know what my code is going to do.

    But unless you're doing something insanely stupid like relying on order of side-effects inside the expressions around the equals, what's the problem here?



  • @error said in WTF Bites:

    @Bulb said in WTF Bites:

    # toybox version of find on device does not cope well with dangling symlinks.
    # As a workaround parse its error output.
    find -L "$fs" -type l -xdev 2>&1 \
        | grep -E "^find: .+: No such file or directory" \
        | sed -e 's/^find: //' -e 's/: No such file or directory$//' \
        | while read; do
    

    For :raisins: instead of some normal embedded Linux, the device uses AOSP core, version somewhere around Nougat (we don't know exactly). No, it's not full Android, it's just uses the core, so we can't do things the Android way and we can't do them the Linux way…

    I really am starting to agree with Blakeyrat about the Linux ecosystem. WhyTF is the standard practice to parse the text interface of CLI tools instead of providing an API?

    There exists a perfectly good OS API. The better question is: why would anyone use CLI tools like find to programmatically determine whether a file exists?

    I've arrived at the sad truth that Linux is victim of the success of sh. It was just good enough that people started writing shell scripts instead of installing a sensible scripting environment like Python.


  • Banned

    @Zecc said in WTF Bites:

    @Gąska said in WTF Bites:

    Scala compiler is very "smart" about switching things around all over the place until everything compiles. I absolutely hate it. I want my compiler to be as dumb as possible. Dumb is predictable. I like to know what my code is going to do.

    But unless you're doing something insanely stupid like relying on order of side-effects inside the expressions around the equals, what's the problem here?

    Call it a logical fallacy, but I'm very afraid of the slippery slope it would introduce. I've seen many programming languages, and they all fall in one of two categories: those that never try to second-guess the programmer and puke out dumb errors in even the most trivial cases, or those that went way too far and nobody can explain what exactly is going on anymore.


  • ♿ (Parody)

    @Gąska said in WTF Bites:

    @Zecc said in WTF Bites:

    @Gąska said in WTF Bites:

    Scala compiler is very "smart" about switching things around all over the place until everything compiles. I absolutely hate it. I want my compiler to be as dumb as possible. Dumb is predictable. I like to know what my code is going to do.

    But unless you're doing something insanely stupid like relying on order of side-effects inside the expressions around the equals, what's the problem here?

    Call it a logical fallacy, but I'm very afraid of the slippery slope it would introduce. I've seen many programming languages, and they all fall in one of two categories: those that never try to second-guess the programmer and puke out dumb errors in even the most trivial cases, or those that went way too far and nobody can explain what exactly is going on anymore.

    But...isn't creating an equals operator that isn't commutative really the first step down a slippery slope here?


  • I survived the hour long Uno hand

    @Zecc
    TRWTF is not just using Fluent API.


  • Banned

    @boomzilla maybe some other slope, but it definitely isn't the "in a misguided attempt to help bad programmers, the rules regarding this seemingly simple language feature have become infinitely complex" slippery slope. See also: C++'s argument-dependent lookup. It seems very straight forward on surface - if you don't have this function in scope but there's a function with that name declared right next to the class definition of the argument, of course you meant that function - but then you start reading the actual name resolution rules and see the bottomless pit of special cases upon special cases and you instantly regret wanting to learn more.


  • ♿ (Parody)

    @Gąska yeah, I don't disagree with your general point, just that it seems misplaced here.

    OTOH, I once wrote an implementation of SQL (over 15 years ago now, probably) where I was lazy and basically hard coded the required order of join conditions (and they had to be simple equality joins, nothing fancy and no and or ors allowed).


  • Banned

    @boomzilla said in WTF Bites:

    @Gąska yeah, I don't disagree with your general point, just that it seems misplaced here.

    Maybe, but I have a feeling that if they fixed this one case, they'd suddenly find 50 other places where they could "improve" the compiler so it "helps" the programmer when they make a "common" mistake.


  • 🚽 Regular

    Okay, levicki.



  • @Gąska I'm currently fighting declarative jenkinsfiles orchestrated by puppet embedded in an AWS cloudformation template. I'm very much with you on the "I like to know what my code is going to do" part. It's all just ***** magic. Things happen (or usually don't) in some particular order defined by the phase of the moon and the price of tea in china from what I can tell.


  • BINNED

    @Zecc said in WTF Bites:

    Okay, levicki.

    Hey, garage is :arrows: !
    :tro-pop:


  • Discourse touched me in a no-no place

    @Gąska said in WTF Bites:

    imagine how many security vulnerabilities could be avoided if GCC didn't elide null checks because of unchecked pointer accesses elsewhere.

    Imagine how many bugs would be avoided if people didn't write stupid code.


  • Banned

    @dkf that's what I'm saying. GCC should stop putting stupid code in its optimizer.



  • Either my internet connection or Youtube is eating a ton of shit right now. Possibly both



  • @acrow said in WTF Bites:

    There exists a perfectly good OS API. The better question is: why would anyone use CLI tools like find to programmatically determine whether a file exists?

    Because it's at least an order of magnitude shorter than equivalent C or C++ code and does not need to be compiled.

    @acrow said in WTF Bites:

    I've arrived at the sad truth that Linux is victim of the success of sh. It was just good enough that people started writing shell scripts instead of installing a sensible scripting environment like Python.

    The shell, including most of the commands, fits in a ~300K binary that is already on the system. Python needs almost three orders of magnitude more and would need to be installed. And then the script would still be longer and would not even be any faster. It might be prettier for some definition of pretty, but it definitely wouldn't be practical.



  • @Gąska said in WTF Bites:

    C++'s argument-dependent lookup. It seems very straight forward on surface - if you don't have this function in scope but there's a function with that name declared right next to the class definition of the argument, of course you meant that function - but then you start reading the actual name resolution rules and see the bottomless pit of special cases upon special cases and you instantly regret wanting to learn more.

    FTFY



  • @dkf said in WTF Bites:

    Imagine how many bugs would be avoided if people didn't write stupid code.

    I guess that's true... as long as you define "stupid code" as "anything not written by a pedantic paranoiac". C(++)'s and especially GCC's "I'll wait till you make one little mistake, then I stab you in the back" attitude is definitely not helping.

    Yeah, I know why K&R allowed undefined behavior in the spec back in the 70s, but this is something that should have been fixed long ago (either by making the language stricter, or switching to another language altogether).


  • BINNED

    @Zerosquare said in WTF Bites:

    Yeah, I know why K&R allowed undefined behavior in the spec back in the 70s, but this is something that should have been fixed long ago (either by making the language stricter, or switching to another language altogether).

    I guess some of it could be fixed by making more things implementation defined.
    Take signed int overflow for example. Different architectures (apparently?) have different behavior, so you don’t want to pessimize by adding extra paths for something that doesn’t happen and when it does is probably a bug anyway. But you could just make it implementation defined so it does whatever is natural, instead of invoking the dreaded nasal demons.

    However, I’m not sure about e.g. data races. You certainly wouldn’t want to make everything atomic for it to be well-defined, that wouldn’t fly. How do other languages’ memory models handle that on non-x86 platforms?



  • @topspin said in WTF Bites:

    Take signed int overflow for example. Different architectures (apparently?) have different behavior, so you don’t want to pessimize by adding extra paths for something that doesn’t happen and when it does is probably a bug anyway.

    But that's the thing. This is not the 1970s anymore: there are a lot fewer architectures that matter now (if you exclude embedded stuff, 99% of the time it's either x64 or ARM), and the vast majority of them are very similar: 8-bit bytes, 2's complement for signed integers, same behavior for integer overflow, etc. And it's very unlikely that future platforms will be any different.

    So, there's no point in making everyone suffer for compatibility with things that are no longer a concern (see also: trigraphs, octal numbers, etc.).



  • @topspin said in WTF Bites:

    Take signed int overflow for example. Different architectures (apparently?) have different behavior,

    That totally ISN'T the reason! The reason is to be able to apply logic like

    for(int i = 0; i < x; ++x) {
        …
        if (i + k < x) {
           …
    

    … oh, that's easy, i + k < x iff i < x - k and we can split the loop to 〈0, x-k) and 〈x-k, x). Nope, in the face of overflow you can't. Even if your overflow is deterministic, the expressions become ungodly mess of special cases in mod 2³². All the while loops like this are common and often hot, so the optimization makes practical difference.

    That's why even Rust has this one actually undefined in release mode, with a panic! in debug mode, so you hopefully catch cases where it might happen in testing.


  • kills Dumbledore

    @e4tmyl33t said in WTF Bites:

    @PleegWat Apparently Terry, and later Rhianna, were both involved in the initial stages of it way back in 2011, but that has somehow changed in the meantime

    There was a clause in the contract saying Terry Pratchett had to have a say. A few years later he set up the company Narrativia with Rob and Rhianna, and everything subsequently has had that as the controling party for similar clauses. Once he died, there was no Terry Pratchett to have that final say, and that's when the previously shelved plans were resurrected



  • @Jaloopa That there is no Terry Pratchett to have final say should not void the clause that he has to, it should render void the license, because there is no way to satisfy the clause, shouldn't it? At which point they'd obviously be forced to re-negotiate with the heirs, who'd want the final say.


  • Discourse touched me in a no-no place

    @Gąska said in WTF Bites:

    @dkf that's what I'm saying. GCC should stop putting stupid code in its optimizer.

    Except… GCC knows that to get to that point in the code, you must've already done a successful access through the pointer, and that therefore the pointer is not NULL (because you can never successfully access through a NULL pointer on a normal system), and that therefore any comparisons with NULL can be resolved at compile time.

    The stupid code is putting the access-through-NULL before the is-NULL check. Don't do that. (I wonder how easy it would be to have a warning for this case? And how useful it would be given that it would probably get quite a few false-positives…)



  • Someone messed up their title decoration tags, I think.

    SteamBroken.jpg

    Well, technically, it's also possible that they ported the Dawn of War and Winter Assault add-on to the Mega Drive. But I kind of doubt it.



  • @dkf said in WTF Bites:

    @Gąska said in WTF Bites:

    @dkf that's what I'm saying. GCC should stop putting stupid code in its optimizer.

    Except… GCC knows that to get to that point in the code, you must've already done a successful access through the pointer, and that therefore the pointer is not NULL (because you can never successfully access through a NULL pointer on a normal system), and that therefore any comparisons with NULL can be resolved at compile time.

    Except there is a couple of cases that formally count as dereference of a null pointer, and gcc treats them as such, but they don't compile to an actual load from a numerically small address. In C++, conversion from pointer to reference is notorious. That is definitely considered dereference, and invalid for NULL pointer, and triggers that optimization, but would not cause a fault at runtime.

    In C I am not sure whether using member of pointer (->) operator when you then just take a pointer to that member counts; the offsetof macro used to use it, but if they introduced __compiler_offsetof built-in, it was probably because they otherwise considered that expression invalid.

    The stupid code is putting the access-through-NULL before the is-NULL check. Don't do that. (I wonder how easy it would be to have a warning for this case? And how useful it would be given that it would probably get quite a few false-positives…)

    Except the mistake is pretty easy to make when references are involved, and it should never crash on that. I just triggers the optimization to go wild.


  • sekret PM club

    @acrow I was going to call bullshit since I know you can edit the thumbnail picture for games in your Steam Library, but I just checked and it's happening on mine too. It probably has something to do with the current Store promotion for Sega's 60th anniversary.


  • Discourse touched me in a no-no place

    @e4tmyl33t said in WTF Bites:

    It probably has something to do with the current Store promotion for Sega's 60th anniversary.

    Yup. Almost every Sega game I've got in Steam has been done the same.

    Team Sonic Racing
    4b4cb754-f180-490f-bf01-d6fcd51b436d-image.png

    Two Point Hospital
    61ece1fe-e73b-41ba-a3bc-c9e020c7faae-image.png

    etc


  • Considered Harmful

    16029664481591661792430833768320.jpg

    Click OK to cancel or click Cancel to not cancel.


  • sekret PM club

    @error said in WTF Bites:

    Click OK to cancel or click Cancel to not cancel.

    No, Cancel is clearly to cancel your cancel. Do you even cancel?


  • Banned



  • @Bulb I think it was that the Pratchett blessing clause would have been removed when the Narrativia became the controlling party (since that was the entity through which Terry would exert his control). Narrativia would be Narrativia with or without Terry; he was putting something together to outlast him.



  • @Watson That's the question. I understood that the previous post as saying their contract predated Narrativia.



  • @Gąska said in WTF Bites:

    @Atazhaia said in WTF Bites:

    And of course Apple just assumes you will know it's about the iPhone 12 preorders.

    You're an Apple customer. What else could you be looking for on iPhone's launch date?

    🤔 Will managers wonder why all store purchases dropped to zero for (however long that redirect is/was there)?

    Nah. Because NEW IPHONE!!!


  • Banned

    @dcon it's not like they have to worry about their customers going to the competition 🤷♂


Log in to reply