August 2015

Overload 128 is now available

ACCU’s Overload journal of August 2015 is out. It contains C++ related articles.

Overload 128

From the journal:

Don’t Design for Performance Until It’s Too Late: People claim optimisation can cause unreadable code. Andy Balaam argues good performance should be at the core of code design. by Andy Balaam

Template Programming Compile Time String Functions: Practising old exercises in new ways can keep you sharp. Nick Weatherhead demonstrates some well-known code katas using C++ compile time tricks. by Nick Weatherhead

C++ concepts support merged into gcc trunk

An evolution of gcc occured:

C++ concepts support merged into gcc trunk

From the article:

I've been banging on the concepts branch for the past month after Andrew told me it was about ready to merge, fixing bugs and streamlining things there to get familiar with the code while I could still look at it as a whole rather than mixed in with the rest of the compiler. But I think I've reached diminishing returns and so I'm going to go ahead and merge it into the trunk...

CppCon 2015 Keynote #2: Better Code -- Data Structures (Sean Parent)

cppcon-040.PNGThe CppCon 2015 program is already chock-full of strong topics and speakers, with a handful of the big talks still to be announced. Here's another of those...

From the announcement:

Keynote: Sean Parent

We are announcing the second keynote for next month’s conference.

Sean Parent, principal scientist at Adobe, will be continuing his “Better Code” keynote series from last year’s C++Now keynote (on complete types) with “Better Code: Data Structures.”

Abstract: The standard library containers are often both misused and underused. Instead of creating new containers, applications are often structured with incidental data structures composed of objects referencing other object. This talk looks at some of the ways the standard containers can be better utilized and how creating (or using non-standard library) containers can greatly simplify code. The goal is no incidental data structures.

Speakers bio: Sean Parent is a principal scientist and software architect for Adobe’s mobile digital imaging group. Sean has been at Adobe since 1993 when he joined as a senior engineer working on Photoshop and later managed Adobe’s Software Technology Lab. In 2009 Sean spent a year at Google working on Chrome OS before returning to Adobe. From 1988 through 1993 Sean worked at Apple, where he was part of the system software team that developed the technologies allowing Apple’s successful transition to PowerPC.

CppCon 2015 Program Highlights, 1 of N

The CppCon 2015 conference program has been posted for the upcoming September conference. We've received requests that the program continue to be posted in "bite-sized" posts, a few sessions at a time, to make the 100+ sessions easier to absorb, so here is another set of talks. This series of posts will conclude once the entire conference program has been posted in this way.

 

There is lots -- lots -- of existing C++ code. How can you effectively bring existing C++ code forward to C++11/14? How can you upgrade your coding styles and conventions? How can tools help you and your team to use correct modern C++ in your production projects?

The following interrelated CppCon 2015 talks tackle these issues and more.

In this post:

  • Keynote: Writing Good C++14 (Bjarne Stroustrup)
  • Plenary: Writing Good C++14 By Default (Herb Sutter)
  • A Few Good Types: Evolving array_view and string_view For Safe C++ Code (Neil MacIntosh)
  • More than Lint: Modern Static Analysis For C++ (Neil MacIntosh)

 

Keynote: Writing Good C++14

How do we use C++14 to make our code better, rather than just different? How do we do so on a grand scale, rather than just for exceptional programmers? We need guidelines to help us progress from older styles, such as “C with Classes”, C, “pure OO”, etc. We need articulated rules to save us from each having to discover them for ourselves. Ideally, they should be machine-checkable, yet adjustable to serve specific needs.

In this talk, I describe a style of guidelines that can be deployed to help most C++ programmers. There could not be a single complete set of rules for everybody, but we are developing a set of rules for most C++ use. This core can be augmented with rules for specific application domains such as embedded systems and systems with stringent security requirements. The rules are prescriptive rather than merely sets of prohibitions, and about much more than code layout. I describe what the rules currently cover (e.g., interfaces, functions, resource management, and pointers). I describe tools and a few simple classes that can be used to support the guidelines.

The core guidelines and a checker tool reference implementation will be open source projects freely available on all major platforms (initially, GCC, Clang, and Microsoft).

Use, comment, and contribute!

Speaker: Bjarne Stroustrup, Managing Director, Morgan Stanley. Stroustrup is the creator and original implementer of C++. He is also a Visiting Professor in Computer Science at Columbia University, a Distinguished Research Professor in Computer Science at Texas A&M University, and continues to actively participate and lead language evolution in the ISO C++ committee.

 

Writing Good C++14 By Default

Modern C++ is clean, safe, and fast. It continues to deliver better and simpler features than were previously available. How can we help most C++ programmers get the improved features by default, so that our code is better by upgrading to take full advantage of modern C++?

This talk continues from Bjarne Stroustrup’s Monday keynote to describe how the open C++ core guidelines project is the cornerstone of a broader effort to promote modern C++. Using the same cross-platform effort Stroustrup described, this talk shows how to enable programmers write production-quality C++ code that is, among other benefits, type-safe and memory-safe by default -- free of most classes of type errors, bounds errors, and leak/dangling errors -- and still exemplary, efficient, and fully modern C++.

Background reading: Bjarne Stroustrup’s 2005 “SELL” paper, “A rationale for semantically enhanced library languages," is important background for this talk.

Speaker: Herb Sutter, author and chair of the ISO C++ committee.

 

