If you know C++
whats the point of C#?
This is a discussion on I Know C++ within the C# Programming forums, part of the General Programming Boards category; If you know C++ whats the point of C#?...
If you know C++
whats the point of C#?
Some things are easier to do with C#. For example, using the .NET framework. C# is also garbage collected, so you have less memory leak problems.
I know C/C++ and C# (among other languages that don't have C's in their names), so here is my view on it.Originally Posted by jaylc185
Ease of GUI design: if you have coded GUI's in C++ you probably know you spend a LOT of time getting the little details right, it is much easier in C#.
edit: The above quote has to do with the use of windows forms so it isn't directly applicable to the *nix environment yet....although they are working on it C# proper doesn't make GUI design easier, but for windows development it and Forms makes life much easier.
JIT Compilation: Since methods aren't compiled until they are needed they are able to do optimizations that are impossible to do with a statically compiled language like C++. For instance the code can be compiled to take advantage of features on the users machine that may not be on all users machine, special instructions unique to their processor like MMX and 3DNOW. To get this in C++ you need to either compile different versions for people with this support and without it, or you need to leave this support out. Plus what happens when new processors come out that have new features? New versions of the framework will allow your code to take advantage of this without recompiling, ie your app will perform better because the end user gets a new copy of the framework.
Cross language compatibility: Since C# is a member of the .NET family it can easily interoperate with any other .NET language. Since the .NET standard is open anyone can make any language a .NET language just by creating a compiler that outputs conforming IL. If you have ever tried to do communication between processes written in different languages you realize what a pain in the ass it can be.
Greater Security: The CLR enforces a lot of security features you probably don't in your own programming. You can do the same thing in C++ but it requires a lot of work on your part and is very error prone.
strong typing: C# is strongly typed, this means the compiler can catch a lot more stupid coding errors on your part
Generics: Similar to C++'s templates but they are not created at compile time thus there is no increase in code size for using them. Also they allow type constraints to make it a requirement that instantiation types are of a certain kind, it will not allow someone to create a class of yours with something other than what you support. For instance if you have a data structure that orders things, say an AVL tree, you need to insure that the types being stored are comparable, you can dictate that the user creating the tree instantiate on a type that is IComparable for instance. You may be able to do this in C++ but last I checked, it has been a few years, you couldn't.
These are just a few advantages. By the tone of your post you seem to be of the mindset that there is one language right for all jobs. This is not the case, imo. A language is just a tool to get the job at hand done. I don't use a hammer to drive a screw C++ certainly has its advantages and disadvantages, as does C#. There is no be all end all language if there was...well there would only be that language. The point of programming is to pick the language best suited for the task at hand, here's a hint, it isn't always C++, nor is it C#, nor is it ASM, etc....
Last edited by Mezzano; 05-21-2005 at 06:06 PM. Reason: clarification
True but it was mentioned by the first poster so I didn't touch on thatOriginally Posted by stovellp
Also with C# (well, .NET) you have the option of "going web" - ASP.NET. Of course you could use C++ to output web pages (by writing your own web server or ISAPI modules) but ASP.NET takes care of all that crap for you.
LOLOriginally Posted by stovellp
I remember this article about this one company that had a lot of Cold Fusion developers. So, the company switched to Apache & PHP, and the Cold Fusion developers were not happy, but they would've been happy if they knew PHP....
So what I'm saying is, if you mastered C++, and you mastered C#, then if your company switches from C++ to C#, you will feel happy, not bad :]....but of course if you're taking time away from C++, you could hinder yourself from going deeper into the dark caves of 1000+ lines of code at which will render you as supremo C++ man! And I'm cheetah man!