• alexc@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    5 months ago

    I don’t know what the hate is unless you are trying to store time as a String property. There a special place in hell for all developers who do this.

    IMHO, all you really need to know is an Epoch time stamp and whether it’s localized to the viewer or the creator… Not that complex. The problem with time zones is that politicians keep changing them

    Honestly, I’d rather give the creator of NULL a slap.

    • dohpaz42@lemmy.world
      link
      fedilink
      English
      arrow-up
      0
      ·
      5 months ago

      I’m probably going to get a lot of hate for this, and I do recognize there have been problems with it all over the place (my code too), but I like null. I don’t like how it fucks everything up. But from a data standpoint, how else are you going to treat uninitialized data, or data with no value? Some people might initialize an empty string, but to me that’s a valid value in some cases. Same for using -1 or zero for numbers. There are cases where those values are valid. It’s like using 1 for true, and zero for false.

      Whomever came up with the null coalescing operator (??) and optional chaining (?->) are making strides with handling null more elegantly.

      I’m more curious why JavaScript has both null and undefined, and of course NaN. Now THAT is fucked up. Make it make sense.

      • pivot_root@lemmy.world
        link
        fedilink
        arrow-up
        0
        ·
        5 months ago

        To offer a differing opinion, why is null helpful at all?

        If you have data that may be empty, it’s better to explicitly represent that possibility with an Optional<T> generic type. This makes the API more clear, and if implicit null isn’t allowed by the language, prevents someone from passing null where a value is expected.

        Or if it’s uninitialized, the data can be stored as Partial<T>, where all the fields are Optional<U>. If the type system was nominal, it would ensure that the uninitialized or partially-initialized type can’t be accidentally used where T is expected since Partial<T> != T. When the object is finally ready, have a function to convert it from Partial<T> into T.

        • dohpaz42@lemmy.world
          link
          fedilink
          English
          arrow-up
          0
          ·
          5 months ago

          Ignoring the fact that a lot of languages, and database systems, do not support generics (but do already support null), you’ve just introduced a more complex type of null value; you’re simply slapping some lipstick on it. 😊