Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

agnos.is Forums

  1. Home
  2. Programmer Humor
  3. JavaScript

JavaScript

Scheduled Pinned Locked Moved Programmer Humor
programmerhumor
152 Posts 83 Posters 2 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • avidamoeba@lemmy.caA [email protected]

    Yup. It's completely inconsistent in its interpretation of the + operator.

    gsus4@mander.xyzG This user is from outside of this forum
    gsus4@mander.xyzG This user is from outside of this forum
    [email protected]
    wrote on last edited by [email protected]
    #14

    Yeah, I actually had to try 1+"11" to check that it didn't give me 12, but thankfully it commutes it's consistent πŸ˜‡

    P 1 Reply Last reply
    8
    • avidamoeba@lemmy.caA [email protected]

      This is too stupid so I had to check.

      Fuck me.

      buboscandiacus@mander.xyzB This user is from outside of this forum
      buboscandiacus@mander.xyzB This user is from outside of this forum
      [email protected]
      wrote on last edited by
      #15

      Fuck me.

      1 Reply Last reply
      1
      • gsus4@mander.xyzG [email protected]

        Yeah, I actually had to try 1+"11" to check that it didn't give me 12, but thankfully it commutes it's consistent πŸ˜‡

        P This user is from outside of this forum
        P This user is from outside of this forum
        [email protected]
        wrote on last edited by
        #16

        it commutes

        Maybe the behaviour with regard to type conversion, but not for the operation itself.

        "13"+12 and 12+"13" don't yield the same result.

        R 1 Reply Last reply
        3
        • A [email protected]

          Unfortunately, it makes sense if you know what + means, which is concatenate. - is strictly a math function though.

          Not saying that makes this better. It just makes sense.

          G This user is from outside of this forum
          G This user is from outside of this forum
          [email protected]
          wrote on last edited by [email protected]
          #17

          It is 'comprehensible' in the sense that it's possible to figure out how it happened, but it absolutely does not "make sense" in terms of being a reasonable language design decision. It's 100% incompetence on the part of the person who created Javascript.

          A R F 3 Replies Last reply
          19
          • r00ty@kbin.lifeR [email protected]

            Should it, or should it be "1"? (just removing one, one)

            G This user is from outside of this forum
            G This user is from outside of this forum
            [email protected]
            wrote on last edited by
            #18

            Which "1" did it remove? And did it search the string to find a "1" to remove, or did it remove whichever character happened to be at array index 1?

            __nobodynowhere@sh.itjust.works_ A F 3 Replies Last reply
            1
            • whaleross@lemmy.worldW [email protected]

              People that try to do mathematical operations with strings blaming the programming language that had a stated design goal to do its best and try to keep running scripts that make no sense because they realized it would be used by people that have no idea what they are doing. Clearly they were right.

              G This user is from outside of this forum
              G This user is from outside of this forum
              [email protected]
              wrote on last edited by
              #19

              the programming language that had a stated design goal to do its best and try to keep running scripts that make no sense...

              ...itself makes no sense. It is wrong and bad that Javascript was ever designed that way in the first place.

              whaleross@lemmy.worldW 1 Reply Last reply
              18
              • avidamoeba@lemmy.caA [email protected]

                This is too stupid so I had to check.

                Fuck me.

                cidvicious@sh.itjust.worksC This user is from outside of this forum
                cidvicious@sh.itjust.worksC This user is from outside of this forum
                [email protected]
                wrote on last edited by
                #20

                I think I'm on the side of "if you do this in your code, you deserve what you get."

                1 Reply Last reply
                8
                • cm0002@lemmy.worldC [email protected]
                  This post did not contain any content.
                  supervisor194@lemmy.worldS This user is from outside of this forum
                  supervisor194@lemmy.worldS This user is from outside of this forum
                  [email protected]
                  wrote on last edited by [email protected]
                  #21

                  It's not that hard to understand what it is doing and why the decision was made to make it do that. JavaScript has a particular purpose and it's mission is not consistency.

                  It's not like TypeScript doesn't exist if you just get lightheaded at the idea of learning JavaScript's quirks and mastering using it despite them.

                  S 1 Reply Last reply
                  3
                  • gsus4@mander.xyzG [email protected]

                    Hm, playing devil's advocate, I think it is because the minus has not been defined as a string operation (e.g. it could pop the last char), so it defaults to the mathematical operation and converts both inputs into ints.

                    The first is assumed to be a concat because one of the parcels is a string...

                    It's just doing a lot of stuff for you that it shouldn't be in first place 🀭

                    0 This user is from outside of this forum
                    0 This user is from outside of this forum
                    [email protected]
                    wrote on last edited by
                    #22

                    It's just doing a lot of stuff for you that it shouldn't be in first place 🀭

                    Kinda like log4j!

                    1 Reply Last reply
                    5
                    • whaleross@lemmy.worldW [email protected]

                      People that try to do mathematical operations with strings blaming the programming language that had a stated design goal to do its best and try to keep running scripts that make no sense because they realized it would be used by people that have no idea what they are doing. Clearly they were right.

                      0 This user is from outside of this forum
                      0 This user is from outside of this forum
                      [email protected]
                      wrote on last edited by
                      #23

                      it would be used by people that have no idea what they are doing. Clearly

                      And so let's enable these people?
                      Let's add AI to the mix while we're at it.

                      whaleross@lemmy.worldW 1 Reply Last reply
                      7
                      • G [email protected]

                        Which "1" did it remove? And did it search the string to find a "1" to remove, or did it remove whichever character happened to be at array index 1?

                        __nobodynowhere@sh.itjust.works_ This user is from outside of this forum
                        __nobodynowhere@sh.itjust.works_ This user is from outside of this forum
                        [email protected]
                        wrote on last edited by
                        #24

                        The one at the end. Subtraction is the opposite of addition. If addition adds a character to the end of the string, it must follow that subtraction would remove a character from the end of the string.

                        R 1 Reply Last reply
                        4
                        • cm0002@lemmy.worldC [email protected]
                          This post did not contain any content.
                          wreleven@lemmy.caW This user is from outside of this forum
                          wreleven@lemmy.caW This user is from outside of this forum
                          [email protected]
                          wrote on last edited by
                          #25

                          Feels like it could be one of those facebook posts to test "smart" people. Only the top 1% of people can answer this simple math question: "11" + 2 * 2 - 3

                          1 Reply Last reply
                          6
                          • G [email protected]

                            the programming language that had a stated design goal to do its best and try to keep running scripts that make no sense...

                            ...itself makes no sense. It is wrong and bad that Javascript was ever designed that way in the first place.

                            whaleross@lemmy.worldW This user is from outside of this forum
                            whaleross@lemmy.worldW This user is from outside of this forum
                            [email protected]
                            wrote on last edited by
                            #26

                            It was never intended to run full applications but only the small business scripts and hobbyist homepage stuff that were the thing in the 90s, across inconsistent browsers that were a jungle of hit and miss behaviour where it was preferred that menus keep working even if the mouse effect was not. Anything of scale was expected to be done in Java. Dynamic web pages did not exist and as anything not static was generated server side into a static html file to be rendered on the client.

                            Anyway, back then it wasn't considered the job of the programming language to hold the hand of the aspiring developer as it is common today. It's not a bad thing that IDE and even compilers and preprocessors try to help you write better code today, but then it simply didn't exist.

                            JavaScript is from a different time and because it has the hard requirement or backwards compatibility there is no changing it and has not been for thirty years except to add stuff to it.

                            I think it's just silly to ask the past to keep up with the present. Bad code is not the fault of the language regardless, even though junior devs and even seasoned ones like to think so to protect their ego. I think it is better to accept it, learn from it and roll with it because every single platform and language has their weird quirks anyway.

                            Signed, old dude that learned programming in 8 bit BASIC and 6502 machine code without an assembler, where code bad enough would freeze your machine that required a cold boot and starting over from your last save that you didn't do.

                            B R 2 Replies Last reply
                            15
                            • 0 [email protected]

                              it would be used by people that have no idea what they are doing. Clearly

                              And so let's enable these people?
                              Let's add AI to the mix while we're at it.

                              whaleross@lemmy.worldW This user is from outside of this forum
                              whaleross@lemmy.worldW This user is from outside of this forum
                              [email protected]
                              wrote on last edited by
                              #27

                              Now that you mention it, it is a bit funny how Lemmy is hating LLMs as a code generation tool while also hating on the interpreter for their own hand typed code not running.

                              0 I 2 Replies Last reply
                              4
                              • whaleross@lemmy.worldW [email protected]

                                It was never intended to run full applications but only the small business scripts and hobbyist homepage stuff that were the thing in the 90s, across inconsistent browsers that were a jungle of hit and miss behaviour where it was preferred that menus keep working even if the mouse effect was not. Anything of scale was expected to be done in Java. Dynamic web pages did not exist and as anything not static was generated server side into a static html file to be rendered on the client.

                                Anyway, back then it wasn't considered the job of the programming language to hold the hand of the aspiring developer as it is common today. It's not a bad thing that IDE and even compilers and preprocessors try to help you write better code today, but then it simply didn't exist.

                                JavaScript is from a different time and because it has the hard requirement or backwards compatibility there is no changing it and has not been for thirty years except to add stuff to it.

                                I think it's just silly to ask the past to keep up with the present. Bad code is not the fault of the language regardless, even though junior devs and even seasoned ones like to think so to protect their ego. I think it is better to accept it, learn from it and roll with it because every single platform and language has their weird quirks anyway.

                                Signed, old dude that learned programming in 8 bit BASIC and 6502 machine code without an assembler, where code bad enough would freeze your machine that required a cold boot and starting over from your last save that you didn't do.

                                B This user is from outside of this forum
                                B This user is from outside of this forum
                                [email protected]
                                wrote on last edited by
                                #28

                                Anyway, back then it wasn't considered the job of the programming language to hold the hand of the aspiring developer as it is common today.

                                But that’s exactly what it’s doing by trying to figure out what the developer meant. β€˜β€œ11” + 1’, should cause the compiler to tell the developer to to fuck themselves.

                                1 Reply Last reply
                                5
                                • __nobodynowhere@sh.itjust.works_ [email protected]

                                  The one at the end. Subtraction is the opposite of addition. If addition adds a character to the end of the string, it must follow that subtraction would remove a character from the end of the string.

                                  R This user is from outside of this forum
                                  R This user is from outside of this forum
                                  [email protected]
                                  wrote on last edited by
                                  #29

                                  This is how we end up with an endian schism

                                  1 Reply Last reply
                                  1
                                  • whaleross@lemmy.worldW [email protected]

                                    People that try to do mathematical operations with strings blaming the programming language that had a stated design goal to do its best and try to keep running scripts that make no sense because they realized it would be used by people that have no idea what they are doing. Clearly they were right.

                                    M This user is from outside of this forum
                                    M This user is from outside of this forum
                                    [email protected]
                                    wrote on last edited by
                                    #30

                                    There's also Chefkoch and Mozart for that purpose.

                                    1 Reply Last reply
                                    0
                                    • G [email protected]

                                      It is 'comprehensible' in the sense that it's possible to figure out how it happened, but it absolutely does not "make sense" in terms of being a reasonable language design decision. It's 100% incompetence on the part of the person who created Javascript.

                                      A This user is from outside of this forum
                                      A This user is from outside of this forum
                                      [email protected]
                                      wrote on last edited by
                                      #31

                                      I mean, I'd never try to do this anyway because if the types aren't the same unexpected things can happen. That's like programming 101.

                                      G 1 Reply Last reply
                                      3
                                      • whaleross@lemmy.worldW [email protected]

                                        Now that you mention it, it is a bit funny how Lemmy is hating LLMs as a code generation tool while also hating on the interpreter for their own hand typed code not running.

                                        0 This user is from outside of this forum
                                        0 This user is from outside of this forum
                                        [email protected]
                                        wrote on last edited by
                                        #32

                                        I seldom use an interpreter.

                                        whaleross@lemmy.worldW 1 Reply Last reply
                                        1
                                        • avidamoeba@lemmy.caA [email protected]

                                          This is too stupid so I had to check.

                                          Fuck me.

                                          J This user is from outside of this forum
                                          J This user is from outside of this forum
                                          [email protected]
                                          wrote on last edited by
                                          #33

                                          From all the Javascript quiks this is the least stupid and the most obvious.

                                          1 Reply Last reply
                                          22
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups