.NET Questions (CLOSED)

Questions and Answers on any aspect of .NET. Now closed.

This discussion group is now closed.

Have a question about .NET development? Try stackoverflow.com, a worldwide community of great developers asking and answering questions 24 hours a day.

The archives of .NET Questions contain years of Q&A. Even older .NET Questions are still online, too.

C++ for .NET vs. Old School

What is the difference between creating a CLR C++ app in visual studio, versus creating a WIN32?
SCADA Guy Send private email
Monday, January 15, 2007
 
 
There's a different API.

Using CLR C++ you can use the API provided by the .NET framework (and memory is managed for you, i.e. garbage-collected).

Using OS C++ you can use the Win32 API, or MFC (or other unmanaged frameworks).
Christopher Wells Send private email
Monday, January 15, 2007
 
 
That's from the programmer's point of view. From the user's point of view, there's not much difference! Except that the Win32 API always exists on a Windows machine, whereas the .NET framework must be installed separately (unless it's Windows Vista). The .NET framework offers some features that don't otherwise exist, e.g. the ability to run an application that you deem untrustworthy (it will run in a sandbox and throw an exception if it tries to use a priviledged API). Those are major differences ... there are plenty of other differences too ... do you have a more specific question?
Christopher Wells Send private email
Monday, January 15, 2007
 
 
Yes, performance? Is C++ for CLR just another flavor of .NET language? In other words, does it compile to the same IL code like C# and VB do? I have understood that the difference b/w C# and VB was mainly programmer preference, other than the fact the C# was the system language, and thus more tightly connected to the framework.

Before I fired up VS yesterday and tried to create a C++ App, I had never heard of C++ for CLR. You never see examples of .NET code done in VB/C#/C++, so there has to be some major reason why.

Thanks,
SCADA Guy Send private email
Tuesday, January 16, 2007
 
 
> Is C++ for CLR just another flavor of .NET language?

Yes.

> I have understood that the difference b/w C# and VB was mainly programmer preference

Yes, but you mean "VB.NET" not "VB": 'VB' is another old-school language.

> You never see examples of .NET code done in VB/C#/C++, so there has to be some major reason why.

You see examples of .NET code done in VB.NET and in C# but not in CLR C++ (or "managed C++" as it's called).

I haven't tried it but I guess that the reason for 'managed C++' is to help you port existing C++ code to .NET.
Christopher Wells Send private email
Tuesday, January 16, 2007
 
 
Visual Basic for the .NET Framework is just called "Visual Basic", without an explicit ".NET" qualifier.  The current version is called "Visual Basic 2005".
Chris Nahr Send private email
Tuesday, January 16, 2007
 
 
Also, "Managed C++" was the name for the "managed extensions" for C++ that worked with .NET 1.0/1.1.  For .NET 2.0 an entirely new version was devised, called "C++/CLR".  That's another set of language extensions, this time standardized.
Chris Nahr Send private email
Tuesday, January 16, 2007
 
 
Thanks Chris. Is it true that, as with J#, the reason for using C++/CLR (instead of using C# or VB 2005) is probably only to port legacy C++?
Christopher Wells Send private email
Tuesday, January 16, 2007
 
 
Re VB naming:

VB6: Called VB, VB6, or even VB.Classic.
VB 1.x: Called VB .NET (note space and capitalisation).
VB 2.0: Called VB 2005.
Mark Pearce Send private email
Tuesday, January 16, 2007
 
 
Oops, it's C++/CLI, not C++/CLR... sorry!

Easy porting of C++ code is definitely one reason why Microsoft made Managed C++ and C++/CLI, but there are others.  You can use C++ to mix managed & unmanaged code & data in the same .NET assembly.  That allows you to embed code that's very fast and hard to decompile, and data that's not controlled by the GC and easily accessible to non-.NET libraries.

Also, the VC++ compiler has better optimization than any other .NET compiler, even when creating IL code.  Personally, I think there's also a propaganda reason beyond the technical benefits: C++ programmers won't take a platform seriously unless they can run C++ on the platform...
Chris Nahr Send private email
Tuesday, January 16, 2007
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz