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. Really frustrated when moving from C# to C++

Really frustrated when moving from C# to C++

Scheduled Pinned Locked Moved The Lounge
csharpc++
88 Posts 42 Posters 33 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.
  • Steve EcholsS Steve Echols

    You're really gonna miss the String class. :)


    - S 50 cups of coffee and you know it's on! Code, follow, or get out of the way.

    P Offline
    P Offline
    peterchen
    wrote on last edited by
    #40

    What's so bad about CString? ducks

    FILETIME to time_t
    | FoldWithUs! | sighist | WhoIncludes - Analyzing C++ include file hierarchy

    R 1 Reply Last reply
    0
    • K Keith Barrow

      Interesting, I hadn't considered the problem it that way, and I think for your points are valid. That said, I've only really developed for PC and I've only really been a .net developer professionally, I enjoy tinkering with other languages and I miss c++, which I use to write my dissertation. I think the deepest separation is between those who like programming and computing for its own sake, and those who do it solely as their day job. I think a large proportion of the latter group fall into your PC-centric category as this is what pays and what is easiest to get work in. Got my 5 anyway!

      Sort of a cross between Lawrence of Arabia and Dilbert.[^]
      -Or-
      A Dead ringer for Kate Winslett[^]

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #41

      Just immagine you had a C64 from 1983. A small 8 bit CPU at less than one MHz and about 50k RAM which you can use. None of the brute force methods you are used to would get you anywhere. Multitasking / multithreading? From the hardware side that would have been no problem. All you need is a hardware timer and an interrupt. But then the interrupt routine, which would have to handle the scheduling of the threads and also the bookkeeping, would nibble away at your little memory. And the effectiveness of having a CPU, which with luck executes 100000 - 200000 instructions per second, do this is more than questionable. Just-in-time-compiler? Or any compiler at all? An IDE which goes beyond a simple text editor? How? CPU, memory and available mass storage (two flopy drives with about 160k disk space each, if you are lucky) are simply not enough. A framework? How many libraries do you think you can load into your memory? And, with only very slow floppies available, some kind of swapping mechanism is also out of the question. Good code? That means wrapping everything up in functions and/or objects. Now and back then, calling a function or method was the same procedure: Push parameters onto the stack, call the function (which then cleans up the stack by removing the parameters), the function then does its job, pushes the return value onto the stack, returns and finally leaves it to the calling code to remove the return value from the stack again. Very quickly the little CPU is working more on the stack than on the actual program. Obviously, good code back then was defined a little differently than today. Those were only a few examples where the brute force approach has become the normal way to go. The more limited your system gets, the less useful the 'normal' approaches become. And I have enough things which were considered obsolete come back.

      "I just exchanged opinions with my boss. I went in with mine and came out with his." - me, 2011 ---
      I am endeavoring, Madam, to construct a mnemonic memory circuit using stone knives and bearskins - Mr. Spock 1935 and me 2011

      S 1 Reply Last reply
      0
      • J jpg 0

        Mostly because of how pointers and references work, and also function definition seems very different. :((

        L Offline
        L Offline
        leonej_dt
        wrote on last edited by
        #42

        Once you formally understand data types, memory addresses and l-values, getting pointers should not be that difficult. A pointer is a data type whose admissible values are memory addresses, and whose operations are referencing (input: an l-value, output: the l-value's memory address) and dereferencing (input: a memory address, output: whatever data is in that memory address as an l-value, exception thrown if the original memory address is null). Once you formally understand pointers, getting references is very easy: A reference is a pseudo-data type that is implemented a hidden non-null pointer. When you declare a reference, it must be passed an l-value, which will be referenced. As we have already seen, the referencing operation yields a memory address, which will be used to initialize the hidden pointer (hence, the pointer will be non-null). When you use an already declared reference, the hidden pointer is automatically dereferenced, so you do not have to do it explicitly. As a result, no pointer stuff is explicitly coded. So the message is: If you want to understand pointers in C++, learn what an l-value is. --- Myself, I migrated the other way (C++ to C# 2.0), and had a hard time understanding delegates, because some idiot said that delegates were, deep inside, nothing but function pointers, and I even more stupidly believed him. (Or her. I still do not know the gender of whoever wrote that article.) But that is not true: a delegate contains two pointers: a (member) function pointer, and a this pointer, which may be null (if you pass a static method).

        Eduardo León

        1 Reply Last reply
        0
        • P peterchen

          And you haven't even scratched the surface... The frustration will last for another five years aftetr which, if you make it through, you might get addicted.

          FILETIME to time_t
          | FoldWithUs! | sighist | WhoIncludes - Analyzing C++ include file hierarchy

          L Offline
          L Offline
          leonej_dt
          wrote on last edited by
          #43

          Personally, I didn't find it frustrating. I got addicted almost instantaneously.

          Eduardo León

          1 Reply Last reply
          0
          • J jpg 0

            Mostly because of how pointers and references work, and also function definition seems very different. :((

            F Offline
            F Offline
            Firo Atrum Ventus
            wrote on last edited by
            #44

            It always took a lot of hard work to move from C to A

            A hidden needle is way more effective than an unsheathed sword. That is, in the hand of professionals. What about you? Just pray your enemies are blind

            1 Reply Last reply
            0
            • B bob16972

              I feel the same way about C++ to C#. I've found you still need to check for null just as often and C#, without the .NET library (libraries are really a different topic...IMHO), is hardly the C++ 2.0 most C/C++ programmers had been longing for. I would like a reinvented C/C++ without all the historical baggage but I'd like to keep pointers and references the way they are. I had high hopes for C# but I think they missed a great opportunity to "fix" what was wrong with C/C++ and instead ended up trying to "fix" what was wrong with Java.

              S Offline
              S Offline
              S Senthil Kumar
              wrote on last edited by
              #45

              bob16972 wrote:

              instead ended up trying to "fix" what was wrong with Java.

              That might have been true for C# 1.0, but C# now has closures, delegates, anonymous types, lazy evaluation (yield) which AFAIK, neither C++ nor Java have. Of course, you could write code yourself to get the same effect, but I hope that's not what we are talking here.

              Regards Senthil _____________________________ My Home Page |My Blog | My Articles | My Flickr | WinMacro

              B R 2 Replies Last reply
              0
              • S S Senthil Kumar

                bob16972 wrote:

                instead ended up trying to "fix" what was wrong with Java.

                That might have been true for C# 1.0, but C# now has closures, delegates, anonymous types, lazy evaluation (yield) which AFAIK, neither C++ nor Java have. Of course, you could write code yourself to get the same effect, but I hope that's not what we are talking here.

                Regards Senthil _____________________________ My Home Page |My Blog | My Articles | My Flickr | WinMacro

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

                Delegates can be useful in C#, but I'd have to say that I could only be glad if the other 3 never got fully implemented in any language. I'm sure there will be those who differ in opinion with my view and all I can say is, have fun coding/debugging/tracing and reading code that utilizes those features. You have my sympathies. :sigh:

                S 1 Reply Last reply
                0
                • B bob16972

                  Delegates can be useful in C#, but I'd have to say that I could only be glad if the other 3 never got fully implemented in any language. I'm sure there will be those who differ in opinion with my view and all I can say is, have fun coding/debugging/tracing and reading code that utilizes those features. You have my sympathies. :sigh:

                  S Offline
                  S Offline
                  S Senthil Kumar
                  wrote on last edited by
                  #47

                  Well, I personally love any language feature that helps express my intent concisely, and I must say I use closures and lazy evaluation a lot. Besides, it's not like these features were invented by the C# language designers - they've been around for a long time in functional programming languages. I'm curious though - do you dislike these features because they increase the level of abstraction from the machine?

                  Regards Senthil _____________________________ My Home Page |My Blog | My Articles | My Flickr | WinMacro

                  B 1 Reply Last reply
                  0
                  • P peterchen

                    What's so bad about CString? ducks

                    FILETIME to time_t
                    | FoldWithUs! | sighist | WhoIncludes - Analyzing C++ include file hierarchy

                    R Offline
                    R Offline
                    Rage
                    wrote on last edited by
                    #48

                    :laugh:

                    1 Reply Last reply
                    0
                    • L Lost User

                      I've just moved to Python - you can't even tell a thread to terminate or pass variables by reference!

                      Join the cool kids - Come fold with us[^] "Program as if the technical support department is full of serial killers and they know your home address" - Ray Cassick Jr., RIP

                      R Offline
                      R Offline
                      Rage
                      wrote on last edited by
                      #49

                      Be careful.[^]

                      L 1 Reply Last reply
                      0
                      • J jpg 0

                        Mostly because of how pointers and references work, and also function definition seems very different. :((

                        A Offline
                        A Offline
                        Amarnath S
                        wrote on last edited by
                        #50

                        I've found three courses very useful: these are the Programming Methodology (Java), Programming Abstractions (C++) and Programming Paradigms (Advanced C++) available for free at the "Stanford Engineering Everywhere" site: http://see.stanford.edu/see/courses.aspx[^] You'll be surprised to note that they teach pointers in the Java course. This is what makes you a real programmer. After that, learning about C++ going through the second and third courses is easier. In fact, if you search for "CS106B", you'll reach the course site, where you'll find a C++ Course Reader, which is very well written. Keep in mind that all of this is for free.

                        1 Reply Last reply
                        0
                        • R Rage

                          Be careful.[^]

                          L Offline
                          L Offline
                          Lost User
                          wrote on last edited by
                          #51

                          :laugh:

                          Join the cool kids - Come fold with us[^] "Program as if the technical support department is full of serial killers and they know your home address" - Ray Cassick Jr., RIP

                          1 Reply Last reply
                          0
                          • J jpg 0

                            Mostly because of how pointers and references work, and also function definition seems very different. :((

                            L Offline
                            L Offline
                            Lost User
                            wrote on last edited by
                            #52

                            Bite on it big boy, you are in a mans world now! :cool:

                            Dr D Evans "The whole idea that carbon dioxide is the main cause of the recent global warming is based on a guess that was proved false by empirical evidence during the 1990s" financialpost

                            1 Reply Last reply
                            0
                            • J jpg 0

                              Mostly because of how pointers and references work, and also function definition seems very different. :((

                              G Offline
                              G Offline
                              Gary R Wheeler
                              wrote on last edited by
                              #53

                              Hmm. I went the opposite direction. I spent years programming in C++, and only a couple of years ago started working in C# as well. Like a lot of other C++ -> C# folks, I'm mainly frustrated by the lack of a deterministic destructor (and don't bring up IDisposable; just don't). I believe you have the harder way to go. I simply had to learn a certain amount of ".NET-fu". I also had to learn to recognize when I was working too hard at the problem at hand. A lot of times I tried to re-invent the wheel, when .NET had a perfectly good set of wheels already available. While the C++ does include a substantial body of 'plumbing' code available in the form of standard and open source libraries, most of it is less systematized and organized than the .NET libraries. This makes it much more likely that you will be tempted to write your own 'plumbing' code. Best quote I've heard regarding C++ came from Bjarne Stroustrup, creator of the language: "C makes it easy to shoot yourself in the foot. With C++, you blow your entire leg off." My addendum, regarding C#: "With C#, the good news is you're shooting rubber bullets."

                              Software Zen: delete this;

                              N 1 Reply Last reply
                              0
                              • L Lost User

                                And even worse, pointers do exist in C# and work very much the same way.

                                "I just exchanged opinions with my boss. I went in with mine and came out with his." - me, 2011 ---
                                I am endeavoring, Madam, to construct a mnemonic memory circuit using stone knives and bearskins - Mr. Spock 1935 and me 2011

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

                                Yes and for some unknown reason they are considered unsafe. So coding with .Net is like coding with a condom, it's safe. :laugh: :laugh:

                                Ego non sum semper iustus tamen Ego sum nunquam nefas!

                                1 Reply Last reply
                                0
                                • S S Senthil Kumar

                                  Well, I personally love any language feature that helps express my intent concisely, and I must say I use closures and lazy evaluation a lot. Besides, it's not like these features were invented by the C# language designers - they've been around for a long time in functional programming languages. I'm curious though - do you dislike these features because they increase the level of abstraction from the machine?

                                  Regards Senthil _____________________________ My Home Page |My Blog | My Articles | My Flickr | WinMacro

                                  B Offline
                                  B Offline
                                  bob16972
                                  wrote on last edited by
                                  #55

                                  IMO, these are all unnecessary hacks that encourage a programmer to justify the immediate use of brute force attacks to expedite their handling of mundane problems.

                                  1 Reply Last reply
                                  0
                                  • B bob16972

                                    I feel the same way about C++ to C#. I've found you still need to check for null just as often and C#, without the .NET library (libraries are really a different topic...IMHO), is hardly the C++ 2.0 most C/C++ programmers had been longing for. I would like a reinvented C/C++ without all the historical baggage but I'd like to keep pointers and references the way they are. I had high hopes for C# but I think they missed a great opportunity to "fix" what was wrong with C/C++ and instead ended up trying to "fix" what was wrong with Java.

                                    S Offline
                                    S Offline
                                    sucram
                                    wrote on last edited by
                                    #56

                                    The only thing wrong with C++ are some of the developers using it. :doh:

                                    Ego non sum semper iustus tamen Ego sum nunquam nefas!

                                    B 1 Reply Last reply
                                    0
                                    • S sucram

                                      The only thing wrong with C++ are some of the developers using it. :doh:

                                      Ego non sum semper iustus tamen Ego sum nunquam nefas!

                                      B Offline
                                      B Offline
                                      bob16972
                                      wrote on last edited by
                                      #57

                                      Nah, its ok now that those who couldn't figure it out moved on to something simpler like C#. ;P

                                      1 Reply Last reply
                                      0
                                      • S S Senthil Kumar

                                        bob16972 wrote:

                                        instead ended up trying to "fix" what was wrong with Java.

                                        That might have been true for C# 1.0, but C# now has closures, delegates, anonymous types, lazy evaluation (yield) which AFAIK, neither C++ nor Java have. Of course, you could write code yourself to get the same effect, but I hope that's not what we are talking here.

                                        Regards Senthil _____________________________ My Home Page |My Blog | My Articles | My Flickr | WinMacro

                                        R Offline
                                        R Offline
                                        rockonedge
                                        wrote on last edited by
                                        #58

                                        Actually C++ has closures, delegates, anonymous types, lazy evaluation and (yield). - delegates, lazy evaluation exist before C# has it through template in boost.signal, boost.phoenix among others. - closures, anonymous types are on C++0x and already shipped with VC++ 2010 an gcc 4.5+ - yield? here you are

                                        S 1 Reply Last reply
                                        0
                                        • L Lost User

                                          Just immagine you had a C64 from 1983. A small 8 bit CPU at less than one MHz and about 50k RAM which you can use. None of the brute force methods you are used to would get you anywhere. Multitasking / multithreading? From the hardware side that would have been no problem. All you need is a hardware timer and an interrupt. But then the interrupt routine, which would have to handle the scheduling of the threads and also the bookkeeping, would nibble away at your little memory. And the effectiveness of having a CPU, which with luck executes 100000 - 200000 instructions per second, do this is more than questionable. Just-in-time-compiler? Or any compiler at all? An IDE which goes beyond a simple text editor? How? CPU, memory and available mass storage (two flopy drives with about 160k disk space each, if you are lucky) are simply not enough. A framework? How many libraries do you think you can load into your memory? And, with only very slow floppies available, some kind of swapping mechanism is also out of the question. Good code? That means wrapping everything up in functions and/or objects. Now and back then, calling a function or method was the same procedure: Push parameters onto the stack, call the function (which then cleans up the stack by removing the parameters), the function then does its job, pushes the return value onto the stack, returns and finally leaves it to the calling code to remove the return value from the stack again. Very quickly the little CPU is working more on the stack than on the actual program. Obviously, good code back then was defined a little differently than today. Those were only a few examples where the brute force approach has become the normal way to go. The more limited your system gets, the less useful the 'normal' approaches become. And I have enough things which were considered obsolete come back.

                                          "I just exchanged opinions with my boss. I went in with mine and came out with his." - me, 2011 ---
                                          I am endeavoring, Madam, to construct a mnemonic memory circuit using stone knives and bearskins - Mr. Spock 1935 and me 2011

                                          S Offline
                                          S Offline
                                          Stefan_Lang
                                          wrote on last edited by
                                          #59

                                          I actually had a compiler back then. It supported some 13 control statements, and variable names could have one relevant character (i. e. only up to 26 different variables allowed), where each variable could be an int, a string, or an (one-dimensional) array of either. I've used it to program my own version of Tetris, although I had to write down much of the programs on paper to be able to build and flatten the three-dimensional arrays I required. I don't recall an actual 'editor', instead I typed each line individually, and had to issue a command for listing the program code if I wanted to see it. (hence my need to write most of it on paper first) PS.: I should add this was on the C=Plus/4 , not the earlier 64. There were quite a few Basic compilers for the latter, but unfortunately not for the former. On a sidenote, here I found a list of languages available for the C64 family. The compiler I used isn't even on there, but as you can see there was in fact a pretty excessive selection of languages available, at least for the C64.

                                          modified on Tuesday, May 31, 2011 8:53 AM

                                          L 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