Like Tree1Likes
  • 1 Post By VirtualAce

C++/CLI and C#

This is a discussion on C++/CLI and C# within the C++ Programming forums, part of the General Programming Boards category; I'm learning Visual C++. And I have learned that there are two ways to programming in C++. First, use standard ...

  1. #1
    hqt
    hqt is offline
    Registered User
    Join Date
    Aug 2011
    Posts
    115

    Question C++/CLI and C#

    I'm learning Visual C++. And I have learned that there are two ways to programming in C++. First, use standard C++ and C++/CLI. For simple explain: standard C++: the way we programming before, on borland, on DevC++, or any other IDE. and C++/CLI: mean you progamming C++ with .NET platform after. (and often use Microsoft visual studio IDE).

    I know, standard C++ is strong, no doubt.
    But, when you choose C++/CLI, mean you want to use the power of .NET(and who use your software, must install .NET too @@). So, when It's happen, when you want to live with .NET, why don't you use C#: the other programming language that have many points different make you program more easy. For the most easiest example: in C# have garbage collection, and you don't care memory leak anymore.

    So, who can explain for me, please.
    thanks

  2. #2
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498
    I'd say staying with the standard would be better than weird hybrids....(but that may not be true for everyone)
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  3. #3
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    But, when you choose C++/CLI, mean you want to use the power of .NET
    No, no no, that's a common misconception. C++/CLI combines the weak points of C++ and .NET. It features all that makes .NET slow and cumbersome combined with the cryptic C++ syntax that's hard to use. There are very special cases where you need to put up with C++/CLI and then it's godsent, but if you don't need it (and if you don't know, you don't need it) don't use it.

    C++ is hard to master, but very powerful.
    C# is less powerful, but very easy to learn and therefore very productive.
    C++/CLI is hard to master AND less powerful.

    Please note that I'm a fan of it because I need it. But even as a fan of it... stay away. Go C++ or C#.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  4. #4
    'Allo, 'Allo, Allo
    Join Date
    Apr 2008
    Posts
    611
    Interop

    If you're using it for anything else, you're doing it wrong.

  5. #5
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    It really is for interop as has been said. That is what I have used it for and it works well in that context. I have created WinForms based tools both in C++/CLI and C# and there are very little differences between the two. Both leverage the power of .NET and both are about as fast to develop with. Instead of using object.SomeFunc you normally use object->SomeFunc and instead of doing using dot nomenclature for namespaces you use the scope resolution operator. Managed pointers use ^ in C++/CLI and you have finalizers.

    Personally I primarily use it for interop but in theory it is feasible to develop WinForms or WPF in pure C++/CLI rather than C#.

  6. #6
    hqt
    hqt is offline
    Registered User
    Join Date
    Aug 2011
    Posts
    115
    So, as many people say there, C++/CLR is useless, huh they hard no learn like C++, and less powerful, just like C#. But I don't think so, because if this is true, Microsoft won't develop this programming language.

  7. #7
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498
    Quote Originally Posted by hqt View Post
    But I don't think so, because if this is true, Microsoft won't develop this programming language.
    (Am I / Are you) in a different Universe where microsoft has a different history ?
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  8. #8
    hqt
    hqt is offline
    Registered User
    Join Date
    Aug 2011
    Posts
    115
    @manasij7479: I'm very sorry for my bad english, but I don't know your idea :"> Can you tell me more clearly, please
    But I still think, if Micsrosoft Visual C++.NET noone or rarely people use it, Microsoft won't develop it, huh. So, it must have some powerful points that C++ and .NET don't have ?
    Am I tell right ? please correct for me, please.

    thanks

  9. #9
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498
    >Can you tell me more clearly, please
    And risk a flamewar here... no thanks! .. anyway.. it wasn't your english, I meant M$'s somewhat irrational history.
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  10. #10
    Registered User
    Join Date
    Oct 2006
    Posts
    2,294
    C++/CLI is very useful for interfacing between native and managed code. one situation in which this could be useful is when talking to hardware.

    for anything more than interop code, there are generally better tools.

  11. #11
    hqt
    hqt is offline
    Registered User
    Join Date
    Aug 2011
    Posts
    115
    @Elkvis: you mean that C++/CLI useful for those application that use .NET platform + doing something with hardware, too ?
    But I think, those application is rarely appear. In my knowledge, .NET help to create software more easily, and when you want to talk with hardware, it's just a small part, and often use standard C++. ?

  12. #12
    Registered User
    Join Date
    Oct 2006
    Posts
    2,294
    Quote Originally Posted by hqt View Post
    But I think, those application is rarely appear.
    that is correct.

    Quote Originally Posted by hqt View Post
    .NET help to create software more easily, and when you want to talk with hardware, it's just a small part, and often use standard C++. ?
    but C++/CLI gives you the ability to drop down in to native code to handle the hardware interface, and still make it accessible to the managed application.

  13. #13
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    So, as many people say there, C++/CLR is useless, huh
    C++/CLI is not useless and I do not see that anywhere in this thread. C++/CLI is a godsend for interop code. I hated it when I first encountered it and my colleagues here will vouch for that as well. Over the years of using it I now understand its place and could see myself developing apps in it instead of pure C++. Not everyone is going to do that and for the most part it is simply for interop'ing managed and unmanaged code and that is the beauty of the language. Microsoft did a good job with C++/CLI and made it rather simple to mix managed and unmanaged code given you follow a few constraints. Just like every other language it is a tool and when you use it for the right job the tool shines.

    That being said I rather enjoy programming in C++. C++/CLI, and C#. They all bring different functionalities to the table and allow you different design approaches and all are fantastic tools for what they were designed for. With this triplet of tools you can pretty much accomplish anything you want to on the Windows platform.

    No tool is useless when used for what it was designed to do.
    nvoigt likes this.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21