Who’s afraid of C++

C++ is the 2nd programming language I’ve learned (C was the 1st) back in object oriented course and I’ve been using it ever since. From my first job where I’ve wrote code using Vim and XEmacs (for Linux - I’m not that old) to my current job where I’m using Visual Studio 2010 I’ve never stopped using C++.

I know most of its tricks and I occasionally use some its “black magic” and I enjoy seeing the code I worked so hard on doing what I need it to do.

Since .NET 1.1 came out back in 2003 I’ve been a .NET addict. I’ve enjoyed seeing how the .NET world progressed and changed over the last 10 years and I’m proud to be one of the passengers in this amazing ride.

Luckily for me I got to enjoy both worlds – excluding my first job every project I worked on I’ve used both C++ and C#.

I wrote a graphic engine using C++ and used C# and winforms for the application's  UI, I’ve used Managed C++ to expose an old C++ legacy application using web services written in C#, I’ve written code in both C++ and C# to harness the profiler API to do my bidding. And I always thought I don’t have a clear preference between the two – they are merely programming languages designed so I can write software that does what I want.

But it’s not true, every single project I did on my own free time I’ve used .NET. Because I seem to get results faster using managed code and I don’t have to mess with many compilation and linking errors.

And the tools – although C++ has it’s share of productivity tools it cannot compete with the sheer amount of tools that are available for the .NET developer. Although us C++ developer did get some much deserved support in the new Visual Studio but it still takes much more time to develop application than with C#.

And it’s more than that - at work we try to keep a clean and well structured code but I’ve noticed that there is a big difference between our clean C# code base to the messy bordering spaghetti C++ code. One the reasons is that we use Resharper for refactoring our .NET code while we still haven't found a similar tool for C++. The simplest refactoring such as a method name change need to be done at least in two places (remember header files) and can cause very interesting compilation issues that would take some time to solve – so developers tend to avoid them.

The same developer who would make sure that each class is stored in a different file in C# would put five classes in the same header file to avoid unnecessary conflicts during build.

I’m not sure if this lack of discipline is caused because it’s harder to write clean code in C++, the lack of tools, or fear…

 

What I do know is that writing C++ requires much more energy and I guess that’s why I enjoy it so much – it’s much more fulfilling achieving something hard than something trivial.



Labels: ,