Archive

Posts Tagged ‘Herb Sutter’

Just As Fast, But Easier To Write

September 26, 2011 2 comments

I love watching Herb Sutter videos on C++. His passion and enthusiasm for the language is infectious. Like Scott Meyers, Herb always explains the “why” and “how” of a language feature in addition to the academically dry “what” .

In this talk, “Writing modern C++ code: how C++ has evolved over the years“,  Herb exhibits several side by side code snippets that clearly show much easier it is to write code in C++11 (relative to C++98) without sacrificing efficiency.

Here’s an example (which I hope isn’t too blurry) in which the C++11 code is shorter and obsoletes the need for writing an infamous”new/delete” pair.

Note how Herb uses the new auto, std::make_shared, std::shared_ptr, and anonymous lambda function features of C++11 to shorten the code and minimize the chance of making mistakes. In addition, Herb’s benchmarking tests showed that the C++11 code is actually faster than the C++98 equivalent. I don’t know about you, but I think this is pretty w00t!

I love paradoxes because they twist the logical mind into submission to the cosmos. Thus, I’m gonna leave you with this applicable quote (snipped from Herb’s presentation) by C++ expert and D language co-creator Andrei Alexandrescu:

Note: As a side bonus of watching the video, I found out that the Microsoft Parallel Patterns Library is now available for Linux (via Intel).

C++ Dudes To Follow

January 4, 2011 Leave a comment

If you’re a twit like me, and you also “do” C++, you might want to follow these people and resources on twitter:

They don’t tweet much, but when they do, they’re worth listening to. Do you know of any other C++ twitter resources that I should add to my list?

We’ve All Had Those Days

November 17, 2010 Leave a comment

OMG! Last night, when I was sittin’ near the fire in my dinner jacket, sippin’ my glass of cognac, smokin’ my pipe, pettin’ my dog, and intently reading  Sutter & Alexandrescu’s classic “C++ Coding Standards: 101 Rules, Guidelines, and Best Practices“, I came across this curious passage:

Can you remember a time when you wrote code that used the standard library (for example) and got mysterious and incomprehensible compiler errors? And you kept slightly rearranging your code and recompiling, and rearranging some more and compiling some more, until the mysterious compile errors went away, and then you happily continued on—with at best a faint nagging curiosity about why the compiler didn’t like the only-ever-so-slightly different arrangement of the code you wrote at first? We’ve all had those days…

What on earth are they talking about? That’s never happened to me. What about you?

C++ Naming Conventions

May 8, 2010 2 comments

For grins, I perused a few books written by several C++ mentors that I respect and admire. I was interested in the naming conventions that they personally use when writing code. Here are the results.

Scott Meyers (Effective C++):

class names – class PhoneBook {};

member function names – void addPhoneNumber(const std::string& pn);

member attribute names – std::string theAddress;

Note: no annotation to distinguish class member attributes from local function variables.

Bjarne Stroustrup (The C++ Programming Language):

I consider the CamelCodingStyle of identifiers “pug ugly” and strongly prefer underscore_style as cleaner and inherently more readable, and many people agree. On the other hand, many reasonable people disagree.

class names – class Phone_book {};

member function names – void add_phone_number(const std::string& pn);

member attribute names – std::string the_address;

Note: no annotation to distinguish class member attributes from local function variables.

Herb Sutter and Andrei Alexandrescu (C++ Coding Standards):

class names – class PhoneBook {};

member function names – void AddPhoneNumber(const std::string& pn);

member attribute names – std::string theAddress_;

Note: they use post-underscores to distinguish class member attributes from local function variables (int clientName_;  //is a class member)

When I’m not constrained by a specific naming standard, I use this one:

class names – class PhoneBook {};

member function names – void add_phone_number(const std::string& pn);

member attribute names – std::string the_address_;

Note: Like Herb & Andrei, I use post-underscores to distinguish class member attributes from local function variables (int client_name_; //is a class member).