Runtime Generated Code with C++

Posted by Kaya Kupferschmidt • Wednesday, February 9. 2005 • Category: C++
While I was designing the architecture of my 3d graphics library (Project Magnum), enabling high performance was a critical design goal. But with the addition of abstraction layers, some doubts about the whole approach began to rise in my head, as each layer will inevitabely eat some CPU time and therefore means a decrease in performance. Abstraction in C++ often means the usage of virtual functions, which cannot be inlined by the compiler and whcih are even more expensive than a normal function call. Especially with the new processors having very long pipelines, each jump or call will introduce considerable costs in terms of CPU cycles.

I was thinking about a good solution that on the one hand would still support a high level of abstraction and on the other hand would eliminate the need of virtual function calls. Soon I realized that in many cases, the overhead of virtual functions and abstract interfaces is not really needed with static geometry. In these cases the geometry is created once and does not change much during later execution, but still each call to the render method would incurr a series of virtual calls in order to set the correct shader, material, textures etc. But in the case of static models, the decisions, which routines are ultimately called by the virtual functions, would never change.

Continue reading "Runtime Generated Code with C++"

Herb Sutter on Channel 9

Posted by Kaya Kupferschmidt • Monday, February 7. 2005 • Category: C++
The readers of this blog may already have found out (see Designing and Writing Generic Facilities: A C++ Challenge and Effective C++ vs Exceptional C++) that I am a fan of Herb Sutter. Now I discovered that this guy is working at Microsoft, and not as some dumb programmer, but he is an (or maybe even the?) architect on the Visual C++ team, which indeed is an excellent compiler and development environment. People can definitely argue on the quality of the design of Windows or Office (for me, I don't like MS Word at all, too many features, too bloated), but Visual C++ really is a shining star within the Microsoft product line, and even among development environments as such.

But I didn't intend to write some anthems on Visual C++, I really wanted to tell you that on Channel 9 (a Microsoft forum for developer relations) there are two videos featuring Herb Sutter: Herb Sutter - The future of Visual C++, Part I and Herb Sutter, the Future of Visual C++, Part II.

Kaya

Well Designed Classes and Interfaces

Posted by Kaya Kupferschmidt • Thursday, February 3. 2005 • Category: C++
The last two days I have been working hard to get a nice spring simulation working in C++ together with an appropraite demo, for example cloth rendering. The spring simulation itself is completely done using templates that allow any base type for calculations (float, doubles or even some custom data types) and they work in any dimension (the 2- and 3-dimensional cases are the most interesting, but while on the track, why prevent even further generalisation if it costs nothing in this case).

Still missing is the setup for a rectangular grid and the rendering routines. While these tasks are straightforward, the biggest problem is a clear and solid design of the interfaces and classes which are responsible for creating a spring system and for rendering. Why do I need that much time on such a apparently negligible? I will try to explain why a good design of great importance.

Continue reading "Well Designed Classes and Interfaces"

Designing and Writing Generic Facilities: A C++ Challenge

Posted by Kaya Kupferschmidt • Monday, January 31. 2005 • Category: C++
Some weeks ago, I wrote a small book comparison called "Effective C++ vs Exceptional C++" about two C++ specific books. I really like Herb Sutters books, they contain very valuable information and tricky examples that teach you a better style of programming.

Today on informit.com a sample chapter from the book "Exceptional C++ Style: 40 New Engineering Puzzles, Programming Problems, and Solutions" by Herb Sutter has been made available online. Read the full article called Designing and Writing Generic Facilities: A C++ Challenge, in order to get an impression about the book.

Kaya

C++ Style Guide

Posted by Kaya Kupferschmidt • Wednesday, January 5. 2005 • Category: C++
I updated the C++ style guide, but still there are some sections missing. You can download a pdf version or view an online HTML version.

So now after this announcement you might wonder abut what you can expect inside the C++ Style Guide. In order to give an answer, I am so lazy and copy the introduction of the guide.

Many people who start developing software in a team are confronted with a coding style guide, which might be a recommendation but more often it is a mandatory piece of paper. Of course the fact that their freedom of programming the way they would like is restricted often causes frustration in the beginning. But if you have worked on a big project with many different people you quickly begin to realize that not only the requirements of the program that is worked on are important, but also some sort of common language and programming style is essential for the success of the project.

But there is more to a style guide than a set of rules describing how variables should be called. A good style guide also contains many rules that relate to more general aspects of programming that help to ensure a high quality and help to avoid bugs. These guidelines include the proper use of public, protected and private sections in a class, the correct usage of the virtual keyword etc. Many of these items should be clear to the experienced programmer, but it is always a good idea to be aware of these rules and to know why they exist.


Kaya

C++ Style Guide

Posted by Kaya Kupferschmidt • Thursday, December 23. 2004 • Category: C++
The last few days I began to work on a C++ Style Guide which contains rules and recommendeations about good programming habbits in C++. This helps to ensure high quality of produced code and software and even can speed up development by giving answers to common questions when designing a new class.

There is an online browsable version and a downloadable PDF document available. Pleas keep in mind that this still is work in progress!

Kaya

A Simple Sidebar