Please note that I don't update this web site anymore. You can visit my new personal blog at www.williamwilling.com.
Returning To C++
Monday, November 29, 2004
Last week I made good progress with my game. It took me some time to get on track,
because I had to reacquaint myself with an old friend: C++. After having programmed in
C# for about three year, my view on object-oriented programming as a whole and C++ in
particular has changed a bit.
C++ is a quirky language and to me that's part of its beauty. Knowing how to properly
manage computer memory and playing around with operator overloading has all the charm
and challenge of a good logics puzzle. C++ has been a great hobby for me over the
When you actually need to be productive, however, C++ isn't always that great and
I'm not talking about the lack of garbage collection. Declaring member functions twice is a
pain, whichever way you look at it. For example, it greatly hinders refactoring, because
you need to make changes to the function signature in two seperate places. That is not
my only gripe with the language, but it is my main one.
While programming in C#, I also got used to unit testing and test-first development,
so naturally I looked for a C++-based unit testing framework. I found and tried a couple,
but most of them require the declaration of unit tests in more than one location. Writing a
class with a run()-member function and a couple of private functions for the tests is just
about the same amount of work. Of course, a unit testing framework has more to offer,
but nothing I need at the moment, so I'm currently writing simple classes for my tests
and it works well for me.
Now that I have the basics in order, I'm becoming more and more productive. Also, I'm
having fun again programming in C++, despite its shortcomings.
Back to blog index
I had to use Java for a software engineering class at my university, and we used ant and JUnit for making automatic tests.
As I understand it, there is something similar for C++, I think called CUnit or something like that. Have you tried it?
I am actually relearning C++ myself. I would like to hear more about your progress with it, especially with things like how you handle testing.
Thursday, December 2, 2004 10:28 PM
First of all, sorry for not responding promptly. I'm not used to getting comments (yours is actually the first one. :-)), so I hadn't checked for a while.
I think you are referring to CppUnit, which I have tried. It is a bit too involved for my taste. My needs are very simple, so I don't need something that powerful at the moment. Also, I still need to declare and define tests seperately with CppUnit, so it doesn't solve my main problem.
I'll definitely be blogging about game programming more in the near future. I also really want to do some articles or tutorials about game programming in C++, but at the moment I'm too busy programming. :-)
Thursday, December 9, 2004 3:33 PM
As far as I know, unit testing frameworks for C++ are not as good as those for C# and Java, and that has to do with the C++ language itself.
Anyway, these two languages work totally different, and it all depends on your needs and there should not be a lot of debate on this. It would make no sense to use C++ if C# can produce fast-enough program, while C++ sure runs much faster than C#.
Friday, September 23, 2005 7:03 AM
The main problem with C#, in my point of view, is not its speed, but its reliance on the .NET Framework.
But I agree that comparing unit testing in C# with unit testing in C++ is not very useful. If you have already decided you're going with C++, then you only need to compare C++ unit test frameworks.
However, if you grew up with unit testing in C#, then unit testing in C++ is somewhat of a cold shower; that was the reason I mentioned it.
By the way, Noel Llopis has compared a couple of unit testing frameworks for C++: http://www.gamesfromwithin.com/articles/0412/000061.html
Friday, September 23, 2005 10:45 AM
Tell me what you think
Since I'm not updating this site anymore, I disabled comments. You can visit me at my new site: www.williamwilling.com.