• 0 Posts
  • 4 Comments
Joined 1 year ago
cake
Cake day: June 15th, 2023

help-circle

  • 418teapot@lemmy.worldtoProgrammer Humor@programming.devaverage day in NPM land
    link
    fedilink
    English
    arrow-up
    35
    arrow-down
    4
    ·
    edit-2
    1 month ago

    It’s kind of insane how bad this whole is-number thing is. It’s designed to tell you if a string is numeric, but I would argue if you’re ever using that you have a fundamental design problem. I hate dynamic typing as much as anyone else, but if forced to use it I would at least try to have some resemblance of sanity by just normalizing it to an actual number first.

    Just fucking do this…

    const toRegexRange = (minStr, maxStr, options) => {
      const min = parseInt(minStr, 10);
      const max = parseInt(maxStr, 10);
      if (isNaN(min) || isNaN(max)) throw Error("bad input or whatever");
      // ...
    

    Because of the insanity of keeping them strings and only attempting to validate them (poorly) up front you open yourself up to a suite of bugs. For example, it took me all of 5 minutes to find this bug:

    toRegexRange('+1', '+2')
    // returns "(?:+1|+2)" which is not valid regexp
    

  • Agreed, but my point is with a centralized network the lowest common denominator wins. There is no reason you can’t have QoL features on an open network, and thusly let everyone have the features that they care most about.

    Can you imagine what a shithole the internet would have been if email wasn’t federated an open? There is absolutely no way that whatever centralized bullshit would have spawned instead would already be either long gone or enshittified to the point of being useless.


  • Good for you, you have a short list of requirements out of a chat service and discord perfectly fills your niche. But different people have different requirements for chat, and they don’t align. And network effects force people who have differing requirements to use the service with the most users which sucks.

    For instance here are things that I require from any chat service that I use that discord completely falls flat at:

    • Ability to run it on my linux machine without using an electron client (npm is a huge mess of supply chain attacks and I refuse to run any software that is likely to contain dependencies from it)
    • Ability to run it on my AOSP phone which does not have any google play services installed
    • Ability to write software to back up messages without fear of a company changing their API and breaking my backup system