James Michael Hare

...hare-brained ideas from the realm of software development...
posts - 164 , comments - 1434 , trackbacks - 0

My Links

News

Welcome to my blog! I'm a Sr. Software Development Engineer in the Seattle area, who has been performing C++/C#/Java development for over 20 years, but have definitely learned that there is always more to learn!

All thoughts and opinions expressed in my blog and my comments are my own and do not represent the thoughts of my employer.

Blogs I Read

Follow BlkRabbitCoder on Twitter

Tag Cloud

Archives

Post Categories

.NET

CSharp

Little Wonders

Little Wonders

vNext

C#: A "Dumbed-Down" C++?

I was spending a lovely day this last weekend watching my sons play outside in one of the better weekends we've had here in Saint Louis for quite some time, and whilst watching them and making sure no limbs were broken or eyes poked out with sticks and other various potential injuries, I was perusing (in the correct sense of the word) this month's MSDN magazine to get a sense of the latest VS2010 features in both IDE and in languages.

When I got to the back pages, I saw a wonderful article by David S. Platt entitled, "In Praise of Dumbing Down"  (msdn.microsoft.com/en-us/magazine/ee336129.aspx).  The title captivated me and I read it and found myself agreeing with it completely especially as it related to my first post on divorcing C++ as my favorite language.

Unfortunately, as Mr. Platt mentions, the term dumbing-down has negative connotations, but is really and truly a good thing.  You are, in essence, taking something that is extremely complex and reducing it to something that is much easier to use and far less error prone.  Adding safeties to power tools and anti-kick mechanisms to chainsaws are in some sense "dumbing them down" to the common user -- but that also makes them safer and more accessible for the common user.  This was exactly my point with C++ and C#.  I did not mean to infer that C++ was not a useful or good language, but that in a very high percentage of cases, is too complex and error prone for the job at hand.

Choosing the correct programming language for a job is a lot like choosing any other tool for a task.  For example: if I want to dig a French drain in my lawn, I can attempt to use a huge tractor-like backhoe and the job would be done far quicker than if I would dig it by hand.  I can't deny that the backhoe has the raw power and speed to perform.  But you also cannot deny that my chances of injury or chances of severing utility lines or other resources climb at an exponential rate inverse to the amount of training I may have on that machinery.

Is C++ a powerful tool?  Oh yes, and it's great for those tasks where speed and performance are paramount.  But for most of us, it's the wrong tool.  And keep in mind, I say this even though I have 17 years of experience in using it and feel myself highly adept in utilizing its features both in the standard libraries, the STL, and in supplemental libraries such as BOOST.  Which, although greatly help with adding powerful features quickly, do very little to curb the relative dangers of the language.

So, you may say, the fault is in the developer, that if the developer had some higher skills or if we only hired C++ experts this would not be an issue.  Now, I will concede there is some truth to this.  Obviously, the higher skilled C++ developers you hire the better the chance they will produce highly performant and error-free code.  However, what good is that to the average developer who cannot afford a full stable of C++ experts?

That's my point with C#:  It's like a kinder, gentler C++.  It gives you nearly the same speed, and in many ways even more power than C++, and it gives you a much softer cushion for novices to fall against if they code less-than-optimally.  A bug is a bug, of course, in any language, but C# does a good job of hiding and taking on the task of handling almost all of the resource issues that make C++ so tricky.  For my money, C# is much more maintainable, more feature-rich, second only slightly in performance, faster to market, and -- last but not least -- safer and easier to use. 

That's why, where I work, I much prefer to see the developers in my workplace moving to C#.  The quantity of bugs is much lower, and we don't need to hire "experts" to achieve the same results since the language itself handles those resource pitfalls so prevalent in poorly written C++ code.  C++ will still have its place in the world, and I'm sure I'll still use it now and again where it is truly the correct tool for the job, but for nearly every other project C# is a wonderfully elegant and powerful alternative to C++.  Is it "dumbed-down" as some C++ developers would complain?  If so, only in the very best sense -- but to me, it's the smarter choice.

Print | posted on Sunday, April 18, 2010 11:17 PM | Filed Under [ My Blog C# C++ ]

Feedback

Gravatar

# re: C#: A Dumbed-Down C++?

And yes, I will actually have some coding entries here soon...
4/18/2010 11:26 PM | James Michael Hare
Gravatar

# re: C#: A "Dumbed-Down" C++?

Unfortunately this approach "It's like a kinder, gentler C++." has some SERIOUS negative consequences.

Over 50% of the times when a client engages me to deal with ".Net performance issues", the root cause is that they applied approaches and patterns that were appropriate for another language (typically C++) into a .NEt (typically C#) application.

For those who have been around long enough, there was a major paradigm shift in the switch from "structured" to "object oriented" code about 20 years ago. One had to "unlearn" many items and adopt a compete new way of thinking about a problem.

The same is true (more subtle, but larger in scope) in switching from environments such as Native C++ into a managed environment like C# (or even C++/CLI
4/23/2010 2:31 PM | TheCPUWizard
Gravatar

# re: C#: A "Dumbed-Down" C++?

Oh I totally agree with that. In many ways a C++ developer has to "unlearn" what they know about C++ to fully embrace the safety and beauty of C# and still get good performance.

There's many times I've seen C++ developers jump into C# and think they're doing micro-optimizations which end up actually hurting them as they defeat JIT optimizations.

So yes, I agree. The salient point is that C# is a much better business class language in my experience. The article itself was mainly arguing against C++ developers who consider it "watered-down" or somehow inferior.
4/23/2010 2:40 PM | James Michael Hare
Gravatar

# re: C#: A "Dumbed-Down" C++?

@Cazare: Recent comparissons of C# vs C++ vs Java have shown C# and C++ as the best performers and Java quite a bit farther behind.

C# does sactifice some performance to give you more features and safety, so a perfectly written C# program will probably never quite be as fast as a perfectly written C++ application, but it's a LOT easier to write a perfect C# application than a perfect C++ application.

In today's business world, C# tends to trump C++ in terms of maintainability and time-to-market while still having exceptional performance.

That said, there are still cases where you need the raw speed and power of C++ for more system level applications.

They're two different tools and it depends on the job, mostly. My main argument, though, is that too often C++ developers tend to shun C# and stick to their guns in terms of performance even when they really don't need that little extra umph at the cost of maintainability.
2/9/2011 11:51 AM | James Michael Hare
Gravatar

# re: C#: A "Dumbed-Down" C++?

@Security News:

Yes, C# is an easier to use language with a quicker time to market, but it's not a wholesale replacement for C++ since C++ still has the edge for performance. For business class software, though, where getting features out quickly is more important than the extra 5% of performance, it's hard to beat C#.
4/26/2011 3:02 PM | James Michael hare
Post A Comment
Title:
Name:
Email:
Comment:
Verification:
 

Powered by: