In The Community: Meet James McNellis

This is the second installment in the “In The Community” series spotlighting members of the C++ / developer community. Today we meet James McNellis, a developer on the Visual C++ team and community guy.

James is a developer on the Visual C++ team, which he joined this past July.  As a member of this team, he builds awesome C++ libraries and is currently doing work on the C Runtime Libraries (CRT).  Prior to joining the Visual C++ team, he was a developer on the Blend for Visual Studio team where he worked on the XAML designer for Windows Store apps.  James has been programming in C++ for 15 years and has worked on a wide variety of projects, from embedded robotics software to 3-D simulation.

In his “free” time, James is a prolific contributor on Stack Overflow and is working on an open-source native reflection library for the Windows Runtime, implemented in modern C++, called CxxReflect.  He tweets at @JamesMcNellis.

Why C++?

I love C++ because it makes it easy to build large software systems that are correct, maintainable, extensible, and high-quality.  It enables high levels of abstraction without sacrificing performance.  It has one of the most magnificent language features ever—templates—which, among many other wonderful uses, allow us to build generic components that are as efficient as any type-specific components that we might consider building instead.  It has first rate support for value semantics, which make programs easier to reason about.  There are C++ toolchains for most major platforms, and with a bit of work it’s possible to build libraries that will run practically anywhere.  Flexibility, performance, and portability are all extremely important.

What do you like most about C++?

Object lifetimes are deterministic, there are rules specifying exactly when objects are created and destroyed, and those rules apply consistently to all objects of all types.  I think these fundamental language rules are largely the reason why C++ is so awesome.  They enable resources to be managed uniformly (via RAII) and make it possible to build complex systems easily by aggregating small, composable parts.  They make it easier to build programs that exhibit correct behavior, in both nominal and error cases.

I took the C++ object model for granted until I spent time working on a large system implemented in C#, which does not have deterministic object lifetimes.  C++ has many splendid features, but the object model with deterministic object lifetimes was the thing I missed most.

Least?

The syntax of the language.  C++ inherits a bucket of syntactic oddities from C (e.g., the declarator syntax), then adds some quirky syntax “features” of its own (e.g. the most vexing parse).  None of these issues are particularly horrible on their own, but it’s aggravating because there are so many quirks and corner cases.  C++ with a simpler, cleaner, easier to learn and teach, and more consistent syntax would be a truly wonderful language.  But then, of course, such a language wouldn’t be C++ .

What advice would you give new C++ developers?

Don’t make the mistake of assuming that C++ is just like [insert language with which you are already experienced].  Idiomatic, correct, well-written C++ is quite different from similarly high-quality code written in other popular languages, including Java and C#.  C++ best practices are quite different from best practices in other languages.  The best way to learn to program in C++ is to obtain a good book and learn how to write idiomatic C++ from the start.  You’ll save a lot of time and avoid much pain and suffering.

Do you have any favorite C++ favorite authors or books?

I recommend C++ Primer 5th ed. by Lippman, Lajoie, and Moo as both an introductory text and a reference text for C++.  It presents C++ with an emphasis on modern C++ style, covers much of C++11, and discusses many best practices.  (Of particular note:  dynamic allocation using ‘new’ isn’t discussed until page 449, and one of the first statements is that it is “notoriously tricky.”)

There are many other very good C++ books.  The Definitive C++ Book Guide and List on Stack Overflow lists the best of them.

Where are your favorite technical places on the Web?

Stack Overflow, of course!  Stack Overflow isn’t just a great place to find answers when you’re trying to solve a problem.  Reading through answers to C++ questions, even if those questions aren’t immediately relevant to what you’re currently working on, is a great way to learn about parts of the language with which you’re not familiar.  There are many C++ experts and enthusiasts who contribute on Stack Overflow and there’s a ton of very useful, very readable information.  You’d have a hard time finding a better community of friendly, helpful experts.  As a starting point, consider perusing the C++ FAQ, containing frequently asked questions with great answers.

I also encourage everyone to contribute answers.  I’ve been using C++ for a while, but I didn’t really, truly start learning the language until I started contributing on Stack Overflow.  There’s a big difference between being able to write code in a language and being able to explain clearly and concisely how and why that code works (or doesn’t work).  Helping others by helping to answer their questions is quite rewarding and is a great learning experience.

What question should I have asked?

What is your favorite color?

And the answer?

Chartreuse (#7fff00)

Thanks James!