For a while now, I’ve been thinking whether , for me, as a C++ programmer, learning C# is worth investing time in. I admit I was kind of annoyed seeing people with little experience in programming saying that C# is the way to go, it is the latest release from Microsoft so it must be the greatest thing since sliced bread.
There are a lot of good posts on C++ vs. C# out there, so I won’t repeat any of the traditional pros and cons, these are just some of my thoughts on the matter.
I believe some hotshots at Microsoft took a good look at Java and thought “Hmmmm….this write once, run anywhere thingie seems intriguing…and why are so many people using it?… and we don’t like that Sun’s getting all this attention. Yeah, we definitely want a share of this! But…we didn’t really have that much of a success with J++, how can we rebrand it? Wait! Why don’t we create a new language that runs anywhere (as long as that anywhere supports a Win-based OS, of course) and market it as the language that incorporates the best features from all other major languages?”
Now, believe it or not, Microsoft has nailed a lot of good things with C#. It is easy to use, the learning curve is nowhere near as steep as C++’s and, there’s plenty of documentation for it. Unfortunately, I believe these are also its pitfalls. IMHO, while C#’s relative simplicity will – maybe – allow more people with great ideas, that might not have had the time to learn C++, to start programming, it will also encourage sloppy programming. Most (new) programmers will not bother about resource management (where and when the resources are allocated and when or where they are released) since the garbage collector does that transparently, but truth is this will have a great impact on performance.
So…back to my original problem, should a C++ programmer bother learning C# or not? Well, with the CLR included neatly into VS 2005 there’s no need to, but in the end it all comes down to the personal preference. I say, take a look at C#, you might end up liking it. Personally, I did program with it a little bit, but didn’t like it… I’m sticking with C++ for now