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 3 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]

    This is too stupid so I had to check.

    Fuck me.

    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
    #10

    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.

    T G 2 Replies Last reply
    12
    • 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.

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

      It's an issue with most if not all languages that aren't strongly typed.

      1 Reply Last reply
      5
      • P [email protected]

        You have some random QA Testers to thank for that!

        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 [email protected]
        #12

        This is a really good interview, and does a good job highlighting Javascript's biggest strength: it's flexibility.

        “It was also an incredible rush job, so there were mistakes in it. Something that I think is important about it is that I knew there would be mistakes, and there would be gaps, so I made it very malleable as a language.”

        He cites the “discovery” of asm.js inside of JavaScript, calling it “another thing I’m particularly proud of in the last 10 years.” It uses the bitwise operators that were included in the original JavaScript which are now the basis for a statically-typed language with machine types for high-speed performance. “If it hadn’t been in there from 1995, it would’ve been hard to add later. And the fact that it was there all along meant we could do incredibly fast JavaScript.”

        He tells InfoWorld it’s “this very potent seed that was in the original JavaScript from the 10 days of May in 1995.” JavaScript’s 32-bit math operators (known as bitwise operators) trace their lineage all the way back to the C programming language — and to Java. This eventually led to WebAssembly — a way to convert instructions into a quickly-executable binary format for virtual machines — and the realization that with a JavaScript engine, “you can have two languages — the old language I did with the curly braces and the functions and the shift operators, and this new language which is a binary language, not meant for reading by humans or writing. But it can be generated by compilers and tools, and can be read by tools…”

        1 Reply Last reply
        6
        • 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 🤭

          avidamoeba@lemmy.caA This user is from outside of this forum
          avidamoeba@lemmy.caA This user is from outside of this forum
          [email protected]
          wrote on last edited by
          #13

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

          gsus4@mander.xyzG 1 Reply Last reply
          13
          • 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
                                          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