C++ and C# programmers

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • NastyD
    Gold Gabber
    • Jun 2004
    • 614

    C++ and C# programmers

    I'm a C++ programmer with many years experience behind me, and I've dabbled a little in C#. Thing is I'm going for a job where they want to see some C# knowledge, although they're not too bothered about commercial experience.

    Has anyone got any good bullet points to answer the question "What are the main differences between C++ and C#?". I know a few (of course), but I want to impress the panel.

    Cheers
    An ounce of image is worth a pound of performance.
  • ichrang
    Getting warmed up
    • Jun 2004
    • 75

    #2
    I work with c# now and have had c++ in the past. Main thing is that C# is better for building GUI's and other graphical tools....if youve ever done any visual basic, its some what like that. What it has over Visual Basic is that its object oriented and multi-threaded (u can run two processes at the same time). You dont have to worry about memory allocation, which has always been a pain in the a$$ with C++. you dont have to worry about pointers. Strings and text manipulation is alot easier with C# because you have better string manipulation components built in. If youve ever had java experience which I personally dont, but everyone tells me that C# is microsoft version of java and that they parallel heavily.
    Syntax is pretty much identical between the two... if you are competent with C++, you will have no problem picking up C# especially if youve ever done any VB programming.
    Thats what pops to my mind immediately when i think of the question.....theres tons more tho.
    music at: www.djrichang.com
    add me: www.myspace.com/djrichang

    Comment

    • groffhibbitz
      Gold Gabber
      • Jun 2004
      • 632

      #3
      why don't you have to worry about pointers? what do you mean by that?

      Comment

      • ichrang
        Getting warmed up
        • Jun 2004
        • 75

        #4
        Originally posted by groffhibbitz
        why don't you have to worry about pointers? what do you mean by that?
        When you pass arrays into functions in C++. you have to declare a pointer to that array...ie

        float * examplepointer;
        examplepointer = &array[0];
        x = functionCall(examplearray);

        in C# you just pass the array name directly into funciton call...

        float array[N];
        x = functionCall(array);


        this thread definitely belongs on a different forum
        music at: www.djrichang.com
        add me: www.myspace.com/djrichang

        Comment

        • MJ
          Here since 2002
          • Jun 2004
          • 6560

          #5
          I have my 25m swimming certificate.
          mjwebhosting you know it makes sense



          Silentium est aureum

          Comment

          • groffhibbitz
            Gold Gabber
            • Jun 2004
            • 632

            #6
            Originally posted by ichrang
            Originally posted by groffhibbitz
            why don't you have to worry about pointers? what do you mean by that?
            When you pass arrays into functions in C++. you have to declare a pointer to that array...ie

            float * examplepointer;
            examplepointer = &array[0];
            x = functionCall(examplearray);

            in C# you just pass the array name directly into funciton call...

            float array[N];
            x = functionCall(array);


            this thread definitely belongs on a different forum
            that is easier! I like it.

            Have you ever used python? You don't have to worry about anything there. You don't even have to declare types!

            python:

            array[n]
            x = functionCall(array)

            Comment

            • brakada
              Gold Gabber
              • Jun 2004
              • 622

              #7
              Originally posted by Musical Journey
              I have my 25m swimming certificate.
              So, what does that mean? You can swim as far as 25m ?
              We shall boldly dance, where no man has danced before..."

              Comment

              • MJ
                Here since 2002
                • Jun 2004
                • 6560

                #8
                Originally posted by brakada
                Originally posted by Musical Journey
                I have my 25m swimming certificate.
                So, what does that mean? You can swim as far as 25m ?
                Yeh, 25 miles is some distance i think you`ll agree.
                mjwebhosting you know it makes sense



                Silentium est aureum

                Comment

                • thepariah
                  Getting Somewhere
                  • Jun 2004
                  • 101

                  #9
                  Originally posted by ichrang
                  I work with c# now and have had c++ in the past. Main thing is that C# is better for building GUI's and other graphical tools....if youve ever done any visual basic, its some what like that. What it has over Visual Basic is that its object oriented and multi-threaded (u can run two processes at the same time). You dont have to worry about memory allocation, which has always been a pain in the a$$ with C++. you dont have to worry about pointers. Strings and text manipulation is alot easier with C# because you have better string manipulation components built in. If youve ever had java experience which I personally dont, but everyone tells me that C# is microsoft version of java and that they parallel heavily.
                  Syntax is pretty much identical between the two... if you are competent with C++, you will have no problem picking up C# especially if youve ever done any VB programming.
                  Thats what pops to my mind immediately when i think of the question.....theres tons more tho.
                  Ok that's is mostly a bunch of crap. C# and the new VB.NET are similar, but so is managed C++ if you look at it that way. They all use the same CLR but are not syntactically the same.

                  The main differences between C# and C++ is
                  • Garabge collection, no explicate call to delete objects
                    C# is a true object oriented language (like java) not some dress up make beleive object orientation built over C
                    C# is strongly typed.
                    C# isn't compiled to machine code, it's compiled to IL (Intermediate Language)


                  for a more in depth review of the two there are a ton of websites with C# tips for C++ programmers

                  for instance: http://www.andymcm.com/csharpfaq.htm

                  Comment

                  • superEGO72
                    Getting Somewhere
                    • Jun 2004
                    • 212

                    #10
                    Originally posted by ichrang
                    When you pass arrays into functions in C++. you have to declare a pointer to that array...ie

                    float * examplepointer;
                    examplepointer = &array[0];
                    x = functionCall(examplearray);
                    thats not really true.

                    you can declare a function to accept an array as an argument.

                    void bob(int[] fucko, int n)
                    {
                    //whatever
                    }

                    void main()
                    {
                    int blah[20];

                    bob(blah, 20);
                    }


                    now, the dynamics in how the compiler handles that situation are different... but it can be done

                    Comment

                    • day_for_night
                      Are you Kidding me??
                      • Jun 2004
                      • 4127

                      #11
                      *watches l33tn3ss of thread go right over his head*

                      Comment

                      • Paul Louth
                        Getting Somewhere
                        • Jun 2004
                        • 162

                        #12
                        Re:: C++ and C# programmers

                        The main differences between C# and C++ is
                        Garabge collection, no explicate call to delete objects
                        C# is a true object oriented language (like java) not some dress up make beleive object orientation built over C
                        C# is strongly typed.
                        C# isn't compiled to machine code, it's compiled to IL (Intermediate Language)
                        I case you don't know why these help:

                        Garabge collection, no explicate call to delete objects
                        Stops memory leaks and dangling pointers (big issues in C++), basically when all references to an object are removed (ie they all become null) then the object is fair game for the garbage collector. The garbage collector will occasionly step through the heap looking for objects without references and will free them automatically. Because of this you can't guarantee that an object will destruct when all references to it become null, so your finalizers need to be able to handle loss of refering objects or objects it refers to. The GC is a whole topic in its own right, so its worth looking into this before any serious C# coding (they will almost certainly ask about it in any interview).

                        C# is a true object oriented language (like java) not some dress up make beleive object orientation built over C
                        C# is strongly typed.

                        No globals. Default access to most things are private. Its impossible to cast to void and treat the object as untyped. Everything derives from the base object class, including fundamental value types like ints, floats etc.

                        C# isn't compiled to machine code, it's compiled to IL (Intermediate Language)
                        IL is a byte coded language, basically C# is compiled down to simple instructions that the CLR (Common Language Runtime) can parse quickly and simply. This probably won't concern you for most jobs.

                        One more thing, the .NET Framework API mainly throws execptions to flag errors rather than returning error codes. So you tend to have to wrap a lot of functionality with try-catch-finally blocks.

                        Paul
                        soundcloud.com/paullouth
                        https://www.facebook.com/waterwalklondon
                        www.4four.org

                        Comment

                        • nightfly
                          Getting Somewhere
                          • Jun 2004
                          • 121

                          #13
                          Re:: C++ and C# programmers

                          C# is a true object oriented language (like java) not some dress up make beleive object orientation built over C
                          C++ is perfectly well object-orientated if you use it as such, it's just that nearly all "C++" programmers use it like "C with classes". This isn't necessarily a bad thing IMO, having to go completely OO can be very restrictive and feel somewhat pointless. I hate Java for it's excessive "objectness", I just get pissed off writing stupid code that could be done in a much cleaner way.

                          And managed C++ =

                          Comment

                          • Paul Louth
                            Getting Somewhere
                            • Jun 2004
                            • 162

                            #14
                            Re:: C++ and C# programmers

                            This isn't necessarily a bad thing IMO, having to go completely OO can be very restrictive and feel somewhat pointless.
                            Only if you do it wrong
                            soundcloud.com/paullouth
                            https://www.facebook.com/waterwalklondon
                            www.4four.org

                            Comment

                            • Chris Micali
                              Fresh Peossy
                              • Jun 2004
                              • 21

                              #15
                              Thepariah: nicely put

                              These are language differences.. there are also some fundamental differences of the C# development and runtime environment. C# is one of languages in the Microsoft .NET platform which includes, among other things, a CLR, or common language runtime. As was stated above, C# is compiled into bytecode (IL) which is interpreted at runtime by a virtual machine. This is very similar to java, and Microsoft's .NET runtime is about a 21M redistributable. When you build C# apps, they are supposedly portable because they run as bytecode in this VM, although Microsoft has only made this CLR for Win32 (there is a project called MONO which is trying to fix this. In practice you will find that C# has a lot more in common with Java than C++.

                              There are also a bunch of other language differences, as C# has things like deletgates (sort of like function pointers for events), class properties (member variables with get/set functions,) new class features (interfaces, sealed classes, etc,) and more.

                              You can check out
                              C# Language Homepage
                              C# 1.2 Language Specification

                              Comment

                              Working...