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 32 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.
  • 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
        • Mike HankeyM Mike Hankey

          Like learning to drive with a stick. If you can drive a stick you can drive anything!

          Semper Fi http://www.hq4thmarinescomm.com[^]
          www.jaxcoder.com[^] WinHeist

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

          Mike Hankey wrote:

          drive a stick

          Hm, are you referring to a broom here? ;)

          Mike HankeyM 1 Reply Last reply
          0
          • C CPallini

            Real programmers don't use CStrings. In fact real programmers don't use strings at all. :-\

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
            [My articles]

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

            Not even g-strings? ;P

            1 Reply Last reply
            0
            • S Stefan_Lang

              Mike Hankey wrote:

              drive a stick

              Hm, are you referring to a broom here? ;)

              Mike HankeyM Offline
              Mike HankeyM Offline
              Mike Hankey
              wrote on last edited by
              #62

              Why of course but it has to be a straw broom.

              Semper Fi http://www.hq4thmarinescomm.com[^]
              www.jaxcoder.com[^] WinHeist

              1 Reply Last reply
              0
              • J jpg 0

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

                R Offline
                R Offline
                R Erasmus
                wrote on last edited by
                #63

                Really not that bad. declared variable e.g. int i = 0; somewhere in memory there is a integer variable named i whose value equals 0. int* i = 0; i points to memory address 0. in order to get/set the value at memory address 0 dereference(*) i. *i = 1234; int j = *i; printf("%d\n", j) prints 1234 Also: int j = 1234; int* i = &j; // address of symbol In english, i is now equal to the address of j. Or i points to j. i++; // This increments the pointer's address to the next integer pointer. Seing that i is a integer the next integer will be 4 bytes from i's initial value. If i was a char it would of incremented the address by 1. j++; // Would just increment the value of j by 1. Hope it helps... that is the basics

                "Program testing can be used to show the presence of bugs, but never to show their absence." << please vote!! >>

                1 Reply Last reply
                0
                • S Stefan_Lang

                  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 Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #64

                  Yes, sure there were some compilers back then. But they kept things much simpler than what we are used to today. I have tried some C compilers for 8 bit machines. With them you use the PC to do your development, test the program in emulators and transfer it to the real thing once you are done. The smallest machine just had 4k RAM and at this point a C compiler becomes almost useless, even if you do your development comfortably on a PC. The compiler (or better: the compiled program) uses up the available memory very fast. If I write my programs in assembly, the result will be much more compact.

                  "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

                  N 1 Reply Last reply
                  0
                  • J jpg 0

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

                    M Offline
                    M Offline
                    MacRaider4
                    wrote on last edited by
                    #65

                    As one in a similar boat, going from VB to C# to C++. I can appreciate the frustration as I'm still working it out (only been working with C++ about 2 months now). However I enjoy the challenge that it poses and the control you have is great (once you figure it out). The biggest challenge I've had, is once you think you have something figured out and you go to do something similar and nope, didn't quite have that grasp on it and back to re-reading something. Buck up little sailor it's not that bad, we'll get through it... and if not you can always go back to C#, nothing wrong with that.

                    1 Reply Last reply
                    0
                    • J jpg 0

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

                      S Offline
                      S Offline
                      Sascha Atrops
                      wrote on last edited by
                      #66

                      > Mostly because of how pointers and references work, and also function definition seems very different. I am a C++ and C# Developer now. And I was a java developer before. For me it's really frustrating to work with C#, because I do not have the choice between pointers and references or embedded objects. I only have pointers. Or structs which cannot have a constructor. That's miserable! I do not have any const correctness. I do not have multiple inheritance. C# or Java is a jail for me. I am not allowed to think about a software which contains a little thought which is behind heresy for the language designers. I read a statement of a c#-designer why const-correctness is useless: It's not safe, because you can fool it with const_cast. That is absolutely true. But why do you lock the door to your house? Because smashing the door a very conscious decision. Everybody can see that something wrong is going on here. You can distinguish between open and broken doors. You can search for them, just enter CTRL-F and type "const_cast" and you are going to find the bad guys. The C# design is to give up the lock so that everybody can enter the house - even by mistake. Imagine you had one drink to much last night and you enter the wrong house. It's no problem, the door is open. You decide to move all objects. In the morning you notice it's not your place and the owner doesn't like the changes. Now you have a problem. Imagine leave the house and do not remember anymore. A few weeks later your neighbor comes back in his house, everything has changed so he decides to run amok. Congratulations - you're his first victim. With const-correctness you had to smash the door first. Even if you drunk like hell, if the key doesn't match you have to do an additional decision. You have to think about it. With C# you just enter without any traces you can CTRL-F for. Is that the progress of a modern programming language? To the gui with the string class problem: With C++ I have my a string class which more powerful than std::string or the string class of c# or java. I am definitely not missing string classes of other languages. I am missing a good string class in C# or Java. I am working with C++ every day. Of course I have a toolbox for my every day work. If don't have and you're unable to continue if you do not find a tool in your .NET framework, get a another job. Back to the frustrated: Open your mind to new possibilities to formulate your algorithms. Use the differences between pointers and references to write more relia

                      1 Reply Last reply
                      0
                      • G Gary R Wheeler

                        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 Offline
                        N Offline
                        Nemanja Trifunovic
                        wrote on last edited by
                        #67

                        Gary R. Wheeler wrote:

                        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).

                        +5. Nothing beats C++ destructors, especially not the complicated and error prone Dispose pattern[^]. I really miss C++ :((

                        utf8-cpp

                        1 Reply Last reply
                        0
                        • J jpg 0

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

                          U Offline
                          U Offline
                          User 4223959
                          wrote on last edited by
                          #68

                          You probably need to step back a little and write a small program in assembler. C++ is a syntax layer on top of C, which is a macro-assembler of a sorts. That's what makes them different from C#, Java, Python, Lisp... So write a small assembler program ( print an argument + 1) - and then write the same in C or C++. Now run your C program in debugger, step into your code in disassembler and see how the disassembler code compares to your assembler code. Then, I promise, things will click into their places, and you will understand everything :)

                          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
                            grgran
                            wrote on last edited by
                            #69

                            It's easy, whenever you get a compiler error just add a "const" keyword near by and keep adding them till the error goes aways. ;-)

                            1 Reply Last reply
                            0
                            • M Mladen Jankovic

                              .jpg wrote:

                              Mostly because of how pointers and references work

                              It's a one thing that distinguish boys and real men.

                              [Genetic Algorithm Library]

                              M Offline
                              M Offline
                              Member 96
                              wrote on last edited by
                              #70

                              NO it's one thing that distinguishes dinosaurs and modern humans. I coded a crapload of c++ and I wouldn't go back unless forced at gun point.


                              There is no failure only feedback

                              A 1 Reply Last reply
                              0
                              • J jpg 0

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

                                P Offline
                                P Offline
                                patbob
                                wrote on last edited by
                                #71

                                There's also new, override and virtual functions :) Kpping track of whether a parameter is passed by value or reference because the compile won't help you there. And then there's C# generics vs. C++ templates.. not even close (hint: new, override & virtual). Oh, and let's not forget Dispose() -- blowing the brains out of an instance (that others could still be using) without destructing it. .Net library is worth it, but you could use the C++ implementation of .Net instead.

                                patbob

                                1 Reply Last reply
                                0
                                • J jpg 0

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

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

                                  When you don't know any programming languages, learning your first one is a moderate chore. You have to learn some basic concepts like functions, operator precedence, and of course what the keywords mean (what language #1 uses to spell "for", "procedure", etc). When you know 9 programming languages, learning your tenth is not so hard. You still have to learn how the keywords are put together, and you also have to learn any new concepts implemented in that language. If you're completely switching paradigms (like going from C to haskell) it's a bigger chore. But, when you know exactly one programming language, that second language is pretty tough. It's tough because you already know how to spell "if" and "for". You already know how to define a function, with the certainty you can only have when you only know one way. Learning a second language is hard, because it breaks all your internal rules. Those rules may be wrong, and may be limiting, but the cognitive dissonance caused by breaking them is no less real for that. C++ and C# are both good, useful languages. Both have warts, but neither one is badly broken. They're just for different things. What is broken is just your expectation that you do the exact same things in C++ as you do in C#. And the closer the syntax of the two languages are, the harder it is to get over the notion that they are the same.

                                  1 Reply Last reply
                                  0
                                  • M Member 96

                                    NO it's one thing that distinguishes dinosaurs and modern humans. I coded a crapload of c++ and I wouldn't go back unless forced at gun point.


                                    There is no failure only feedback

                                    A Offline
                                    A Offline
                                    AdamNThompson
                                    wrote on last edited by
                                    #73

                                    Amen to that. I love coding. Both for my paycheck and in my spare time. I have experimented with lots of languages, frameworks and patterns all for the sake of understanding. One thing I have found to be true is that C# is powerful and time efficient, and flexible. C# and .Net are my go to language/platform of choice. Can I accomplish the same thing in C++? Sure I can, It would just take twice as long and give me a head ache. It's one thing to take the time to understand how a language/platform works behind the scenes to grow as a developer, it's whole other thing to take twice as long to code the same application so that you can go around calling yourself a "real man".

                                    -Adam N. Thompson adam-thompson.com

                                    N A 2 Replies Last reply
                                    0
                                    • A AdamNThompson

                                      Amen to that. I love coding. Both for my paycheck and in my spare time. I have experimented with lots of languages, frameworks and patterns all for the sake of understanding. One thing I have found to be true is that C# is powerful and time efficient, and flexible. C# and .Net are my go to language/platform of choice. Can I accomplish the same thing in C++? Sure I can, It would just take twice as long and give me a head ache. It's one thing to take the time to understand how a language/platform works behind the scenes to grow as a developer, it's whole other thing to take twice as long to code the same application so that you can go around calling yourself a "real man".

                                      -Adam N. Thompson adam-thompson.com

                                      N Offline
                                      N Offline
                                      Nji Klaus
                                      wrote on last edited by
                                      #74

                                      Could not have said it any beter.

                                      1 Reply Last reply
                                      0
                                      • R rockonedge

                                        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 Offline
                                        S Offline
                                        S Senthil Kumar
                                        wrote on last edited by
                                        #75

                                        The features provided by boost don't count as language features, IMO. But yeah, I didn't know about the 0x features. Nice that C++ is evolving with the times. I didn't understand the bad nothing of these features though.

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

                                        1 Reply Last reply
                                        0
                                        • A AdamNThompson

                                          Amen to that. I love coding. Both for my paycheck and in my spare time. I have experimented with lots of languages, frameworks and patterns all for the sake of understanding. One thing I have found to be true is that C# is powerful and time efficient, and flexible. C# and .Net are my go to language/platform of choice. Can I accomplish the same thing in C++? Sure I can, It would just take twice as long and give me a head ache. It's one thing to take the time to understand how a language/platform works behind the scenes to grow as a developer, it's whole other thing to take twice as long to code the same application so that you can go around calling yourself a "real man".

                                          -Adam N. Thompson adam-thompson.com

                                          A Offline
                                          A Offline
                                          Atique Rahman
                                          wrote on last edited by
                                          #76

                                          Learning order depends. If someone learns C/C++ first and then he learns C# he will enjoy C# because he knows that things are just easier in C#. It's not like that his knowledge in C/C++ isn't only useful in learning new OOP languages but also to understand how really things work in deeper extent. The `real man` is one who doesn't care about the language/platform but solves the problem in best way using best tools available. Why bother spending years to develop the GUI using C++ if same can be done with C# in months? Why bother using C# when more control over system is necessary i.e., developing device drivers or creating a heavy game with lots of graphics operation requiring direct system API calls. In that case you should C/C++.

                                          A 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