sh0dan // VoxPod

Tuesday, October 05, 2004

Finally getting some code done

Even though it has been rather hard to find some free time lately, I've actually begun getting some actual code done for my new project, which at the moment is called DSPsynth (but that might change again).

One of the reasons it has taken me so long to get started is that I've spent some time "upgrading" my C++ skills to avoid making too many silly mistakes in my first implementation attempts. For that the C++ FAQ Lite has been a great help. It contained many of the answers for some of the things I didn't know about the "++" side of C++. There were also a lot of designwise hints that could be picked up - and it has helped me a lot in getting a good idea of what I should learn and do before beginning the actual implementation.

I've also begun researching the features of the STL-library, and it seems like a very good library to do trivial (but often annoying) implementations of thing like linked lists, string handling , etc. Boost also seems like a great library with many excellent features, like the graph library, smart pointers, memory management and much more. While both the idea and actual code of templates is rather new to me, having a Java background, it seems like good concepts for generalizing code.

So, even though I haven't been getting too much code down for the last few weeks, they have been great in terms of opening my eyes for what might very well turn out to be very helpful tools for greating a great framework.


  • Be careful about learning C++ -- too many times the very next thing a programmer does after learning feature X is try to to use feature X in everything. There are some parts of STL that IMO are more obfuscational than generally useful, such as the functional library. Templates, in particular, lend themselves to some truly horrific behemoths, with mountains of type traits classes and impressively tangled header dependencies. Try to use templates to do what you _need_ and not what you _think_ you might need down the road.

    Also, complex C++ features and cross-DLL calls often don't mix. For instance, passing STL containers to plugins is a big no-no, because it will blow up if the compilers mismatch or one of the modules involved is statically linked to the CRT. Smart pointers can cause similar problems.

    Finally, be wary of the traps. A lot of people are surprised that list::size() is O(N) in some STLs; reference counted pointers will snare you in loops. I haven't used Boost much, but with the STL, you'll get the most use out of vector, list, map, and string.

    By Blogger Phaeron, at 3:32 am  

Post a Comment

<< Home