I know .NET is a Microsoft framework. I currently use Visual Studio 2008 for C++ programming in school. Am I using .NET?

What is .NET? More specifically, is C++ a .NET framework by default? Does it just relate to the class libraries?

Recommended Answers

All 4 Replies

I know .NET is a Microsoft framework.

Yes.

I currently use Visual Studio 2008 for C++ programming in school. Am I using .NET?

Maybe. C++ is a programming language that is fundamentally incompatible with .NET. However, Microsoft has a frankenstein language called C++/CLI which mixes C++ with .NET code (and from my impression of it, it seems mostly intended (and used) as glue between real C++ code and real .NET code (e.g., C#), not as a standalone language). It might not be obvious to you which one you are using. But, technically-speaking, if you do C++ programming, then you are not using .NET, and if you do C++/CLI programming, then you are most-likely using .NET.

Here are some obvious signs that a given piece of code is in C++/CLI and not in C++.

  1. If standard library components use CamelCase convention, like String instead of std::string. All standard library components in C++ use all lower-case letters, usually underscore-separated.
  2. If you see things like System::Console::WriteLine( something ) as opposed to std::cout << something << std::endl;.
  3. If you see the character ^ anywhere. In C++, that character is not used for anything, and cannot appear in variable names either. In C++/CLI, it denotes a pointer.
  4. If you see things like ref class Something { to declare a class.
  5. If you see gcnew instead of new (gcnew means "garbage collected new"). In C++, there is no such thing as garbage to collect, so that doesn't exist.

and so on...

What is .NET?

.NET is an environment overlaid on top of the OS in which semi-native code can run. Traditionally, you write a program in some native programming language (like C, C++, fortran, D, etc.), which you then compile for a target OS (and system) to produce binary executable code, and then you run the executable directly (with some assistance from the OS). So, these languages are called native because the compiled code runs directly on the CPU, unfiltered. In an environment like .NET or JVM (Java Virtual Machine) which work essentially the same way, the code gets compiled in an intermediate code (called "byte-codes") which is at a much higher level than binary executable code. Then, as you run it, the platform (or framework, or virtual machine) translates those byte-codes into executable actions on-the-fly. There are two main motivations for doing this, 1) a single piece of code is good for all systems (on which the .NET or JVM can run and is installed), while a native language requires at least a recompilation for each system, and possibly some work to port the code; and 2) having the intermediate layer allows for all sorts of safety measures to be put in place (mostly to protect programmers from their own inadequacy). The penalty for this is, of course, a massive loss of performance (we're talking 5 to 100 times slower programs, depending on many factors).

More specifically, is C++ a .NET framework by default?

No. It cannot ever be in .NET. For one, the objectives (or design decisions) of .NET (or equivalently, JVM) are completely different from those of C and C++ (and D). For two, C++ long predates .NET and thus, was never designed for .NET. For three, C++ is one of the most widely used language in the world with a massive amount of robust production code using it, it cannot make accomodations for some Microsoft's flavor of the day. For four, C++ has features that are unparalleled in .NET or JVM and which are, for technical reasons, not possible on any kind of on-the-fly compilation / byte-code interpreted framework. And finally, C/C++ are the fastest languages in the world, and many people use them for that specific reason (e.g., computer games, robotics, embedded systems, etc.), so these languages have to remain uncompromising in speed.

Does it just relate to the class libraries?

Well, beyond what I already explaned, if we talk of the difference between programming in C++/CLI versus in C++, then for the average programmer the main difference will indeed be the standard libraries (and it is the main "selling point" of .NET). The .NET framework has a lot more functionality built into the standard libraries, while C++ is more conservative, again, because of its much wider application areas, not just desktop applications like .NET. But one of the main differences is the garbage collection. .NET manages the memory for you by deleting it at some point when it can establish that you don't need that memory anymore (i.e., it collects the garbage), this has practical advantages and disadvantages. In native languages like C++, the programmer is left to deal with the memory (i.e., not produce garbage). Then, .NET also does a lot more checking of things like going out-of-bounds on an array, while C++ trusts that programmers don't do such mistakes or will implement the bound-check themselves when needed. Finally, there are all sorts of other little differences, but they are mostly trivial syntactic differences.

commented: An informative, concise and polite post +10
commented: Thans Mike for your elaborate information and so patience +0

More succinctly:

I know .NET is a Microsoft framework. I currently use Visual Studio 2008 for C++ programming in school. Am I using .NET?

No.

What is .NET? More specifically, is C++ a .NET framework by default? Does it just relate to the class libraries?

.NET, in terms of actual software, is a bytecode interpreter (which interprets .NET bytecode) and set of library functions. C# is a programming language that (typically) gets compiled to .NET bytecode. (Bytecode is a series of instructions, in a particular format, evaluated by a program called a bytecode interpreter. ".NET" has a particular format for its bytecode.)

C++ is a programming language that (typically) gets compiled to machine code. (Machine code is a series of instructions evaluated by a bunch of wires called a CPU.) In your case, probably x86 machine code, or amd64 machine code.

(we're talking 5 to 100 times slower programs, depending on many factors).

It's more like 1-3 times slower, for C#, most of the time.

For four, C++ has features that are unparalleled in .NET or JVM and which are, for technical reasons, not possible on any kind of on-the-fly compilation / byte-code interpreted framework.

Not really. There is no reason C++ cannot be evaluated by an interpreter, or with on-the-fly compilation. (For example, look at the things LLVM can do.)

The .NET framework is a platform on which applications developed using microsoft tools run on. Console C++ programs can run without the .NET framework, but when the framework is there, it does not make any difference. C++ language is also included in the Microsoft Visual Studio suit, I'm sure just to make it easily accessible by C++ lovers and to add a graphical touch to it.

...I don't even know where to begin on that, but here we go:

The .NET framework is a platform on which applications developed using microsoft tools run on.

Kind of, but MonoDevelop is used to run .NET code on several platforms. Unless you consider the language syntax and specification tools.Console C++ programs can run without the .NET framework

Console C++ programs can run without the .NET framework

What's your point? You can write console C++ applications with or without the .NET Framework. Same for GUI applications and static/dynamic libraries.

but when the framework is there, it does not make any difference

That makes a huge difference. You suddenly have access to the .NET Framework, which has a massive library of classes and has a garbage collector. Also, you can have a mixture of managed and unmanaged code. Along with some decrease in performance, given the overhead of the garbage collector and the interpreter. That's a pretty significant difference I would say.

C++ language is also included in the Microsoft Visual Studio suit

Yup.

I'm sure just to make it easily accessible by C++ lovers and to add a graphical touch to it.

I'll admit, this is somewhat correct, although lacking quite a bit. The whole purpose of an IDE is to give a set of tools to aid in the development of applications, along with a "graphical touch". Without it, we're back to using a text editor and the command line to build applications. I guess I'm not getting your point here...

What was the point of this post? Between mike_2000_17 and Rashakil Fol they answered the question quite well, and you didn't really add anything. You seemed to be answering a question without enough information to do so, and provided incorrect and incomplete information that could confuse any new programmers reading this post later on.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.