3

I've always had a thing for C++/CLI. Maybe because not many developers use it... or just because it's different.

Suppose Microsoft fully supported C++/CLI as they do VB.NET and C# (ie. LINQ, WPF, etc.). Would you use it?

If not, why?

Inisheer
  • 20,376
  • 9
  • 50
  • 82

8 Answers8

14

I do use it. Even with the relative lack of tool support, it still beats raw P/Invoke for dealing with Win32.

As for LINQ, i don't really care to see too much more hacked into the C++ language. LINQ is usable enough as-is - if they're gonna enhance the compiler, they should work on C++ 0x support...

Shog9
  • 156,901
  • 35
  • 231
  • 235
5

It's all about using the right tool for the right job. I use C++/CLI for platform interop work because it's much easier to get the marshaling correct. I use C# for almost all other .NET work, with some VB.Net (I like the inline XML). I admit I haven't learned IronRuby, IronPython, F#, or any other .NET language yet, but I'm seriously considering it just to increase my programming arsenal.

To answer the question, I don't think I'd use it anymore than I already do because I feel I already use it for the jobs it fits best. C# is still the best .NET language as I see it because it was specifically designed for that platform, rather than shoehorning an older language to fit it. Adding better support for C++/CLI would only decrease my development time, rather than sway my usage from another language.

Jeff Yates
  • 61,417
  • 20
  • 137
  • 189
4

C++/CLI delivers very effectively on the promise of uniting Managed and Unmanaged code. It lets you expose what feels like a perfectly native C# library with 100% access to native C++/libraries "on the inside". It's not an exercise in elegance but in the history of practical programming tools what compares?

If you need LINQ and WPF, just use C#. That's the beauty of C++/CLI: write your Managed wrapper and then go back to C#. I don't see C++/CLI intending to replace C# for day to day use.

Jared Updike
  • 7,165
  • 8
  • 46
  • 72
4

...but I'm not entirely clear on what C++/CLI offers that C# does not. -- @Thomas Owens

One huge benefit (in my book) is RAII (see the answer given by Adam Wright to my question regarding RAII in .NET).

Community
  • 1
  • 1
Motti
  • 110,860
  • 49
  • 189
  • 262
1

Perhaps...but I'm not entirely clear on what C++/CLI offers that C# does not. Pointers, perhaps? I've done all of my .NET programming (the little I've done) in C#, and I'm starting to learn F#, but if it was fully supported and well documented, sure, I would give it a go.

Thomas Owens
  • 114,398
  • 98
  • 311
  • 431
  • Exactly. You wouldn't HAVE to do anything different than the typical C# coding, but you always have the native option available. – Inisheer Oct 07 '08 at 18:17
  • 1
    If you need to interact with non-managed code, IJW is *huge*. I'm still shocked that the error-prone, VB-style P/Invoke carried through into C# and VB.NET, but C++/CLI provides a way around it, allowing the use of the Platform SDK headers (or whatever other native API headers you might have). – Shog9 Oct 07 '08 at 18:26
1

I am mixing C++/CLI with MFC to take advantage of the WPF and XAML, but I am using the new C++ 2008 feature pack -- free ribbon components. :)

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
  • I've read a bit about the ribbon component. Is it fully featured similar to MS Office? – Inisheer Oct 07 '08 at 18:26
  • You need to agree to Microsoft's license before you use it, which includes a non-compete clause. It's free inperpetuity, but you should be aware that you are restricted by that license, even if you use the MFC implementation. – Jeff Yates Oct 07 '08 at 18:30
1

I would not use it because I don't want to be tied to a huge run-time. And I don't like all those ^ pointer thingys :)

I do like/miss the great library that .NET offers though.

DougN
  • 4,407
  • 11
  • 56
  • 81
0

I use it to support legacy code as well as writing shims between managed and native code. Love that VS11 supports it much better

Anton K
  • 4,658
  • 2
  • 47
  • 60