I just read C++ vs. C# and thought it might be worthwhile to throw up a few thoughts. I've been ranting and raving about how great the new Managed C++ (C++/CLI) is. It's true, it is great, but I still prefer to do most of my work in C#. Why?
- C# compiles incredibly fast. I'm compiling around 80,000 lines and it takes about 20 seconds for a rebuild. That's from a cold start. (Chokes a little bit starting up intellisense.)
- Partial classes. Code is so much more maintainable when you have many nested classes. (#include just doesn't compare as a solution.)
- Anonymous delegates. An incredible feature for unlocking the power of the new generic collection classes. (posts to come on this.)
- No headers and no need to declare before you use. Both of these can make some nasty looking code sometimes.
XML Documentation(Heh, missed this one when I looked last time, it has been awhile... XML Documentation (C++))
- Constructors can call other constructors in the same class.
- I'm generally more partial to the way it looks. That's obviously a simple preference.
- Generally speaking people seem to be less afraid of C#. More know it (for managed code) and it's easier to enlist a little extra help on a C# project.
What do I like about Managed C++ over C#?
- Simple properties. Mmmm. Very nice for rapid prototyping.
- The hat ^. I like knowing when I've got a managed heap handle.
- C++ Interop is a much better way to work with unmanaged code if you have to.
- Mixed assemblies.
- Easier to get function pointers. (this is sometimes useful when using the generic collections, not a big thing, however)
If you have to migrate an unmanaged C++ project and want to do it piecemeal, the interop capabilities makes Managed C++ the obvious choice.
(If you have any feedback on what you prefer with either language I'd be happy to hear it.)
(What about VB? I did a lot with VB6 for awhile, but jumping back and forth between C#, C++, and C++/CLI is enough for my head at the moment. So, no comment.)