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.
  • cm0002@lemmy.worldC [email protected]
    This post did not contain any content.
    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
    #106

    Imagine doing math with strings and then blaming the language not yourself

    Z gmtom@lemmy.worldG 2 Replies Last reply
    35
    • R [email protected]

      Imagine doing math with strings and then blaming the language not yourself

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

      The risk is when it happens unintentionally. The language is bad for hiding such errors by being overly 'helpful' in assuming intent.

      F 1 Reply Last reply
      42
      • Z [email protected]

        The risk is when it happens unintentionally. The language is bad for hiding such errors by being overly 'helpful' in assuming intent.

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

        Sure, but at this point it's your own fault if you don't use Typescript to keep these issues from happening.

        S J 2 Replies Last reply
        11
        • F [email protected]

          Sure, but at this point it's your own fault if you don't use Typescript to keep these issues from happening.

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

          So, just don’t use JavaScript?

          F M S 3 Replies Last reply
          8
          • F [email protected]

            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 This user is from outside of this forum
            G This user is from outside of this forum
            [email protected]
            wrote on last edited by
            #110

            Computing a nonsensical result is itself a failure. Continuing to run while avoiding giving an error in that case accomplishes nothing but to make the program harder to debug.

            1 Reply Last reply
            0
            • S [email protected]

              So, just don’t use 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
              #111

              I wouldn't use raw JS for anything new, yes. Typescript however is an excellent language.

              1 Reply Last reply
              3
              • L [email protected]

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

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

                (.) is a valid expression in Haskell. Normally it is the prefix form of the infix operator . that does function
                composition. (.) (2*) (1+) 3 = ((2*) . (1+)) 3 = 2 * (1 + 3) = 8.

                But, the most common use of the word "boob" in my experience in Haskell is the "boobs operator": (.)(.). It's usage in Haskell is limited (tho valid), but it's appearance in racy ASCII art predates even the first versions on Haskell.

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

                  That is just the tip of the iceberg:

                  https://whatthefsharp.com/JavaScript/3

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

                  Haha that’s a great site. But I think the C example is actually reasonable behaviour.

                  1 Reply Last reply
                  2
                  • J [email protected]

                    Instead of trying to make it work, javascript could just say "error." Being untyped doesn't mean you can't have error messages.

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

                    I think it's less about type system, and more about lack of a separate compilation step.

                    With a compilation step, you can have error messages that developers see, but users don't. (Hopefully, these errors enable the developers to reduce the errors that users see, and just generally improve the UX, but that's NOT guaranteed.)

                    Without a compilation step, you have to assign some semantics to whatever random source string your interpreter gets. And, while you can certainly make that an error, that would rarely be helpful for the user. JS instead made the choice to, as much as possible, avoid error semantics in favor of silent coercions, conversions, and conflations in order to make every attempt to not "error-out" on the user.

                    It would be a very painful decade indeed to now change the semantics for some JS source text.

                    Purescript is a great option. Typescript is okay. You could also introduce a JS-to-JS "compilation" step that DID reject (or at least warn the developer) for source text that "should" be given an error semantic, but I don't know an "off-the-shelf" approach for that -- other than JSLint.

                    1 Reply Last reply
                    1
                    • R [email protected]

                      Also, you contradicted yourself just then and there. Not a single of your examples does string concatenation for these types. It's only JS

                      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
                      #115
                      • In https://lemm.ee/comment/20947041 they claimed "implicit type coercion" and showed many examples; they did NOT claim "string concatenation".
                      • However, that was in reply to https://lemmy.world/comment/17473361 which was talking about "implicit conversion to string" which is a specific type of "implicit type coercion"; NONE of the examples given involved a conversion to string.
                      • But also, that was in reply to https://lemm.ee/comment/20939144 which only mentions "implicit type coercion" in general.

                      So, I think probably everyone in the thread is "correct", but you are actually talking past one another.

                      I think the JS behavior is a bad design choice, but it is well documented and consistent across implementations.

                      R 1 Reply Last reply
                      2
                      • F [email protected]

                        Sure, but at this point it's your own fault if you don't use Typescript to keep these issues from happening.

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

                        "Use a different language" is a common defense of javascript, but kind of a weird one.

                        F 1 Reply Last reply
                        22
                        • 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
                          #117

                          If you're consciously and intentionally using JavaScript like that, I don't want to be friends with you.

                          1 Reply Last reply
                          4
                          • J [email protected]

                            "Use a different language" is a common defense of javascript, but kind of a weird one.

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

                            Not really, considering Typescript only adds static types to JS. It's not a different language, it's an extension.

                            Q 1 Reply Last reply
                            4
                            • R [email protected]

                              Imagine doing math with strings and then blaming the language not yourself

                              gmtom@lemmy.worldG This user is from outside of this forum
                              gmtom@lemmy.worldG This user is from outside of this forum
                              [email protected]
                              wrote on last edited by
                              #119

                              The problem is consistency.

                              1 Reply Last reply
                              14
                              • cm0002@lemmy.worldC [email protected]
                                This post did not contain any content.
                                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 [email protected]
                                #120

                                Javascript is a dogshit language that everyone is stuck with. The best that we can hope for is the likes of typescript take the edge off of it. Even though it's like smearing marzipan over a turd. At least it's ok if you don't take a deep bite.

                                1 Reply Last reply
                                14
                                • S [email protected]

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

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

                                  So you don't have a suggestion. Got it.

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

                                    So you don't have a suggestion. Got it.

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

                                    Of course. Nothing beats JS, oh guru mighty guru

                                    supervisor194@lemmy.worldS 1 Reply Last reply
                                    0
                                    • B [email protected]
                                      • In https://lemm.ee/comment/20947041 they claimed "implicit type coercion" and showed many examples; they did NOT claim "string concatenation".
                                      • However, that was in reply to https://lemmy.world/comment/17473361 which was talking about "implicit conversion to string" which is a specific type of "implicit type coercion"; NONE of the examples given involved a conversion to string.
                                      • But also, that was in reply to https://lemm.ee/comment/20939144 which only mentions "implicit type coercion" in general.

                                      So, I think probably everyone in the thread is "correct", but you are actually talking past one another.

                                      I think the JS behavior is a bad design choice, but it is well documented and consistent across implementations.

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

                                      Read the thread again, it seems you slipped somewhere. This was all about the claim that implicit conversion to string somehow could make sense.

                                      1 Reply Last reply
                                      0
                                      • B [email protected]

                                        (.) is a valid expression in Haskell. Normally it is the prefix form of the infix operator . that does function
                                        composition. (.) (2*) (1+) 3 = ((2*) . (1+)) 3 = 2 * (1 + 3) = 8.

                                        But, the most common use of the word "boob" in my experience in Haskell is the "boobs operator": (.)(.). It's usage in Haskell is limited (tho valid), but it's appearance in racy ASCII art predates even the first versions on Haskell.

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

                                        The pioneers of ASCII art in the 70s and 80s are the unsung heroes of porn.

                                        1 Reply Last reply
                                        1
                                        • S [email protected]

                                          Of course. Nothing beats JS, oh guru mighty guru

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

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

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