ifacethoughts

C++ And The Pits

C++ is not one of the favorite programming languages today, not in the age of dynamic, garbage collecting and quick-to-code languages age. It has unfortunately become subject to a lot of bashing. I actually think that criticism is good, because it helps in evolving. Unfortunately you get to hear points on the same theme – making the features look as pitfalls and the power as danger. Jeff Atwood points to Eric Lippert’s warning about C++ as a Pit of Despair Programming Language.

Most of the signboards hover around memory management. With C++ I learnt that a disciplined approach helps you in avoiding the common errors mentioned there. Most of the times this happens because your plan changes, and your code does not reflect that. Memory management, according to me, is one of the most powerful features of any programming language. With garbage-collected ones, it is just that someone else does it for you. This might work most of the times, but at other times you want control over it. Today we are not resource hungry, and optimized use of the resources is not a big bang for the buck. But that does not mean that all languages should be garbage collected.

Its strictness is the other aspect talked about. As Jeff says, C++ is fast but unforgiving. I think the strictness helps to find holes in your design. Again, a disciplined approach should help you get on the right line. We seem to treat the programmer as the end user many times, and want to apply the concept of tolerance here. Is it wrong to assume that a programmer understands fundamentals of computing? We seem to extend this in that direction by saying that programmers should be spared, and C++ does not.

A lot of criticism of C++ and at times even OOP, has come out because it lets you do bad design. With flexible tools it is important to know and follow the best practices. C++ Techniques FAQ is one of the places to start with. Conversations between Bill Venners and Bjarne Stroustrup is another goldmine. They can probably justify when Bjarne Stroustrup says:

Within C++, there is a much smaller and cleaner language struggling to get out.

Having said that, I agree that there is no one-size-fits-all solution. C++ is not for all cases, thought it might be. There other excellent languages out there which perfect in other cases. But C++ has some excellent features. I personally love the template programming which has opened a whole new way of writing small code generators. It is a language which lets you optimize to the deepest level to help you deliver the best performance. The learning curve for C++ can be tough, it does deliver long-term benefits.

Let me end with some places where C++ still gets used:

You will find more well maintained and extensive lists C++ Applications and The Programming Languages Beacon.

Say your thought!

If you want to use HTML you can use these tags: <a>, <em>, <strong>, <abbr>, <code>, <blockquote>. Closing the tags will be appreciated as this site uses valid XHTML.

freshthoughts

contactme

Abhijit Nadgouda
iface Consulting
India
+91 9819820312
My bookmarks

badgesand...

This is the weblog of Abhijit Nadgouda where he writes down his thoughts on software development and related topics. You are invited to subscribe to the feed to stay updated or check out more subscription options. Or you can choose to browse by one of the topics.