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.
  • C [email protected]

    This is fair enough from an idealistic view. In practice, you don't want your entire website to shit itself because of a potentially insignificant error.

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

    In practice runtime errors are a bitch to find and fix.

    C 1 Reply Last reply
    7
    • pupbiru@aussie.zoneP [email protected]

      this the β€œor throw an error”

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

      If you try what I wrote it will throw a NaN. I was asking about the first part of the proposal.

      S 1 Reply Last reply
      1
      • L [email protected]

        I don't even know Haskell but it seems like (" ( , ) ") would be an instance of boob.

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

        It looks like two worms split running from another tinier worm. Makes you wonder what it has done to be so feared

        1 Reply Last reply
        0
        • C [email protected]

          This is fair enough from an idealistic view. In practice, you don't want your entire website to shit itself because of a potentially insignificant error.

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

          This is exactly why it should throw an error, to make it incredibly obvious something isn't working correctly so it can be fixed. Otherwise you have wrong logic leading to hard to notice and hard to debug problems in your code

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

            That is just the tip of the iceberg:

            https://whatthefsharp.com/JavaScript/3

            T candyman337@sh.itjust.worksC M C W 6 Replies Last reply
            15
            • 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.

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

              It makes perfect sense if the Lang objective is to fail as little as possible. It picks the left side object, checks if the operand is a valid operand of the type. If it is, it casts the right variable into that type and perform the operand. If it isn't, it reverses operand positions and tries again.

              The issue here is more the fact that + is used both as addition and as concatenation with different data types. Well, not an issue, just some people will complain.

              G 1 Reply Last reply
              1
              • S [email protected]

                Lol. In a dynamically typed language? I will do this always, that's why I am using it

                exu@feditown.comE This user is from outside of this forum
                exu@feditown.comE This user is from outside of this forum
                [email protected]
                wrote on last edited by
                #77

                You can have a dynamic language that is strongly typed to disallow stuff like this. Like Python for example

                S 1 Reply Last reply
                0
                • exu@feditown.comE [email protected]

                  You can have a dynamic language that is strongly typed to disallow stuff like this. Like Python for example

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

                  Aand what is your point?

                  1 Reply Last reply
                  0
                  • C [email protected]

                    This is fair enough from an idealistic view. In practice, you don't want your entire website to shit itself because of a potentially insignificant error.

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

                    I'd rather have my website shit itself than have silent difficult to find errors.

                    C 1 Reply Last reply
                    4
                    • K [email protected]

                      That is just the tip of the iceberg:

                      https://whatthefsharp.com/JavaScript/3

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

                      F#? What? We can't curse on the internet? Self censorship at dictator levels here. /s

                      1 Reply Last reply
                      3
                      • supervisor194@lemmy.worldS [email protected]

                        Well then, rage against the machine for the next 30 years and see if they kill it in favor of a nice, strict language that everybody loves. Maybe you could suggest one here for consideration.

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

                        So, all you've mustered is some lame-ass whataboutism?
                        Have a good day

                        supervisor194@lemmy.worldS 1 Reply Last reply
                        0
                        • C [email protected]

                          This is fair enough from an idealistic view. In practice, you don't want your entire website to shit itself because of a potentially insignificant error.

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

                          Look! I bought this for free on capybaras website, there's a glitch!

                          capybara: at least it didn't throw an error.

                          / jk 😁

                          C 1 Reply Last reply
                          3
                          • cm0002@lemmy.worldC [email protected]
                            This post did not contain any content.
                            yogsototh@programming.devY This user is from outside of this forum
                            yogsototh@programming.devY This user is from outside of this forum
                            [email protected]
                            wrote on last edited by
                            #83

                            Obligatory link to wat? video

                            https://www.destroyallsoftware.com/talks/wat

                            1 Reply Last reply
                            8
                            • P [email protected]

                              You're right. I've got too much Perl on the brain and forgot my roots. There is a language that does what you're talking about with the '+' operator: BASIC

                              Good luck getting the same thing retrofitted into JavaScript though. I can imagine a large number of websites would break or develop mysterious problems if this (mis)behaviour was fixed.

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

                              I don't think there's a way to retrofit JS - but php versions are deprecated all the time. Why not do the same with client-side script versions? πŸ™‚

                              1 Reply Last reply
                              0
                              • K [email protected]

                                That is just the tip of the iceberg:

                                https://whatthefsharp.com/JavaScript/3

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

                                Oh wow, that's upsetting

                                1 Reply Last reply
                                8
                                • 3 [email protected]

                                  It's not nonsensical, implicit type coercion is a feature of JavaScript, it's perfectly logical and predictable.

                                  JavaScript is a filthy beast, it's not the right tool for every job, but it's not nonsensical.

                                  When you follow a string with a +, it concatenates it with the next value (converted to string if needed). This makes sense, and it's a very standard convention in most languages.

                                  Applying arithmetic to a string would be nonsensical, which they don't do.

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

                                  You are entitled to your opinion. implicit conversion to string is not a feature in most languages for good reasons.

                                  3 1 Reply Last reply
                                  0
                                  • K [email protected]

                                    That is just the tip of the iceberg:

                                    https://whatthefsharp.com/JavaScript/3

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

                                    Not just javascript: https://www.destroyallsoftware.com/talks/wat

                                    1 Reply Last reply
                                    3
                                    • K [email protected]

                                      That is just the tip of the iceberg:

                                      https://whatthefsharp.com/JavaScript/3

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

                                      Ugh, like... I get why it outputs like that, but I also absolutely hate that it outputs like that.

                                      1 Reply Last reply
                                      2
                                      • R [email protected]

                                        If you try what I wrote it will throw a NaN. I was asking about the first part of the proposal.

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

                                        The NaN isn't an thrown. It's just silently put into the result. And in this case it's completely unintelligible. Why would an operation between two strings result in a number?

                                        "Hello" - "world" is an obvious programmer mistake. The interpreter knows that this is not something anyone will ever do on purpose, so it should not silently handle it.

                                        The main problem here is downward coercion. Coercion should only go towards the more permissive type, never towards the more restrictive type.

                                        Coercing a number to a string makes sense, because each number has a representation as a string, so "hello" + 1 makes intuitive sense.

                                        Coercing a string to a number makes no sense, because not every string has a representation as a number (in fact, most strings don't). "hello" - 1 makes no sense at all. So converting a string to a number should be done by an explicit cast or a conversion function. Using - with a string should always result in a thrown error/exception.

                                        R 1 Reply Last reply
                                        1
                                        • C [email protected]

                                          That is absolutely (n > 1) * ("ba" + 0/0 + "a")

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

                                          (n > 1) * ("ba" + 0/0 + "a")

                                          Uncaught ReferenceError: n is not defined

                                          ?

                                          1 Reply Last reply
                                          3
                                          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