Blåhaj Lemmy
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
kuneho@lemmy.world to Programmer Humor@programming.dev ·
edit-2
2 years ago

JavaScript always know my truest of desires

lemmy.world

message-square
36
link
fedilink
434

JavaScript always know my truest of desires

lemmy.world

kuneho@lemmy.world to Programmer Humor@programming.dev ·
edit-2
2 years ago
message-square
36
link
fedilink

alert-triangle
You must log in or # to comment.
  • katy ✨
    link
    fedilink
    arrow-up
    62
    ·
    2 years ago

    Programming Javascript is roughly the equivalent of hitting your head with a hammer or trying to uninstall McAfee.

    • dohpaz42@lemmy.world
      link
      fedilink
      English
      arrow-up
      7
      ·
      2 years ago

      As if Javascript wasn’t complex enough, let’s introduce TypeScript and Coffescript and then write transpilers so we can convert said languages back into Javascript, which we could have done in the first place.

      • traches@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        30
        ·
        2 years ago

        Nobody uses coffeescript anymore, and typescript is there to make things easier not harder.

        • ImpossibleRubiksCube@programming.dev
          link
          fedilink
          English
          arrow-up
          2
          ·
          edit-2
          2 years ago

          deleted by creator

      • devfuuu@lemmy.world
        link
        fedilink
        English
        arrow-up
        1
        ·
        2 years ago

        And all the new versions of all the above constantly being released. I’m so glad I don’t use those languages anymore.

      • Excel@lemmy.megumin.org
        link
        fedilink
        English
        arrow-up
        1
        ·
        2 years ago

        These languages only exist because JS is so dumb in the first place

  • towerful@programming.dev
    link
    fedilink
    arrow-up
    24
    ·
    2 years ago

    Use stringly-typed everything, and always padStart your numbers.
    Saves running into issues with numbers outside the 52-bit integer range.
    And padding start means you don’t have to worry about pesky sort functions.

    Just don’t do maths. Simple.

    Maybe you could do a manual sort.
    Provide a “captcha” prompt, and ask which comes first in the list… You know, to make sure the user is a human! And you get free sorting.

    • dave@feddit.uk
      link
      fedilink
      arrow-up
      37
      ·
      2 years ago

      Use stringly-typed everything

      Instructions unclear. Now 1+2=12.

      • LordTrychon@sh.itjust.works
        link
        fedilink
        arrow-up
        16
        ·
        2 years ago

        I got 000001000002.

    • kuneho@lemmy.worldOP
      link
      fedilink
      arrow-up
      21
      ·
      2 years ago

      Provide a “captcha” prompt, and ask which comes first in the list… You know, to make sure the user is a human! And you get free sorting.

      I mean, this strangely is a compelling idea…

      • TWeaK@lemm.eeBanned
        link
        fedilink
        arrow-up
        16
        ·
        edit-2
        2 years ago

        Removed by mod

        • coloredgrayscale@programming.dev
          link
          fedilink
          arrow-up
          5
          ·
          2 years ago

          Iirc they require 5 votes with the same response. Your effort won’t do anything, other than flag you as unreliable.

          Afaik 4chan (of course) did that poisoning correctly, “classifying” the unknown words as “penis” (of course).

          • TWeaK@lemm.eeBanned
            link
            fedilink
            arrow-up
            2
            ·
            edit-2
            2 years ago

            Removed by mod

            • ImpossibleRubiksCube@programming.dev
              link
              fedilink
              arrow-up
              2
              ·
              edit-2
              2 years ago

              deleted by creator

        • somePotato@sh.itjust.works
          link
          fedilink
          arrow-up
          3
          ·
          2 years ago

          Based

        • trashcan@sh.itjust.works
          link
          fedilink
          arrow-up
          2
          ·
          2 years ago

          o7

    • RobotToaster@infosec.pub
      link
      fedilink
      arrow-up
      7
      ·
      2 years ago

      Just don’t do maths. Simple.

      That’s a good rule for life in general, really.

    • oessessnex@programming.dev
      link
      fedilink
      arrow-up
      3
      ·
      2 years ago

      Turn JavaScript into Bash with these easy steps…

  • Ategon@programming.dev
    link
    fedilink
    arrow-up
    19
    ·
    2 years ago

    Note if you put the image link in the url bar of the post rather than the body it lets people see it while scrolling (url + title can be edited so you can edit it to do that still if you want)

    • kuneho@lemmy.worldOP
      link
      fedilink
      arrow-up
      7
      ·
      2 years ago

      thanks!

      using 3rd party client (and first “image post” I’ve made on this platform) and wasn’t sure how image post should be made.

  • Grass@geddit.social
    link
    fedilink
    arrow-up
    7
    ·
    2 years ago

    Is there even any case where you would want this?

  • fuck_u_spez@lemmy.fmhy.ml
    link
    fedilink
    arrow-up
    6
    ·
    2 years ago

    I couldn’t believe it, tried it out, what the actual heck? I mean I get all these weird string vs number comparison but sorting actual numbers and this comes out? What kind of drugs were the designers of javascript (or at least this function) on… Who thought it was a good idea to sort numbers lexicographically??

    • Kerb@discuss.tchncs.de
      link
      fedilink
      arrow-up
      5
      ·
      2 years ago

      Probably meth or cocaine, considering js was written by a single person in 10 days

      • ImpossibleRubiksCube@programming.dev
        link
        fedilink
        arrow-up
        1
        ·
        edit-2
        2 years ago

        deleted by creator

    • valourvalkyria@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      2 years ago

      Iirc Array.sort requires you to pass a function in, or it casts into strings and sort them.

    • coloredgrayscale@programming.dev
      link
      fedilink
      arrow-up
      1
      ·
      2 years ago

      That way they get to reuse the code for sorting strings!

  • VonReposti@feddit.dk
    link
    fedilink
    arrow-up
    5
    ·
    2 years ago

    Well, 3 out of 5 correct ain’t bad. With some more trial runs we might get this thing nailed!

  • CanadaPlus@lemmy.sdf.org
    link
    fedilink
    arrow-up
    3
    ·
    2 years ago

    So, I think just yesterday or the day before someone on here was saying we shouldn’t make fun of JavaScript anymore.

  • solarzones@programming.dev
    link
    fedilink
    English
    arrow-up
    3
    ·
    2 years ago

    JavaScript knows my truest fears too LOL

  • Aurenkin@sh.itjust.works
    link
    fedilink
    arrow-up
    2
    ·
    2 years ago

    JavaScript: You chose this path, now I have a surprise for you

    • roboter5123@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      2 years ago

      Deploying surprise in 3, 2… Hold up for a seco d that wasn suppossed to happen.

  • heartlessevil@lemmy.one
    link
    fedilink
    arrow-up
    2
    ·
    2 years ago

    I don’t think JS works that way

    • Rikudou_Sage@lemmings.world
      link
      fedilink
      English
      arrow-up
      32
      ·
      2 years ago

      It does.

    • Quasari@programming.dev
      link
      fedilink
      arrow-up
      21
      ·
      2 years ago

      Array.prototype.sort if no callback is passed to it will coerce non-undefined elements to strings when sorting. It does do that.

      To sort numbers passing a function like (a, b) => a - b is good enough.

      • stratoscaster@lemmy.zip
        link
        fedilink
        arrow-up
        17
        ·
        2 years ago

        Fuck JS is stupid.

        Source: use JS regularly

  • Freethewhat@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    2 years ago

    Ugh, I just ran into this in Terraform. Why is this a thing?

    • Swiggles
      link
      fedilink
      arrow-up
      8
      ·
      2 years ago

      It’s just sorted alphabetically (technically it is the UTF16 code order). To be fair it’s a sane default for most use cases. In JS case you can define a very simple callback to change the behavior to numeric sorting (a,b => a<b). Many other sorters provide a flag instead, but numeric sorting is seldom the default as it is not as useful most of the time in weakly typed languages.

      • Excel@lemmy.megumin.org
        link
        fedilink
        English
        arrow-up
        2
        ·
        2 years ago

        weakly typed languages

        Well, looks like we found the problem right there

  • ImpossibleRubiksCube@programming.dev
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    2 years ago

    deleted by creator

Programmer Humor@programming.dev

programmer_humor@programming.dev

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !programmer_humor@programming.dev

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 1.16K users / day
  • 3.88K users / week
  • 7.71K users / month
  • 16.6K users / 6 months
  • 524 local subscribers
  • 28K subscribers
  • 1.92K Posts
  • 64.1K Comments
  • Modlog
  • mods:
  • Feyter@programming.dev
  • adr1an@programming.dev
  • BurningTurtle@programming.dev
  • Pierre-Yves Lapersonne@programming.dev
  • UI: 0.19.13
  • BE: 0.19.13-modified
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code
  • join-lemmy.org