Home > C++ > The “Void Star” Crowd

The “Void Star” Crowd

During theAsk Us Anything” panel discussion at theGoing Native 2012” conference, one of the questions asked was: how do you get the “void *guys to move forward toward a more type-safe and abstract C++ style of programming?“.

By “void *“, the questioner meant programmers who still cling to writing code like this:

instead of this:

The panelists admitted that it was a big challenge, and they gave the following suggestions:

  • Ask them what problems they’re having and then show them the solution by doing it for them in C++ style. (Stroustrup)
  • Set a personal example of increased productivity. (Alexandrescu)
  • Show them compiler generated assembly output comparing the “void *”  C-style code with a more expressive, less error-prone, more readable C++ equivalent. Odds are that the compiler-optimized C++ code will be much shorter than the hand-crafted C code. (STL)

Bjarne Stroustrup seemed especially frustrated at the pervasiveness of “void *” mindset. As a professor at Texas A&M, he said that as people come out of high school, most of them want to write games and they’ve convinced themselves and each other that, beyond a shadow of a doubt, “void *” is as fast as one can get. That’s exacerbated by the fact that many professors and “greybeards” still code in the type unsafe, barely readable, and error prone “void *” way.

I can sympathize with Bjarne and the panel. When I made the transition from C to C++, it took me what-seemed-like forever to “graduate” from arrays and naked pointers to containers and smart pointers and algorithms. Luckily, I did it in spite of myself. I can’t even remember the last time I used “void *” in any of the code I wrote.

  1. April 29, 2012 at 2:46 am

    People still use C++ ? Like, wow. :{

    • April 29, 2012 at 7:34 am

      Yepp. There are a few of us neanderthals still around.

    • lujz
      August 25, 2013 at 12:15 am

      What do you use?

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: