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.
  • G Gary Wheeler

    Oh, I'm more than old enough to know how it worked. I'm just appalled at the notion of doing it in FORTRAN. I've written my own self-modifying code a couple of times, although not in the last 25 years or so. I can see where .NET could let you write self-generating code, but that's a kettle of different piscus, as it were.

    Software Zen: delete this;

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

    I'm just glad I never had the opportunity to do it in COBOL

    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

    G K 2 Replies Last reply
    0
    • OriginalGriffO OriginalGriff

      I'm just glad I never had the opportunity to do it in COBOL

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

      G Offline
      G Offline
      Gary Wheeler
      wrote on last edited by
      #42

      X| I have two claims to fame in my career: I've never written an ECO(*) (Engineering Change Order), and I've never learned COBOL. (*) A document used within my company that describes how to build a product. It's incredibly complicated, and for software it's completely over-engineered.

      Software Zen: delete this;

      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.

        K Offline
        K Offline
        KBZX5000
        wrote on last edited by
        #43

        Wait.. what? Are you talking about std::array, std::list or std::map? Don't mix their terminology, please. I'm guessing you're dealing with a map. And I'm guessing the some_map[value] is initializing a KV-pair with value as key (hella confusing name, btw) and a default value (of type V). Typically, this is done before some algorithm which relies on a particular key existing / values to be initialised to keep its complexity low. Nothing wrong with that, except the very awful variable names. Something like this would make more sense:

        std::map some_map = new std::map()

        // init specific keys

        some_map[new KeyType("key 1")]; // adds key to some_map, in no guaranteed order, with a default ValueType

        KeyType key = new KeyType("key 2");
        some_map[key] = new ValueType(); // same as above, but more verbose

        // do some algorithm that relies on initialized keys / values

        M 1 Reply Last reply
        0
        • OriginalGriffO OriginalGriff

          I'm just glad I never had the opportunity to do it in COBOL

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

          Most oldtimers know the Ken Thompson Turing Award lecture "Reflections on trusting trust" (and the youngers really should be introduced to it!) For a few years after this paper was published (1984), various writers expanded on the idea. One of the articles in my basement archive discusses how this compiler trojan could be implemented in the backend, code generating part, of a compiler suite such as gcc. It would then apply to all the compilers using that backend - Cobol is mentioned as an example, even though the malicious code never existed in Cobol form. This article discusses how the trojan could avoid detection, e.g. by propagating only to executables of a certain minimum size so that the size of the trojan code would be a tiny little fraction. It also discusses how a parse tree could be recognized as a compiler being compiled, and how the trojan could added at the parse tree level before code generation, so that it would spread even to the early (language dependent) compiler stages, not just the back end. This would not exactly be self modifying code, but it illustrates that even Cobol certainly isn't safe for malware.

          1 Reply Last reply
          0
          • K KBZX5000

            Wait.. what? Are you talking about std::array, std::list or std::map? Don't mix their terminology, please. I'm guessing you're dealing with a map. And I'm guessing the some_map[value] is initializing a KV-pair with value as key (hella confusing name, btw) and a default value (of type V). Typically, this is done before some algorithm which relies on a particular key existing / values to be initialised to keep its complexity low. Nothing wrong with that, except the very awful variable names. Something like this would make more sense:

            std::map some_map = new std::map()

            // init specific keys

            some_map[new KeyType("key 1")]; // adds key to some_map, in no guaranteed order, with a default ValueType

            KeyType key = new KeyType("key 2");
            some_map[key] = new ValueType(); // same as above, but more verbose

            // do some algorithm that relies on initialized keys / values

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

            Seems to be something like that. Anyway, reading my_array[value]; and that is it, is damn confusiing!

            K 1 Reply Last reply
            0
            • D den2k88

              It's not C++, it's the programmers. I use C++ and don't do that s**t.

              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

              B Offline
              B Offline
              Bob1000
              wrote on last edited by
              #46

              You are pretty close to the perfect answer.... C++ is as sensible or as stupid and daft as you want it to be. Unfortunately not helped by the C++ ISO bods adding more and more different ways to make it more complicated without adding very much to real C++ users. The idea of less is more is lost on them. Could do with minimum C++ with a lot of the bad and new stuff removed. As for the Template library - great functionality but let down by the ludicrous syntax etc.

              C 1 Reply Last reply
              0
              • G Gary Wheeler

                Member 7989122 wrote:

                Mechanical Engineering Department and eager FORTRAN coder

                Found your problem.

                Software Zen: delete this;

                M Offline
                M Offline
                MKJCP
                wrote on last edited by
                #47

                But without those type of people we would never have put a man on the moon. Remember, it takes people with real jobs to get real things done.

                G 1 Reply Last reply
                0
                • M MKJCP

                  But without those type of people we would never have put a man on the moon. Remember, it takes people with real jobs to get real things done.

                  G Offline
                  G Offline
                  Gary Wheeler
                  wrote on last edited by
                  #48

                  Margaret Hamilton (scientist) - Wikipedia[^]

                  Software Zen: delete this;

                  M 1 Reply Last reply
                  0
                  • G Gary Wheeler

                    Margaret Hamilton (scientist) - Wikipedia[^]

                    Software Zen: delete this;

                    M Offline
                    M Offline
                    MKJCP
                    wrote on last edited by
                    #49

                    Interesting bit of history, thanks.

                    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.

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

                      Don't get frustated, create your own adpator so you can do something like: [static] map_adaptor::wrap(some_array_which_is_really_not_a_primitive_array).find_element_or_insert(value);

                      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.

                        A Offline
                        A Offline
                        Andy Hoffmeyer
                        wrote on last edited by
                        #51

                        Don't blame the language or its standard library for your inability to RTFM. From std::map::operator[] - cppreference.com: operator[] is non-const because it inserts the key if it doesn't exist.

                        M 1 Reply Last reply
                        0
                        • A Andy Hoffmeyer

                          Don't blame the language or its standard library for your inability to RTFM. From std::map::operator[] - cppreference.com: operator[] is non-const because it inserts the key if it doesn't exist.

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

                          No shit it inserts it, I just said that. RTFOT FFS.

                          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.

                            S Offline
                            S Offline
                            Steve Naidamast
                            wrote on last edited by
                            #53

                            Why I don't hate the C++ language I have found it to be overly arcane with its syntax...

                            Steve Naidamast Sr. Software Engineer Black Falcon Software, Inc. blackfalconsoftware@outlook.com

                            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.

                              S Offline
                              S Offline
                              SeattleC
                              wrote on last edited by
                              #54

                              If you had ever had the experience of building a large software project using non-OO code, you would sing a different tune.

                              M 1 Reply Last reply
                              0
                              • S SeattleC

                                If you had ever had the experience of building a large software project using non-OO code, you would sing a different tune.

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

                                You can build a large project from procedural code just as well, it all depends on the architecture you design. Look at the WIndows kernel. All built in C (with a bit of assembler in the HAL)

                                S 1 Reply Last reply
                                0
                                • B Bob1000

                                  You are pretty close to the perfect answer.... C++ is as sensible or as stupid and daft as you want it to be. Unfortunately not helped by the C++ ISO bods adding more and more different ways to make it more complicated without adding very much to real C++ users. The idea of less is more is lost on them. Could do with minimum C++ with a lot of the bad and new stuff removed. As for the Template library - great functionality but let down by the ludicrous syntax etc.

                                  C Offline
                                  C Offline
                                  Carlosian
                                  wrote on last edited by
                                  #56

                                  Yes, I still keep the AT&T C++ book on my desk. A slim volume describing a nice language which was an (IMO) elegant OO extension to 'C'. Now you can look at valid C++ syntax that looks like a cat walked across the keyboard. They seem to be trying to put every feature of every other language into C++ syntax and comprehensibility be damned.

                                  1 Reply Last reply
                                  0
                                  • M Munchies_Matt

                                    You can build a large project from procedural code just as well, it all depends on the architecture you design. Look at the WIndows kernel. All built in C (with a bit of assembler in the HAL)

                                    S Offline
                                    S Offline
                                    SeattleC
                                    wrote on last edited by
                                    #57

                                    And have you, personally, built a million-line code-base in purely procedural code? In C, perhaps? If you have done so, and have done the same using an object-oriented language, then you have standing to dismiss object oriented programming as no better than procedural. Merely asserting that it is possible is not a very strong claim. Pointing to 30-year-old code like the Windows Kernel, that was developed before the broad availability of OO languages is meaningless.

                                    M 1 Reply Last reply
                                    0
                                    • S SeattleC

                                      And have you, personally, built a million-line code-base in purely procedural code? In C, perhaps? If you have done so, and have done the same using an object-oriented language, then you have standing to dismiss object oriented programming as no better than procedural. Merely asserting that it is possible is not a very strong claim. Pointing to 30-year-old code like the Windows Kernel, that was developed before the broad availability of OO languages is meaningless.

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

                                      Ah, so because I havnt done it it isnt true. OK, gotcha! ;)

                                      SeattleC++ wrote:

                                      30-year-old code like the Windows Kernel,

                                      :laugh: :laugh: :laugh: NT is old, 2000 was modified to include PnP and power handling. Windows 10 is even more recent.

                                      1 Reply Last reply
                                      0
                                      • M Munchies_Matt

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

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

                                        Why reference the code and what is it you are requesting?

                                        History is the joke the living play on the dead.

                                        1 Reply Last reply
                                        0
                                        • M Munchies_Matt

                                          Seems to be something like that. Anyway, reading my_array[value]; and that is it, is damn confusiing!

                                          K Offline
                                          K Offline
                                          KBZX5000
                                          wrote on last edited by
                                          #60

                                          I agree 100%

                                          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