-1

I'm primarily a C# developer and the presence of Visual C++ in Visual Studio confuses me.

I have the following questions:

  • Does it do C and C++, and are there different compilers for each?
  • Is there any way to develop code that will be run un-managed in Visual C++ or will anything developed in Visual C++ run need .NET to run? Does managed vs. un-managed come down to the compiler used?

  • If running writing and running managed Visual C++ code, is there anything I can do in VC++ that I couldn't do in C#?

  • Other than learning for its own sake (which is great) would I gain any insight by learning VC++ and if so, where should I start?

I understand this isn't a straight programming question and I am ready for the onslaught of downvotes, however, I am legitimately curious about this and figured others might be as well.

pnuts
  • 58,317
  • 11
  • 87
  • 139
Matt
  • 25,943
  • 66
  • 198
  • 303

2 Answers2

1

A little insight I recall hearing from Stephan T. Lavavej is that nearly everything in the MS toolchain depends through some way or another on MSVC. It's extremely important, albeit not always directly.

Does it do C and C++, and are there different compilers for each?

It only does C++ but most C can be compiled with a C++ compiler.

Is there any way to develop code that will be run un-managed in Visual C++ or will anything developed in Visual C++ run need .NET to run? Does managed vs. un-managed come down to the compiler used?

No, you don't need .NET or C++/CLI. Many people do not.

If running writing and running managed Visual C++ code, is there anything I can do in VC++ that I couldn't do in C#?

Likely low level stuff and using C or C++ libaries.

Other than learning for its own sake (which is great) would I gain any insight by learning VC++ and if so, where should I start?

You will learn all the insights C++ provides. You don't need MSVC for that, just any compiler.

Learn C++ first. Then read MSDN documentation like Dan-o pointed out.

Community
  • 1
  • 1
Pubby
  • 51,882
  • 13
  • 139
  • 180
1

Does it [Visual C++] do C and C++, and are there different compilers for each?

There's one compiler (or at least a single front-end program) that does both C and C++ (but contrary to what some believe, it runs in a separate mode for C, where it will reject constructs specific to C++).

Is there any way to develop code that will be run un-managed in Visual C++ or will anything developed in Visual C++ run need .NET to run? Does managed vs. un-managed come down to the compiler used?

Yes, native code developed in C or C++ can/will run without .NET. There is a sort of hybrid (C++/CLI) that's sort of like C++ but what it produces requires .NET to run. I wouldn't spend a lot of time/effort worrying about it though -- in fact, I'd generally ignore its existence completely.

If running writing and running managed Visual C++ code, is there anything I can do in VC++ that I couldn't do in C#?

Yes and no. C++/CLI makes interop with native code quite a bit simpler than trying to use it directly from C# -- and that's essentially the only situation in which I'd recommend using it (and at least the last time I looked, that was pretty much what MS recommended as well).

Other than learning for its own sake (which is great) would I gain any insight by learning VC++ and if so, where should I start?

Do you mean learning real C++, or Microsoft's C++/CLI thing? As pointed out above, C++/CLI is neither fish nor fowl, and I'd generally avoid it.

Real C++ is rather a different story. There are quite a few reasons to use it:

  1. Templates: find out what C# "generics" do a poor job of imitating.
  2. Native code: can help speed, eliminates dependency on .NET.
  3. Some (but, not all) of the standard library is much better designed.
  4. Saving the best for last: RAII manages all kinds of resources, where GC only manages memory.

Personally, I think you're concentrating far too much on "one compiler" vs. "two compilers" -- it's a nearly meaningless distinction. The real question isn't how many compilers are involved, or which one produces what code, but how to accomplish what you want -- and at least if you're working inside of VS, it'll generally sort out things like which compiler to invoke for a particular piece of source code.

Let this be seen as a sales pitch (or something similar) I feel obliged to point out that C++ isn't all wonder and light compared to C#. Just for example, C++ doesn't really support reflection, which makes some things much clumsier than in C#. Some other areas (e.g., template meta-programming) are possible, but can be hard to understand and often involve truly hideous syntax. Then there's the simple fact that compile times are almost always quite a bit slower with C++ than C#.

Jerry Coffin
  • 476,176
  • 80
  • 629
  • 1,111