• 0 Posts
  • 99 Comments
Joined 1 year ago
cake
Cake day: September 2nd, 2023

help-circle



  • I have had many mouses. Most of them broke the side buttons. The scroll wheel usually lasts as much as the side buttons. After that. The left/right main buttons fail.

    I have never had a mouse with a broken sensor though. I would look for solutions in the software (calibration and settings). But it’s not impossible that it’s broken.



  • The thing about UB is that many optimizations are possible precisely because the spec specified it as UB. And the spec did so in order to make these optimizations possible.

    Codebases are not 6 lines long, they are hundreds of thousands. Without optimizations like those, many CPU cycles would be lost to unnecessary code being executed.

    If you write C/C++, it is because you either hate yourself or the application’s performance is important, and these optimizations are needed.

    The reason rust is so impressive nowadays is that you can write high performing code without risking accidentally doing UB. And if you are going to write code that might result in UB, you have to explicitly state so with unsafe. But for C/C++, there’s no saving. If you want your compiler to optimize code in those languages, you are going to have loaded guns pointing at your feet all the time.


  • I recently came across a rust book on how pointers aren’t just ints, because of UB.

    fn main() {
        a = &1
        b = &2
        a++
        if a == b {
            *a = 3
            print(b)
        }
    }
    

    This may either: not print anything, print 3 or print 2.

    Depending on the compiler, since b isn’t changed at all, it might optimize the print for print(2) instead of print(b). Even though everyone can agree that it should either not print anything or 3, but never 2.


  • If you want to use instructions from an extension (for example SIMD), you either: provide 2 versions of the function, or just won’t run in some CPUs. It would be weird for someone that doesn’t know about that to compile it for x86 and then have it not run on another x86 machine. I don’t think compilers use those instructions if you don’t tell them too.

    Anyway, the SIMD the compilers will do is nowhere near the amount that it’s possible. If you manually use SIMD intrinsics/inline SIMD assembly, chances are that it will be faster than what the compiler would do. Especially because you are reducing the % of CPUs your program can run on.










  • So because you don’t understand it, everything it does should be legal?

    It’s not rare maths. There are trns of thousands of AI experts. And most CS graduates (millions) have a good understanding on how they work, just not the specifics of the maths.

    Yeah, they’re not selling a copy, they are just selling a subscription to a copying machine loaded with the information needed to make a copy. Totally different.

    I should start a business of printers and attach a USB with the PNG of a dollar bill. And of course my printers won’t have any government mandated firmware that disables printing fake money.

    I’m not printing fake money! It’s my clients! Totally legal.