Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • 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
Code Project
  1. Home
  2. The Lounge
  3. Most head-slapping feature in a language

Most head-slapping feature in a language

Scheduled Pinned Locked Moved The Lounge
javascriptdatabasecomlounge
36 Posts 27 Posters 0 Views 1 Watching
  • 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 Chris Maunder

    @Forogar and I were having a chat about unintended programming features (ahem) due to things like: Javascript's truthy: "1" == 1 is true Rexx: " Hello " == "Hello" and 0.0 == 0 is not the same as 0 == 0.0 SQL: Len("hello") = Len("hello ") I'm just wondering what other family favourites there are out there. (Edited because clearly I’ve lost track of what’s up and what’s down)

    cheers Chris Maunder

    Sander RosselS Offline
    Sander RosselS Offline
    Sander Rossel
    wrote on last edited by
    #16

    Try the Predict the Output Challenge (C#)[^]. It shows some fun C# quirks (especially part 1) with types, enumerables etc. :D

    Best, Sander sanderrossel.com Continuous Integration, Delivery, and Deployment arrgh.js - Bringing LINQ to JavaScript Object-Oriented Programming in C# Succinctly

    1 Reply Last reply
    0
    • C Chris Maunder

      @Forogar and I were having a chat about unintended programming features (ahem) due to things like: Javascript's truthy: "1" == 1 is true Rexx: " Hello " == "Hello" and 0.0 == 0 is not the same as 0 == 0.0 SQL: Len("hello") = Len("hello ") I'm just wondering what other family favourites there are out there. (Edited because clearly I’ve lost track of what’s up and what’s down)

      cheers Chris Maunder

      D Offline
      D Offline
      Davyd McColl
      wrote on last edited by
      #17

      I'm sure your first one should be: ``` "1" == 1 is true ``` `===` specifically takes type into account. Javascript's type co-ercion can be a win or a lose, depending on what you want. If type matters, use `===` and `!==`

      1 Reply Last reply
      0
      • C Chris Maunder

        @Forogar and I were having a chat about unintended programming features (ahem) due to things like: Javascript's truthy: "1" == 1 is true Rexx: " Hello " == "Hello" and 0.0 == 0 is not the same as 0 == 0.0 SQL: Len("hello") = Len("hello ") I'm just wondering what other family favourites there are out there. (Edited because clearly I’ve lost track of what’s up and what’s down)

        cheers Chris Maunder

        C Offline
        C Offline
        CodeWraith
        wrote on last edited by
        #18

        That kind of things already existed when our ancestors began to cast logic into silicon[^]. Of course, there also were well designed CPUs[^] that had exactly 256 opcodes, with only 0x68 being reserved as prefix for future expansions of the instruction set. And of course there are the opcodes 0xE0 - 0xEF, the 'Set X Register' instruction for registers 0x0 - 0xF, short SEX. Absolutely no confusion here.

        I have lived with several Zen masters - all of them were cats. His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.

        1 Reply Last reply
        0
        • C Chris Maunder

          @Forogar and I were having a chat about unintended programming features (ahem) due to things like: Javascript's truthy: "1" == 1 is true Rexx: " Hello " == "Hello" and 0.0 == 0 is not the same as 0 == 0.0 SQL: Len("hello") = Len("hello ") I'm just wondering what other family favourites there are out there. (Edited because clearly I’ve lost track of what’s up and what’s down)

          cheers Chris Maunder

          S Offline
          S Offline
          Simon_Whale
          wrote on last edited by
          #19

          Chris Maunder wrote:

          SQL: Len("hello") = Len("hello ")

          That is a fun one that I came across a while ago. for some reason SQL Server ignores the trailing spaces hence they match. LEN (Transact-SQL) - SQL Server | Microsoft Docs[^]

          Every day, thousands of innocent plants are killed by vegetarians. Help end the violence EAT BACON

          1 Reply Last reply
          0
          • C Chris Maunder

            @Forogar and I were having a chat about unintended programming features (ahem) due to things like: Javascript's truthy: "1" == 1 is true Rexx: " Hello " == "Hello" and 0.0 == 0 is not the same as 0 == 0.0 SQL: Len("hello") = Len("hello ") I'm just wondering what other family favourites there are out there. (Edited because clearly I’ve lost track of what’s up and what’s down)

            cheers Chris Maunder

            M Offline
            M Offline
            markchagers
            wrote on last edited by
            #20

            erm, typo?

            "1" === 1 is false
            "1" == 1 is true (truthy rather)

            C 1 Reply Last reply
            0
            • M MacSpudster

              Officially, I actively choose to not slap myself becuz of a (programming) language's nuance(s). :doh:

              The best way to improve Windows is run it on a Mac. The best way to bring a Mac to its knees is to run Windows on it. ~ my brother Jeff

              B Offline
              B Offline
              BryanFazekas
              wrote on last edited by
              #21

              Re-read the OP. Chris didn't state he was going to slap his own head .... :laugh:

              M 1 Reply Last reply
              0
              • C Chris Maunder

                @Forogar and I were having a chat about unintended programming features (ahem) due to things like: Javascript's truthy: "1" == 1 is true Rexx: " Hello " == "Hello" and 0.0 == 0 is not the same as 0 == 0.0 SQL: Len("hello") = Len("hello ") I'm just wondering what other family favourites there are out there. (Edited because clearly I’ve lost track of what’s up and what’s down)

                cheers Chris Maunder

                L Offline
                L Offline
                loctrice
                wrote on last edited by
                #22

                "1" === 1 is true false

                Elephant elephant elephant, sunshine sunshine sunshine

                1 Reply Last reply
                0
                • C Chris Maunder

                  @Forogar and I were having a chat about unintended programming features (ahem) due to things like: Javascript's truthy: "1" == 1 is true Rexx: " Hello " == "Hello" and 0.0 == 0 is not the same as 0 == 0.0 SQL: Len("hello") = Len("hello ") I'm just wondering what other family favourites there are out there. (Edited because clearly I’ve lost track of what’s up and what’s down)

                  cheers Chris Maunder

                  K Offline
                  K Offline
                  kalberts
                  wrote on last edited by
                  #23

                  In Fortran (at least in the old days, Fortran IV and thereabouts) has no reserved words. Spaces have no significance. So you could declare a variable named INTEGER REAL INTEGER INTEGER = 3.14 or a subroutine named FUNCTION to be invoked by CALL FUNCTION(...) The standard loop construct is the DO loop, but DO U BLEP RECISION IF is not the start of a loop. Rather, you could make a comparison with the above variable IF (IF.GT.INTEGER) ... In my student days, there was a single course teaching Fortran. We made it a habit to solve the execizes using predefined identifiers only. Sort of like OCCC, but it took far less effort to obfuscate Fortran.

                  1 Reply Last reply
                  0
                  • C Christian Graus

                    The point of === is that "1" == 1 but "1" !== 1, that is, "1" === 1 will return false, due to the differing types

                    R Offline
                    R Offline
                    realJSOP
                    wrote on last edited by
                    #24

                    This is the kind of crap you get in a weakly typed language.

                    ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                    -----
                    You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                    -----
                    When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

                    1 Reply Last reply
                    0
                    • C Chris Maunder

                      @Forogar and I were having a chat about unintended programming features (ahem) due to things like: Javascript's truthy: "1" == 1 is true Rexx: " Hello " == "Hello" and 0.0 == 0 is not the same as 0 == 0.0 SQL: Len("hello") = Len("hello ") I'm just wondering what other family favourites there are out there. (Edited because clearly I’ve lost track of what’s up and what’s down)

                      cheers Chris Maunder

                      A Offline
                      A Offline
                      Asday
                      wrote on last edited by
                      #25

                      >`"1" === 1 is true` What? `is` is not a keyword in js, and `"1" === 1` evaluates as `false`. What's going on here?

                      1 Reply Last reply
                      0
                      • C Chris Maunder

                        @Forogar and I were having a chat about unintended programming features (ahem) due to things like: Javascript's truthy: "1" == 1 is true Rexx: " Hello " == "Hello" and 0.0 == 0 is not the same as 0 == 0.0 SQL: Len("hello") = Len("hello ") I'm just wondering what other family favourites there are out there. (Edited because clearly I’ve lost track of what’s up and what’s down)

                        cheers Chris Maunder

                        K Offline
                        K Offline
                        Kirk 10389821
                        wrote on last edited by
                        #26

                        In the old fortran stuff: 3 = 9 And change the value of 3 to 9 (Because some nimrod decided to declare numeric constants as variables?) LMAO. But they fix everything by adding an =, so we get =, ==, ===... I am waiting to read some code:

                        if (x ======= y) // equal on 7 planes of existence

                        and

                        if (x ======== y) // A fuzzy version of the above allowing for LESS Equality to be Equal, LMAO

                        1 Reply Last reply
                        0
                        • C Chris Maunder

                          @Forogar and I were having a chat about unintended programming features (ahem) due to things like: Javascript's truthy: "1" == 1 is true Rexx: " Hello " == "Hello" and 0.0 == 0 is not the same as 0 == 0.0 SQL: Len("hello") = Len("hello ") I'm just wondering what other family favourites there are out there. (Edited because clearly I’ve lost track of what’s up and what’s down)

                          cheers Chris Maunder

                          J Offline
                          J Offline
                          jfren484
                          wrote on last edited by
                          #27

                          "1" === 1 is true

                          Umm, this statement is false. Put "1" === 1 into the dev tools console and it will output false.

                          1 Reply Last reply
                          0
                          • M markchagers

                            erm, typo?

                            "1" === 1 is false
                            "1" == 1 is true (truthy rather)

                            C Offline
                            C Offline
                            Chris Maunder
                            wrote on last edited by
                            #28

                            I don’t even know anymore. I’m so confused.

                            cheers Chris Maunder

                            M 1 Reply Last reply
                            0
                            • B BryanFazekas

                              Re-read the OP. Chris didn't state he was going to slap his own head .... :laugh:

                              M Offline
                              M Offline
                              MacSpudster
                              wrote on last edited by
                              #29

                              Y'all need to re-read my comment. Never did imply nor explicitly express Chris did or would do that. :doh:

                              The best way to improve Windows is run it on a Mac. The best way to bring a Mac to its knees is to run Windows on it. ~ my brother Jeff

                              1 Reply Last reply
                              0
                              • C Chris Maunder

                                @Forogar and I were having a chat about unintended programming features (ahem) due to things like: Javascript's truthy: "1" == 1 is true Rexx: " Hello " == "Hello" and 0.0 == 0 is not the same as 0 == 0.0 SQL: Len("hello") = Len("hello ") I'm just wondering what other family favourites there are out there. (Edited because clearly I’ve lost track of what’s up and what’s down)

                                cheers Chris Maunder

                                T Offline
                                T Offline
                                Timothy Purdy
                                wrote on last edited by
                                #30

                                I just loved seeing C/C++ code from colleagues too lazy to comment out a block of code (and letting it sit there for years) via: #if 0 ... #endif I should just go back to clean it out, but now it's nostalgic for me. :-)

                                1 Reply Last reply
                                0
                                • C Chris Maunder

                                  I don’t even know anymore. I’m so confused.

                                  cheers Chris Maunder

                                  M Offline
                                  M Offline
                                  MikeTheFid
                                  wrote on last edited by
                                  #31

                                  Wait 5 years. It will be:

                                  "1" ============== 1

                                  As in, "I really really really really really really really really really want to know if it's really really really really really really really really somewhat mildly truthy."

                                  Cheers, Mike Fidler "I intend to live forever - so far, so good." Steven Wright "I almost had a psychic girlfriend but she left me before we met." Also Steven Wright "I'm addicted to placebos. I could quit, but it wouldn't matter." Steven Wright yet again.

                                  1 Reply Last reply
                                  0
                                  • P Peter_in_2780

                                    I had a colleague who insisted on occasionally writing the (perfectly valid but ummm counter-intuitive) form

                                    index[array]

                                    in C. He also worked out some multi-dimensional extensions, which my marginal brain is too small to contain. And yes, he did have a shot at the The International Obfuscated C Code Contest[^] Cheers, Peter

                                    Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012

                                    A Offline
                                    A Offline
                                    Alister Morton
                                    wrote on last edited by
                                    #32

                                    Yes, I was (long ago) proudly shown char c = i["Some string"];

                                    1 Reply Last reply
                                    0
                                    • P Peter_in_2780

                                      I had a colleague who insisted on occasionally writing the (perfectly valid but ummm counter-intuitive) form

                                      index[array]

                                      in C. He also worked out some multi-dimensional extensions, which my marginal brain is too small to contain. And yes, he did have a shot at the The International Obfuscated C Code Contest[^] Cheers, Peter

                                      Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012

                                      A Offline
                                      A Offline
                                      Alister Morton
                                      wrote on last edited by
                                      #33

                                      Yes, I was (long ago) proudly shown char c = i["Some string"]; - perfectly valid if not immediately obvious to the beginner.

                                      1 Reply Last reply
                                      0
                                      • P Peter_in_2780

                                        I had a colleague who insisted on occasionally writing the (perfectly valid but ummm counter-intuitive) form

                                        index[array]

                                        in C. He also worked out some multi-dimensional extensions, which my marginal brain is too small to contain. And yes, he did have a shot at the The International Obfuscated C Code Contest[^] Cheers, Peter

                                        Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012

                                        E Offline
                                        E Offline
                                        englebart
                                        wrote on last edited by
                                        #34

                                        I had never thought about pointer arithmetic being commutative before... seems consistent at least. int index = 1; char *address = "String"; index[address] is the same as *(index + address) address[index] is the same as *(address + index) + implicitly includes the size of the base data type. (char) If this was attempted with variables instead of constants, you might end up with memory protection issues. Most OSes would not want you to start a loop by loading memory address 1 into a register. They would let you load the memory address of "String"

                                        1 Reply Last reply
                                        0
                                        • C Chris Maunder

                                          @Forogar and I were having a chat about unintended programming features (ahem) due to things like: Javascript's truthy: "1" == 1 is true Rexx: " Hello " == "Hello" and 0.0 == 0 is not the same as 0 == 0.0 SQL: Len("hello") = Len("hello ") I'm just wondering what other family favourites there are out there. (Edited because clearly I’ve lost track of what’s up and what’s down)

                                          cheers Chris Maunder

                                          D Offline
                                          D Offline
                                          Dan Neely
                                          wrote on last edited by
                                          #35

                                          On Error Resume Next

                                          /thread

                                          Did you ever see history portrayed as an old man with a wise brow and pulseless heart, weighing all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt

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


                                          • Login

                                          • Don't have an account? Register

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