• Drusenija@lemmy.world
      link
      fedilink
      arrow-up
      83
      ·
      2 months ago

      What’s even wilder is if you look at the code of that package, all it does is include the is-odd package and then return !is-odd. And the is-odd package isn’t much better, it does some basic checks on the input and then returns n % 2 === 1.

      • NotAViciousCyborg@lemmy.world
        link
        fedilink
        arrow-up
        27
        ·
        2 months ago

        I thought I was missing something. JS is one of my main languages and I always just write the is-odd function myself since it’s like 10 characters. It boggles the mind that is-even has 176k weekly downloads

        • kevincox@lemmy.ml
          link
          fedilink
          arrow-up
          19
          ·
          2 months ago

          To be fair having a name can make things easier to read. I get that i % 2 == 0 is a common pattern and most programmers will quickly recognize what is happening. But isEven(i) is just that much easier to grok and leaves that brainpower to work on something else.

          But I would never import a package for it. I would just create a local helper for something this trivial.

          • NotAViciousCyborg@lemmy.world
            link
            fedilink
            arrow-up
            10
            ·
            2 months ago

            Exactly what I would do if I had to reuse it, especially now since I know that adding a package would actually add 2. It all just seems so…inefficient

            • kevincox@lemmy.ml
              link
              fedilink
              arrow-up
              11
              ·
              2 months ago

              Even if the code isn’t reused adding names to sub-expressions can be very valuable. Often times I introduce new functions or variables even if they are only used once so that I can give them a descriptive name which helps the reader more quickly understand what is happening.

              • NotAViciousCyborg@lemmy.world
                link
                fedilink
                arrow-up
                3
                ·
                2 months ago

                Yeah, I do that with pretty much every separate operation in c# since our solutions are pretty big. Most of my JS scripts are just done in ServiceNow which are separated and named appropriately.

        • gaael@lemmy.world
          link
          fedilink
          arrow-up
          7
          ·
          2 months ago

          Also there are 40-something packages depending on it, so I guess it gets pulled automatically when they are used.

        • Aqarius@lemmy.world
          link
          fedilink
          arrow-up
          2
          ·
          2 months ago

          If youre lazy/busy enough, doing basic checks on the input is enough boilerplate to package out.

    • kamen@lemmy.world
      link
      fedilink
      arrow-up
      10
      ·
      2 months ago

      This must be a “hold my beer” kind of joke and someone wanting to see how far they can take it.

  • udon@lemmy.world
    link
    fedilink
    arrow-up
    74
    arrow-down
    2
    ·
    2 months ago
    1. it’s easy to make fun of
    2. it makes every other programming language look better in comparison
  • SGG@lemmy.world
    link
    fedilink
    English
    arrow-up
    65
    ·
    2 months ago
    1. It runs in browsers
    2. If you hate your co-workers, then they will also feel your pain.
  • Tenkard@lemmy.ml
    link
    fedilink
    arrow-up
    62
    ·
    2 months ago
    1. You can call it “Java” to enrage other programmers
    2. You can compare numbers against strings without wasting time converting them
  • BeefPiano@lemmy.world
    link
    fedilink
    English
    arrow-up
    55
    ·
    2 months ago
    1. It has the simplest multi-threaded implementation: no threads!
    2. You can goof off while your build system takes 20 minutes to rebuild a non-compiled language
        • roguetrick@lemmy.world
          link
          fedilink
          arrow-up
          4
          ·
          2 months ago

          I dunno what correcting someone’s grammar has to do with paying off your readers. Sounds expensive.

        • toastal@lemmy.ml
          link
          fedilink
          arrow-up
          3
          ·
          edit-2
          2 months ago

          This isn’t speaking, but writing (or typing). Using ‘correct’ spelling & grammar helps ESL speakers read the language as well as those relying on text translation software. Some folks make typos & it’s fine to make mistakes but it’s also strange to act like it’s just as easy to understand. Apostrophes have a specific meaning & many folks rely on them for understanding.

          I’m learning a foreign language now & I can tell you it is a massive stumbling block when you run into what you think is a new word, but is ‘just’ a misspelling.

          My issue with this account is not its corrections, but if you want to be the correction bot, at least get the typography right too. ' is as ASCII holdover & it should be .

  • Skullgrid@lemmy.world
    cake
    link
    fedilink
    arrow-up
    46
    arrow-down
    4
    ·
    2 months ago

    I am forced to try to get a JS certification.

    I am reaching the end of my rope, and starting to think of maybe putting my neck into one.

    Isaac Newton said that we see far because we stand on the shoulders of giants.

    Javascript is like standing on the shoulders of dwarves with brittle bone disease.

  • Fargeol@lemmy.ml
    link
    fedilink
    arrow-up
    43
    arrow-down
    1
    ·
    edit-2
    2 months ago

    1 - Easiest way to run a script in your browser
    2 - Always finds its way if inputs are bad
    Nan - undefined

  • vocornflakes@lemmy.world
    link
    fedilink
    English
    arrow-up
    38
    arrow-down
    2
    ·
    2 months ago
    1. Ubiquitous; insane amount of libraries and probably some of the best documentation of any language
    2. JS lambda function syntax is nice
    • ByteJunk@lemmy.world
      link
      fedilink
      arrow-up
      29
      arrow-down
      1
      ·
      2 months ago

      I spent way too long today figuring out why my app was doing something that it’s NOT supposed to do on weekends.

      I read Luxon’s docs (pretty cool lib tbh) again and again, and tried everything I could think of to get isWeekend to return a sane result.

      Turns out I was pulling a somewhat older version of Luxon, where isWeekend didn’t exist. In any sane language, I expect I’d get a huge warning about a property that doesn’t exist, but alas…

      Typescript helps me keep my sanity, but juuuuust barely.

  • kevincox@lemmy.ml
    link
    fedilink
    arrow-up
    24
    arrow-down
    3
    ·
    2 months ago
    1. Is available to be used in website scripting.
    2. Not quite as full of footguns as PHP (although it is close).
  • ☆ Yσɠƚԋσʂ ☆@lemmy.ml
    link
    fedilink
    arrow-up
    22
    arrow-down
    2
    ·
    2 months ago

    The part that always gets me is when people choose Js for the backend. Like I get that it’s the default thing that works on the frontend, so there’s some rationale why you might not want to transpile to it from another language. On the backend though, there are so many far better option, why would you willingly go with Js, especially given that you’re now forced to do all your IO async.

    • jubilationtcornpone@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      9
      arrow-down
      1
      ·
      2 months ago

      I moved from primarily ASP.Net Core backends, which is a hell of a great backend framework btw, to NestJS. Not my choice. I do what the people who sign my paychecks ask for.

      I cannot begin to fathom why anyone would willingly choose JavaScript for backend. TypeScript helps a lot but there are still so many drawbacks and poor design decisions that make the developer experience incredibly frustrating. Features that are standard in ASP.Net Core, Django, or other common backend frameworks just don’t exist.

      Also, don’t get me started on GraphQL. Sure, it has performance advantages for websites of a certain size and scale. But 99% of the websites out there don’t have the challenges that Facebook has. The added complexity and development cost over REST is just not worth it.

      • ☆ Yσɠƚԋσʂ ☆@lemmy.ml
        link
        fedilink
        arrow-up
        3
        arrow-down
        1
        ·
        2 months ago

        Yeah, gql in particular is a problem looking for a solution in most cases. It makes sense for facebook because they have people building frontend apps for their marketplace, and those apps need all kinds of weird combinations of data. However, this isn’t the situation for most apps where you have a fairly well defined set of calls you’re doing.

    • 31337@sh.itjust.works
      link
      fedilink
      arrow-up
      5
      ·
      2 months ago

      Server side rendering looks like it could be useful. I imagine SSR could be used for graceful degradation, so what would normally be a single page application could work without Javascript. Though, I’ve never tried SSR, and nobody seems to care about graceful degradation anymore.

      • ☆ Yσɠƚԋσʂ ☆@lemmy.ml
        link
        fedilink
        arrow-up
        5
        arrow-down
        1
        ·
        2 months ago

        Most pages tend be just documents and fairly simple forms. Making SPAs and then having to worry about SSR is just making a Rube Goldberg machine in most cases. I think something like HTMX is a much better approach in most cases. You keep all your business logic server side, send regular HTML to the client, and you just have a little bit of Js on the frontend that knows how to patch in chunks of HTML in the DOM as needed. Unless you have a highly interactive frontend, this is a much better approach than making a frontend with something like React and adding all the complexity that goes with it.

      • kevincox@lemmy.ml
        link
        fedilink
        arrow-up
        1
        ·
        2 months ago

        No one cares about graceful degradation anymore. But you can sell management on SEO. Page performance is a key aspect of search engine rankings and server-side rendered pages will almost always have a much faster initial load than client-side rendered.

      • ☆ Yσɠƚԋσʂ ☆@lemmy.ml
        link
        fedilink
        arrow-up
        3
        arrow-down
        1
        ·
        2 months ago

        No I meant having to do async as opposed to having threads like you would in Java for example. In vast majority of cases a thread pool will work just fine, and it makes your code far simpler. Typically, Java web servers will have a single thread that receives the request and then dispatches it to the pool of workers. The JVM is then responsible for doing the scheduling between the threads and ensuring each one gets to do work. You can do async too, but I’ve found threads scale to huge loads in practice.

      • juliebean@lemm.ee
        link
        fedilink
        arrow-up
        1
        ·
        2 months ago

        is there a non sexist/queerphobic meaning for that term? i would assume the bigotry is the whole point.