• @steventhedev
    link
    441 month ago

    Clearly your gender field is a boolean. Which means it can be either true, false, null, or undefined. Except in javascript where for some reason it can sometimes be NaN, but only when you try to compare two people.

  • unalivejoy
    link
    fedilink
    English
    291 month ago

    Even booleans take up 8 bits. And that’s a lot of wasted space.

    • @ZILtoid1991
      link
      111 month ago

      That’s why you use bitarrays and bitflags instead when you need more than just one or two arguments for a function.

      • @[email protected]
        link
        fedilink
        English
        91 month ago

        Only if it’s performance sensitive. Otherwise you’re wasting programmer time both writing and reading the code, and you’ve made it less maintainable with more complexities where bugs can creep in.

        The vast majority of the time you can afford a few wasted bits.

        Honestly though I don’t quite understand why a compiler couldn’t optimise this process. Like it knows what a boolean is, surely it could reduce them down to bits.

        • @calcopiritus
          link
          31 month ago

          Well, to get a boolean out of a bit array you have to do some operations. So at first it doesn’t make it more performant. Compilers probably don’t automatically make them bitarrays because of that.

          However, the memory savings means less cache used. And a cache miss is way more expensive than those bit operations. So they should be more performant. I’m sure someone out there has done the actual research and there’s a good reason why compilers don’t make all booleans bitarrays.

  • @[email protected]
    link
    fedilink
    English
    161 month ago

    Bold of programmers to assume gender can be expressed accurately in a finite discrete system. Gonna have to bust the Taylor series for some better approximation.

      • @spongebue
        link
        91 month ago
        public boolean isMale() {
            return !isFemale();
        }
        
        public boolean isFemale() {
            return !isMale();
        }
                  
        
  • @[email protected]
    link
    fedilink
    41 month ago

    Gender is a second order tensor, so you should store it as a pointer to an array of pointers for maximum read/write speed.

    • @ZILtoid1991
      link
      3
      edit-2
      1 month ago

      Gender is a struct

      struct Gender {
        byte binaryBias;    ///Determines male (+) or female (-) bias if present
        ubyte binaryAm;    ///Determines the amount of binary gender(s) present
        bool isTrans;    ///True if assigned at birth gender does not equal with current one
        ubyte xenoAm;    ///Determines the amount of xenogender
        uint xenoGen;    ///Xenogender selection, 0 if not applicable
        Sex* sex;    ///Pointer to the person's current sex
      }
      
      • @[email protected]
        link
        fedilink
        English
        21 month ago

        Now this is a gender definition I can get behind. None of that string/enum crap, just raw data.

      • @[email protected]
        link
        fedilink
        11 month ago

        That’s a lot of implementation detail. Is there just a service interface I can inject to know what bathroom a person’s RFID fob should open?

        • @ZILtoid1991
          link
          11 month ago

          Just don’t have gendered bathrooms, simple as that.