Fog Creek Software
g
Discussion Board




C++/CLI

Am I the only one looking forward to C++/CLI?  It makes me excited to be a C++ developer on Windows again.  Finally I'll be able to use .NET in the OneTrue language!

http://weblogs.asp.net/hsutter/

(Start reading that from the beginning in November if you haven't heard anything about this yet.)

Michael Kale
Thursday, February 12, 2004

Oh, and just in case you guys think this is some kind of marketing campaign ... I'm not in any way affiliated with Microsoft or the official C++ people.  ;-).

I believe in portable, standards compliant code as much as the next guy and use actively three platforms on many days.

I just like being able to use what I consider to be the good features of C++ with .NET (scope-based object lifetimes, RAII, C++ templates mixed and matched with .NET generics, STL classes mixed and matched with .NET classes, reams and reams of legacy code that can be brought forward slowly over many releases, etc, etc, etc).

Michael Kale
Thursday, February 12, 2004

Visual C++ 7 is a big leap no doubt.

Li-fan Chen
Thursday, February 12, 2004

I'm not talking about Managed C++ that you get in current versions of Visual C++.  This is the new stuff that's coming out in Whidbey.  IMHO, C++/CLI makes MC++ look like an ugly hack.  The new binding makes the .NET features "first class" in that the syntax feels natural like it belongs there.

Michael Kale
Thursday, February 12, 2004

can you give a quick summary?  I actually don't have time to read all the entries since november. 

imagine that
Thursday, February 12, 2004

"IMHO, C++/CLI makes MC++ look like an ugly hack."

Actually, MC++ looked like an ugly hack without any help. :-)

I'm a little curious about the C++/CLI stuff, but I doubt I'll use it much. I've gotten progressively more disillusioned about C++ over the years. The current "If it's not a template it's crap!" mania in the newsgroups and print magazines just drive home the point that you can't really program C++ anymore without being a complete expert in everything.

I have work to do; I don't want to spend the time arguing with the compiler.

Chris Tavares
Thursday, February 12, 2004

Maybe I am coming at this from a too Java-informed perspective, but how will you stand the lack of pointers when programming C++ (or am I making a bad assumption that the CLI doesn't forbid pointers like a good little VM should)?

name withheld out of cowardice
Thursday, February 12, 2004

> I making a bad assumption that the CLI doesn't forbid
> pointers like a good little VM should

The CLI doesn't forbid pointers.  You can use them under certain restrictions, even in C# if you mark the code as 'unsafe'.

The original managed C++ extensions had the concept of __gc A* for a managed pointer and __nogc B* for an unmanaged one.  In many cases the compiler could deduce the correct type from the context.

The next version of the compiler introduces a new syntax for handling managed 'handles' using the ^ operator and gets rid of the half dozen or so __'whatever' tags needed currently.

I'm looking forward to this release - but since we have several tens of thousands of lines of managed C++ currently I'm not looking forward to porting it to the new syntax!

Rob Walker
Thursday, February 12, 2004

The new version of Managed C++ (aka C++ CLI or whatever) certainly looks interesting but I do have to ask... who cares?

Let's face it, C++ is an ugly bloated language. The only way all this monstrous complexity is justified is if you use it as a "portable assembler" like its ancestor C, and that means: if you compile to unmanaged code.

I didn't know why anyone would want to use Managed C++ except for rare compatibility scenarios, and while the new version is nicer I still don't know why I'd ever want to use that instead of C#. Especially since the Whidbey version of C# will include templates.

Chris Nahr
Thursday, February 12, 2004

> I still don't know why I'd ever want to use that instead
> of C#. Especially since the Whidbey version of C# will
> include templates.

As you suggest the main advantage of C++ is the easier interop with an existing C++ code base.  In many scenarios this isn't particularly rare.

If you have a static library you link with then managed C++ is the only option for access that in the managed world - short of wrapping it up in as a DLL or COM object.

For totally new projects then C# is very attractive, but even there if you need that little extra bit of flexibility then managed C++ gives you it.  What percentage of projects is that?  Probably small but significant.

Microsoft have stated that they want to see C++ as the 'lowest level' managed language -- it capable of expressing /everything/ that can be done in the CLR. 

Rob Walker
Thursday, February 12, 2004

C# generics in Whidbey are very different than C++ templates.  C++/CLI will let you use both.

http://weblogs.asp.net/branbray/archive/2003/11/19/51023.aspx

C++ is still my language of choice for new code and old.  IMHO, C++ syntax is more expressive than C#/Java and allows for cleaner, more elegant code.  It also does not have to be a lower level language than C# or Java if you don't want it to be.  Using RAII you rarely have to explicitly manage memory and other resources.  C++ class libraries exist with the same levels of abstraction as other languages.  etc, etc.

I realize that many people disagree with this sentiment, and the world is moving towards Java and C#.  I too will likely have to do that, but C++/CLI lets me delay that for a while...

Michael Kale
Thursday, February 12, 2004

Speaking as someone who has been paid to write C++ code for the past 6 years: C++ really sucks.

The only reason to use it is performance and practicality (not having to distribute the entire .NET runtime), once you trade those in by moving to .NET, why bother?

MC++ and C++/CLI are decent for the purposes of wrapping old legacy code to be consumed by other .NET languages; but I'd have to question the sanity of anyone who would continue to write new code in C++ after moving to .NET.

Mr. Fancypants
Thursday, February 12, 2004

Funny how _every_ discussion of something C++ related will inevitably lead into some dork comments á la "C++ SUCKS"...

_
Friday, February 13, 2004

I know what you mean ... it's not worth my time to respond to someone who's using the "X sucks because I say it does" method of debating.

Michael Kale
Friday, February 13, 2004

Speaking as someone who has been paid to write C++ code for the past 6 years: C++ rocks.

It's incredibly expressive, powerful, fast, and compiles on many platforms.  Sure, it's not easy for beginners to use, but careful study of the language is extremely rewarding.

Michael Eisenberg
Friday, February 13, 2004

Speaking as someone who's written C code almost exclusively over the last couple of years, I'd just like to say that C++ already has all the bells, whistles and abstractions that I want.  I can't imagine why I'd want to add a fat runtime that only gave me what I already had.

Clay Dowling
Friday, February 13, 2004

Does this undermine a large part of the whole point of C/C++

i.e.
1. Performance/Lightweight  vs bloated runtime platform, e.g.  .NET


2. Insurance against the future.

By this I mean, if I write C/C++ now, provide I write reasonably good code, there's a good chance that I will be able to make it work (perhaps with mods and rewrite API calls as opposed to the application "engine") in 10 years time when we're running Super-Win-Linux-XP-3000 or whatever.   

Whereas with a proprietary language, even a Microsoft one, you never know when they will pull the rug away from you.  Ask VB6, Microsoft Pascal, or Foxpro users.

S.Tanna
Friday, February 13, 2004

*  Recent Topics

*  Fog Creek Home