Expert Texture Home Contact me About Subscribe Digipede Connect on LinkedIn rwandering on Twitter rwandering on FriendFeed

The blogged wandering of Robert W. Anderson

Things I miss in C++

I have been working on the Attention recorder for IE 6/7 for the AttentionTrust in my “spare” time. I’m using C++/ATL for this.

I am enjoying working in C++ again (most of my development these days is in C#), but it has brought out to me my personal likes / dislikes about the two languages. I know this post is about 3 or 4 years late, but I wasn’t blogging back when I started with C#.

Things I miss in C++

  • Const pointers: The ability to declare that the data referenced by a pointer will be accessed read-only is quite useful. I never liked that this isn’t supported by .NET; though, I understand why it was.
  • Macros: This one still gets me. The macro support in C# is nearly non-existent. Why would you want macros? Doesn’t this violate the strong-typedness of the language? Yes, but stringizing and token-pasting is very useful to build maintainable code. I really wish C# supported this.
  • copy constructors: Having a default implementation of the copy constructor is quite useful.

What I don’t miss in C++

  • Header files: When I used to work in C++ I remember enjoying the distinction between the declaration and the implementation of classes and methods; however, now I just feel like it is an annoyance. The C# approach of leaving this up to the tools is much easier.
  • NULL: Back when true and false were added to C++ as language elements, I wished that null had been added too.
  • global scope: At first I didn’t like that C# has no global scope (outside of classes), but now I look at C++ and don’t like that I have to put methods that are clearly associated with a class implementation, but static, outside of the definition of the class. Certainly this can be handled with namespaces, but that doesn’t quite do it.

Of course, I much prefer the richness of the .NET Framework to the hodge-podge of class libraries required in C++ to do anything modern: ATL / MFC or WTL / MSXML, etc, . . . I also prefer the overall environment of garbage collection and pointer-safety delivered by a managed environment.

Tags: , , , ,

« Previous entries