Locked why C# is powerfull then C++?????

  • Wednesday, February 22, 2012 3:09 AM
     
     
    C# does not support multiple inheritance where as C++ is structured on multiple inheritance.... now what i want to ask is if C# is stuructured upon C++ (supports multiple inheritance) then how it is a more powerfull language then C++........... it is realy confusing to me.....

All Replies

  • Wednesday, February 22, 2012 3:16 AM
     
     Answered

    It depend what you mean by more powerfull.... if you mean to write less to do more then c# is certainly more powerfull.... Linq, LAMBDA are good example of that...

    Multiple inheritance is not (for most of the case) a good programming practice... it can make the code really confusing... you should consider using multiple interface implementation instead... 

  • Wednesday, February 22, 2012 4:52 AM
     
     Answered

    Well...to be frank...it depends on what kind of application you are working on. Both langauge are developed for different purpose. There is no comparision at all. However at broad level I can say if you need low level programming or say system level programming then one should consider C++. If some one is working on application development, one should consider C# to take benifit of rich .Net library. This is just high level statement. There are much more criteria that should be consider before take decision to go with C++ or C#.

    Bottom line is "I will not say one is better then other. It depends on requirement."


    Please click “Mark as Answer” if this post answers your question and click "Vote as Helpful" if this Post helps you.

  • Wednesday, February 22, 2012 5:50 AM
     
     
    C# is constructed through C++(which have multiple inheritance) then how C# is better then C++ if it is built by a metarial having a weakness(multiple inheritance) in itself
  • Wednesday, February 22, 2012 6:37 AM
     
     

    I am not in favor of any of the language.

    But just to Answer your question refer following links:

    http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/b1c2c3e6-aa17-49e4-a7a1-7d1f11120fba/

    http://blogs.msdn.com/b/ericgu/archive/2005/01/26/360879.aspx


    Please click “Mark as Answer” if this post answers your question and click "Vote as Helpful" if this Post helps you.

  • Wednesday, February 22, 2012 7:36 AM
     
     Answered

    Hi,

    stop thinking about "better" or "powerfull" when comparing languages. These words are objective and your understanding of these words can be completly different than my which is different to most other users ...

    So really stop to think that way!

    We can talk about differences and get some arguments about each difference.

    So in c++ you have multiple inheritance which C# does not have. But it was left out because the developer of c# thought that it is not required and only makes things more complex than they need to be.

    In c++ you can write unmanaged code - which can be a big advantage because your applications do not require an installed .Net Framework (Important point when distributing your applications!). But the managed envirnoment has a lot of advantages because it makes life much easier (e.g. memory management is handled by a GC and you have internal checks which prevent attacks like buffer overflows ... both is not really required to write good and stable programs but a developer can make errors more easily.)

    In c++ you can take full advantage of the operating system. The interaction with .Net is more limited even if a lot of parts are covered e.g. PInvoke, COM, .... But not all parts are covered.

    In C++ you have full control of your application - in C# a lot is done in the background. (Just check the number of threads when you run a simple console application!) So the architecture of .Net simply has the result that a real time application on a rtos is not really possible (or at least needs some more enhancements).

    Availability of C++ is also much higher - C++ you find on all platforms I think. You even get it to develop software for all common micro controller.

    As a c++ developer you can access .Net, too. So if you need all the nice libraries (ado.net, wcf, ...) you can also use them.

    So that was some differences.

    In general I would suggest to have a closer look at c# if you are a beginner. It simply makes a start much easier. And if you want to develop applications then it is a great language (we do all out development in C#. I switched to C# when Visual Studio 2002 came out.)

    With kind regards,

    Konrad

  • Wednesday, February 22, 2012 10:49 AM
     
     Answered
    C# is constructed through C++(which have multiple inheritance) then how C# is better then C++ if it is built by a metarial having a weakness(multiple inheritance) in itself

    That question makes no sense at all. You could ask the same meaningless question about C++:

    "C++ can be implemented in C, which has no inheritance at all. How could C++ be better than C, if it is built by a material having a weakness (no inheritance) in itself?

    Or to use a real-world analogy:

    "Sand is useless for building houses. Concrete is made out of sand. Therefore, how can concrete be any use for building houses?"

  • Wednesday, February 22, 2012 3:07 PM
     
     Answered

    C++ is more powerful than C#.  There are a great many things that can be done in C++ that can't be done in C#.  C# is intentionally limiting in what it provides so that what can be done is easier, more manageable, less confusing, etc.  The language is much easier to learn and harder to shoot yourself in the foot with.  Considering that the "power" of a language such as C++ isn't actually needed for a great many programming fields these simplifications are either acceptable or preferable for many people.

    Of all of the things to want from C++ I don't see why you set so much store by multilpe inheritance.  It's not particularly useful in general, and is generally a sign of poor design.  Most of the real power of a language like C++ is it's direct manipulation of memory.  You can allocate exactly how much you need, set it to be what you want, directly manipulate pointers, etc.  Some of this can be done in C# through unsafe blocks, but even that is limited in what it can do.  The vast majority of the time programmers are glad when they don't have to deal with this type of thing, but there are fairly notable exceptions.