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. Why I hate C++

Why I hate C++

Scheduled Pinned Locked Moved The Lounge
c++question
60 Posts 23 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.
  • M Munchies_Matt

    some_array[value];

    [] is over ridden and is commented as // find element matching _Keyval or insert with default mapped Which actually means 'insert it at the end of the list'. Why not a function called 'add_to_map_at_end'? Christ I hate C++ sometimes, it is so up its arse pointless at times.

    N Offline
    N Offline
    Nish Nishant
    wrote on last edited by
    #13

    There may be reasons to dislike C++, but surely this one is a programmer induced problem. :~

    Nish Nishant Consultant Software Architect Ganymede Software Solutions LLC www.ganymedesoftwaresolutions.com

    K 1 Reply Last reply
    0
    • G Gary Wheeler

      OriginalGriff wrote:

      FORTRAN

      OriginalGriff wrote:

      self modifying code

      OriginalGriff wrote:

      misuse of COMMON

      What. The. :elephant:.

      Software Zen: delete this;

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #14

      COMMON allowed you to share variables between different blocks of code: much like a C++ global variable being accessible from different classes. But ... it wasn't type checked, so you could declare a float and then use COMMON to import it as a 7 dimensional array of BYTE values if you wanted. Because the array bounds checking worked on the data as declared in the COMMON statement with no actual reference back to the original variable, you could happily use it to access any location in your memory space. And because there was no physical separation between code and data segments (flat memory model in those days) your code was not in a "read only partition" as code is now. Provided you understood machine code you could revise your program while it was running ... :laugh:

      Sent from my Amstrad PC 1640 Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      pkfoxP G 2 Replies Last reply
      0
      • OriginalGriffO OriginalGriff

        COMMON allowed you to share variables between different blocks of code: much like a C++ global variable being accessible from different classes. But ... it wasn't type checked, so you could declare a float and then use COMMON to import it as a 7 dimensional array of BYTE values if you wanted. Because the array bounds checking worked on the data as declared in the COMMON statement with no actual reference back to the original variable, you could happily use it to access any location in your memory space. And because there was no physical separation between code and data segments (flat memory model in those days) your code was not in a "read only partition" as code is now. Provided you understood machine code you could revise your program while it was running ... :laugh:

        Sent from my Amstrad PC 1640 Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

        pkfoxP Offline
        pkfoxP Offline
        pkfox
        wrote on last edited by
        #15

        Interesting times

        We can’t stop here, this is bat country - Hunter S Thompson RIP

        OriginalGriffO 1 Reply Last reply
        0
        • pkfoxP pkfox

          Interesting times

          We can’t stop here, this is bat country - Hunter S Thompson RIP

          OriginalGriffO Offline
          OriginalGriffO Offline
          OriginalGriff
          wrote on last edited by
          #16

          We committed some serious atrocities in the name of efficiency back then. :-O

          Sent from my Amstrad PC 1640 Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

          K 1 Reply Last reply
          0
          • OriginalGriffO OriginalGriff

            We committed some serious atrocities in the name of efficiency back then. :-O

            Sent from my Amstrad PC 1640 Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

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

            Not as much for speed - more to overcome space limitations. I am too young to have any PDP-8 experience, but an older colleauge told that every single one of the 4094 memory locations - 12 bit data values, 12 bit addresses - was precious. If you had to use a constand, you would always look through the entire binary program to see if the value was already used somewhere, usually as an instruction code, rather that wasting a whole 12 bit word on a duplicate... Yet, with 4096 twelve-bit words, they managed to make a complete newspaper typesetting system (they had hand coded a segment swapping system to read code from a 5 Mbyte (later: 10 Mbyte) disk. Only once did a customer demand all the options, and they couldn't fit all the resident parts into RAM. So they sold that newspaper a 2-CPU solution: When a function in CPU 1 needed to call some code that couldn't fit it, it raised an interrupt signal to CPU 2, the interrupt ID identifying the required function, and went to sleep while CPU 2 was working. Return from the function, in CPU 2, generated an interrupt back to CPU 1, interrupt ID being the result status, so that CPU 1 would wake up and continue its work... I heard about this around 1980, at a time when the PDP-8s had been replaced by PDP-11s serveral years ago, so I guess the story dates to around 1970 ("Computer Techniques A/S", later renamed "Comtec AS", was founded in 1967).

            1 Reply Last reply
            0
            • OriginalGriffO OriginalGriff

              Hey! You can do stupid things in any language, if you try hard. Back in my FORTRAN days, I discovered you could write self modifying code with judicious misuse of COMMON ... you can't do it now, but back then? Handy... :cringe:

              Sent from my Amstrad PC 1640 Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

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

              When structured languages (like Algol, Pascal etc) came onto the scene, we used to say that "You can program FORTRAN in any language". Around 1980. a professor in the Mecanical Engineering Department and eager FORTRAN coder wrote an article for the newsletter from the University Computing Center, with a fierce attack on this silly idea of indenting loops and conditional blocks (when programming in these new languages). Like in a book: All text is left justified, starting at the margin. You can't make it consistent anyway, if you, say, have a labeled statement in that indented part: Any jump to that label would break the idea of this indented block being a coherent unit... Or something like that. I believe I still have that newsletter in my archives. I really should dig it up to see if he had any valid arguments at all. He probably didn't. I can't imagine what they would be.

              G 1 Reply Last reply
              0
              • N Nish Nishant

                There may be reasons to dislike C++, but surely this one is a programmer induced problem. :~

                Nish Nishant Consultant Software Architect Ganymede Software Solutions LLC www.ganymedesoftwaresolutions.com

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

                One reason to dislike C(++) is that it provides excellent tools for a programmer to make a mess in a very simple way. In the earlier days, you could see quite a few horrible cases of poiner arithmetic - and the programmers were proud of it, proud of how they could do things that were impossible in toy languages like Pascal that gave you a slap on your fingers for just addressing outside the array limits, and introducing artificial differences between a pointer to the start of an array and the array itself. Every knowledgeabler person should know that they are the same! Fortunately, intricate pointer arithmetic is no longer the way to prove your skills. OO techniques has been more popular for that for at least 15-20 years. Virtual functions and overrides may be terribly abused, too, and what is the big difference bewtween operator overloading and virtual functions, at the conceptual level?

                M 1 Reply Last reply
                0
                • R Rage

                  OriginalGriff wrote:

                  if you try hard.

                  And the lazies use VB.

                  Do not escape reality : improve reality !

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

                  I remember "PEEK(address)" and "POKE address, value" as dearly loved functions, but that was in the DOS days. If my memory is correct, it never made it into Visual Basic, though. (I guess it would be more or less meaningless, too, considering the memory management of Windows.)

                  1 Reply Last reply
                  0
                  • T TheGreatAndPowerfulOz

                    What you should really be hating on is the abhorrent coder not the language. That's like hating the hammer that was used to build the crappy shack you live in.

                    #SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun

                    M Offline
                    M Offline
                    Munchies_Matt
                    wrote on last edited by
                    #21

                    Oh I do, dont worry, but C++ allows this kind of crap to happen.

                    T 1 Reply Last reply
                    0
                    • M Munchies_Matt

                      Oh I do, dont worry, but C++ allows this kind of crap to happen.

                      T Offline
                      T Offline
                      TheGreatAndPowerfulOz
                      wrote on last edited by
                      #22

                      so does every other language that is of any use beyond kiddie crap.

                      #SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun

                      M 1 Reply Last reply
                      0
                      • T TheGreatAndPowerfulOz

                        so does every other language that is of any use beyond kiddie crap.

                        #SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun

                        M Offline
                        M Offline
                        Munchies_Matt
                        wrote on last edited by
                        #23

                        C++ positively invite this kind of ridiculousness. Give a man a hammer, and everything is a nail. Give a language feature x and every one has to abuse it. C++ has more of these than any other language I have used, ADA, VB, Java, Small Talk, Prolog and of course C, way more.

                        1 Reply Last reply
                        0
                        • D dan sh

                          Suddenly a wild overloaded operator appears... Try stand up comedy. :)

                          "It is easy to decipher extraterrestrial signals after deciphering Javascript and VB6 themselves.", ISanti[^]

                          1 Offline
                          1 Offline
                          11917640 Member
                          wrote on last edited by
                          #24

                          As our program manager said once: After object-oriented design course every programmer writes only singleton classes.

                          1 Reply Last reply
                          0
                          • M Munchies_Matt

                            some_array[value];

                            [] is over ridden and is commented as // find element matching _Keyval or insert with default mapped Which actually means 'insert it at the end of the list'. Why not a function called 'add_to_map_at_end'? Christ I hate C++ sometimes, it is so up its arse pointless at times.

                            1 Offline
                            1 Offline
                            11917640 Member
                            wrote on last edited by
                            #25

                            As our program manager said once: After object-oriented design course every programmer writes only singleton classes.

                            1 Reply Last reply
                            0
                            • D den2k88

                              Any 20 years old code base saw its sharse of clowns, especially the self-taught enthusiast that follow any "guru" blindly. I had such a colleague, luckily he went out slamming the door... unfortunately he had 10 years to make damages. I recently had to update some of his code and I was happy that he was no longer in my proxymity or I would be writing this from behind bars.

                              GCS d-- s-/++ a- C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- ++>+++ y+++*      Weapons extension: ma- k++ F+2 X

                              M Offline
                              M Offline
                              Munchies_Matt
                              wrote on last edited by
                              #26

                              I have come across some right howlers in this code base. Anyway, C++, of all the languages I have used, from ADA, to Prolog, through VB and Java, allows this kind of sillyness. So it is for that that I condemn it. And personally I dont see that OO is a massive benefit over a procedural language except in specific instances. And in fact it is often worse. Particularly in control code, code that is not data centric, but process centric.

                              D S 2 Replies Last reply
                              0
                              • J jeron1

                                While I agree with your statement, std::map implements this very [] operator overload as described. Actually that comment is a nice addition. Would I implement something like that though? probably not.

                                "the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle

                                M Offline
                                M Offline
                                Munchies_Matt
                                wrote on last edited by
                                #27

                                Quite, this is in the map object. Obscene is isnt it, that such an abortion as this is used so widely.

                                L 1 Reply Last reply
                                0
                                • K kalberts

                                  One reason to dislike C(++) is that it provides excellent tools for a programmer to make a mess in a very simple way. In the earlier days, you could see quite a few horrible cases of poiner arithmetic - and the programmers were proud of it, proud of how they could do things that were impossible in toy languages like Pascal that gave you a slap on your fingers for just addressing outside the array limits, and introducing artificial differences between a pointer to the start of an array and the array itself. Every knowledgeabler person should know that they are the same! Fortunately, intricate pointer arithmetic is no longer the way to prove your skills. OO techniques has been more popular for that for at least 15-20 years. Virtual functions and overrides may be terribly abused, too, and what is the big difference bewtween operator overloading and virtual functions, at the conceptual level?

                                  M Offline
                                  M Offline
                                  Munchies_Matt
                                  wrote on last edited by
                                  #28

                                  Member 7989122 wrote:

                                  the programmers were proud of it,

                                  This is a problem in any language, and exactly what I am getting at here.l C++ give bedroom nerd programmers who think complexity is good the chance to do this. Real engineers dont.

                                  Member 7989122 wrote:

                                  what is the big difference bewtween operator overloading and virtual functions

                                  Huge. An overridden function is subclass specialisation. An operator overload is supposed to *improve* the operator's functionality specifically for that class. In fact without overloading that operator might be dangerous. Take the classic 'class contains an allocated pointer' and not overriding the '=' operator. The class being copied to needs new memory allocating, and the contents copied to it. This is good. This is logical. Using [] to add a member to the end of an array is just stupid.

                                  K 2 Replies Last reply
                                  0
                                  • I Ian Bell 2

                                    -1 for blaming an excellent tool when the real problem lies with (s)he who uses it...

                                    History is the joke the living play on the dead.

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

                                    Actually this is in the STL library, the map object, pretty much a part of C++. So yeah, it sucks.

                                    I 1 Reply Last reply
                                    0
                                    • M Munchies_Matt

                                      Actually this is in the STL library, the map object, pretty much a part of C++. So yeah, it sucks.

                                      I Offline
                                      I Offline
                                      Ian Bell 2
                                      wrote on last edited by
                                      #30

                                      I've used STL extensively for decades and std::map is not the problem as mentioned in your OP. As you pointed out, the overridden function was incorrectly implemented so again, the fault lies with the developer and not the language. Technically speaking, STL is a library implemented in C++. So your OP would better have been title "Why I hate STL" (where you probably would have found a much more accepting audience). Cheers, Ian

                                      History is the joke the living play on the dead.

                                      M 1 Reply Last reply
                                      0
                                      • I Ian Bell 2

                                        I've used STL extensively for decades and std::map is not the problem as mentioned in your OP. As you pointed out, the overridden function was incorrectly implemented so again, the fault lies with the developer and not the language. Technically speaking, STL is a library implemented in C++. So your OP would better have been title "Why I hate STL" (where you probably would have found a much more accepting audience). Cheers, Ian

                                        History is the joke the living play on the dead.

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

                                        Here you go: vc-19-changes/unordered_map at master · icestudent/vc-19-changes · GitHub[^]

                                        I 1 Reply Last reply
                                        0
                                        • M Munchies_Matt

                                          I have come across some right howlers in this code base. Anyway, C++, of all the languages I have used, from ADA, to Prolog, through VB and Java, allows this kind of sillyness. So it is for that that I condemn it. And personally I dont see that OO is a massive benefit over a procedural language except in specific instances. And in fact it is often worse. Particularly in control code, code that is not data centric, but process centric.

                                          D Offline
                                          D Offline
                                          den2k88
                                          wrote on last edited by
                                          #32

                                          I beg to differ, there are always pieces of information in a process which are data-centric, and applying OO correctly will break up processes in subprocess objects that are easier to isolate, replicate, store, observe and even parallelize. I do intermix procedural and OO because pure OOP more often than not introduces complexity trying to fit square pegs in round holes, but that's precisely why I like C++ and not the oter OOP languages: it's C, but with 100% OO support.

                                          GCS d-- s-/++ a- C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- ++>+++ y+++*      Weapons extension: ma- k++ F+2 X

                                          M 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