A Few Good Types: Evolving array_view and string_view for Safe C++ Code

The Library Fundamentals TS already contains a string_view type, and possibly soon an array_view type. These are important and should be used pervasively as function parameters, especially instead of (pointer, length) pairs which are generally unsafe. They offer additional benefits in the form of decoupling: allowing functions to be specified in terms of high-level views rather than references to specific, concrete string and container types which bind both caller and callee to a specific implementation detail. As a specific example, using string_view in function signatures allows them to be called with any of the endless proliferation of string types that exist in codebases today (std::string, CStringT, char*, BSTR, HSTRING, MyString etc).

We can and should evolve these types further as a key part of achieving memory safety for C++ code.

This example-driven talk shares our experience with preventing defects in large-scale commercial C++ codebases by applying modestly evolved versions of the proposed array_view and string_view types, plus a small number of related types such as not_null. Adopting these types enables simpler and safer code that eliminates important classes of defects by construction. The types are carefully designed to have usually exactly zero space and time overhead over the current unsafe idioms they replace, so as to leave no valid performance reason against adopting them. Using these types enables high-quality static analysis, and is allowing Microsoft to fully replace non-standard and non-portable annotation systems for type and memory safety in our own code bases.

We believe this approach is generally applicable to code at all levels, from application code down to the most performance-sensitive systems code. An open source reference implementation of the types that supports all major compilers and platforms will be available on GitHub.

More than Lint: Modern Static Analysis for C++

Static analysis tools have the potential to significantly improve programmer productivity as well as the safety, reliability and efficiency of the code they write. Modern static analysis has moved well beyond the mental model people often have based on “lint”: just finding simple “typos” or “thinkos”. Static analysis can find subtle, complex bugs early, identify opportunities to improve performance, encourage consistent style and appropriate usage of libraries and APIs.

This talk will look at the different purposes static analysis tools can be used to meet all these different goals. It will present specific examples from our experience working with sophisticated analysis tools on large, commercial codebases. The talk will also present a specific implementation of a modern static analysis toolkit for C++. This toolkit is being used in a number of different contexts: to provide tool-based enforcement of new coding guidelines and rules, to migrate people to modern C++ coding idioms and to find important security and reliability defects. One notable example of its use is to implement the checker for enforcement of a core set of coding guidelines that are presented in Bjarne Stroustrup’s keynote address.

Some of the tools described in the talk will be available for download as a Community Technology Preview in the latter part of 2015.

Speaker: Neil MacIntosh, Microsoft. Neil is the lead for the C++ static analysis frameworks used widely within Microsoft, including PREfix, PREfast, and ESPx, and is currently involved on making them work better with portable C++14 code rather than nonstandard annotations.

The Dos and Don'ts of Multithreading -- Hubert Matthews

Hubert Matthews talked at the this year's ACCU conference in Bristol with lot's of examples and detailed insight about:

The Dos and Don'ts of Multithreading

by Hubert Matthews

From the conference's schedule:

Multithreading is a popular subject and we've all been led to believe that we need to write threaded programs as single-threaded performance hits a ceiling. However, multithreading is no panacea and may cause more problems than it solves. This talk, suitable for programmers of any level and language, seeks to describe some of these problems and also how to avoid them through appropriate design choices.

Large-Scale Scientific C++ For Casual Coders: Why You (Should) Care -- Axel Naumann

Axel Naumann talked in his this year's keynote at the ACCU conference in Bristol about

Large-Scale Scientific C++ For Casual Coders: Why You (Should) Care

by Axel Naumann

From the ACCU's schedule:

This keynote will introduce the use of C++ for storing and analyzing petabytes of C++ objects at CERN, and more generally in High Energy Physics. Many hundreds of developers, including physicists with limited software skills, have contributed to a code base of > 50 million lines of code that has a lifetime of more than 40 years. Axel will talk about the approach taken in order to provide robust and efficient code, including how novices 'conquer' giant interface worlds. He will present a few of the 'tasty' projects that have proven to be useful for people who don't smash particles on a daily basis, for instance their C++ interpreter and a massively scalable web-based file system.

A generic context menu class for Qt

An unplanned 5th entry in my series on writing applications in C++ using Qt and boost:

A generic context menu class for Qt

by Jens Weller

From the article:

I didn't plan to write a second post on menus. But a reply on twitter caused me to over think my code I presented yesterday. Its not an very important part, so that I moved on once it did run. So, the simple question, why I would not connect the menus to a slot instead of using a switch was a good one. It would restructure the code, and slots are also callable from the outside world, while the switch buries the code inside a method...

CppCast Episode 21: VS2015 and the Universal CRT with James McNellis

Episode 21 of CppCast the only podcast by C++ developers for C++ developers. In this episode Rob and Jason are joined by James McNellis to discuss new features for C++ developers in Visual Studio 2015 and changes made to the C runtime.

CppCast Episode 21: VS2015 and the Universal CRT with James McNellis

by Rob Irving and Jason Turner

About the interviewee:

James McNellis is a senior engineer on the Visual C++ team at Microsoft, where he works on C++ libraries.  He’s spent the past three years working on a major redesign and refactoring of the Visual C++ C Runtime, which culminated in the release of the Universal CRT with Windows 10 and  Visual Studio 2015.  He occasionally speaks at C++ conferences and was at one time a prolific C++ contributor on Stack Overflow.