June 2014

Game Changer -- Tony DaSilva

A little more fodder for those still trying to get their management or team to adopt modern C++:

Game Changer

by Tony DaSilva

From the article:

Even though I’m a huge fan of the man, I was quite skeptical when I heard Bjarne Stroustrup enunciate: "C++ feels like a new language". Of course, Bjarne was talking about the improvements brought into the language by the C++11 standard.

Well, after writing C++11 production code for almost 2 years now (17 straight sprints to be exact), I’m no longer skeptical. ... It seems that the authors of the “High Integrity C++” coding standard agree with my assessment. ...

Modernizing Legacy C++ Code -- James McNellis

mcnellis-2014.PNGFrom Techdays 2014 the Netherlands:

Modernizing Legacy C++ Code

by James McNellis

In this session, James McNellis, a developer on the Visual C++ libraries team, will share his experience using elements of modern C++ to improve a large legacy code base. Learn how to apply principles of modern C++ to gradually improve the quality of legacy code and improve maintainability and debuggability

CMake 3.0.0 Released

A new major version of CMake, v3.0.0 has been released. CMake is a tool for cross platform C/C++ (and more) build poject configuration.

Version 3.0.0 contains many improvements. To get an idea of the recent changes, as well as the improvements of CMake over the last months and years, take a look at the following links:

 

EuroLLVM videos and slides now available

eurollvm-2014.PNGAll available videos are now posted from this April's EuroLLVM conference.

The conference included the following C++-related sesssions. Note that only the first two have video, all have slides or other materials.

 

Keynote: What's new in C++14, and how you can take advantage of it (slides) -- Marshall Clow

Portable Native Client. Fast, Secure, Simple: Pick Three. (slides) -- JF Bastien

clang-tidy - Lint-like checks and beyond (slides) -- Daniel Jasper

Refactoring a large C++ codebase using clang (slides) -- Nick Lewycky

Async Magic - std::async in C++ and its consequences for optimizations (slides) -- Tobias Rieger

Intel Clang-Based C++ Compiler (poster) -- Andrey Bokhanko

Clang as a C++ front-end for Frama-C and VeriFast (poster) -- Virgile Prevosto, Franck Védrine, Bart Jacobs and Gijs van Spauwen

IBM XL C/C++ 13.1 supports =default/=delete, constexpr, nullptr

XL C/C++ and AIX and Linux is now available:

XL C/C++ for AIX and Linux, V13.1 Now Released!

We're happy to announce the release of the XL C/C++ for AIX, V13.1 and XL C/C++ for Linux, V13.1 compilers!  The V13.1 release delivers POWER8 exploitation and new compiler and language features.

From the announcement details:

IBM® XL C/C++ for Linux™ is a standards-based, high performance C/C++ compiler with advanced optimizing features. XL C/C++ for Linux, V13.1 delivers a number of new features and enhancements:

  • Exploitation of the latest IBM POWER8™ architecture
  • Support for additional features in C11 and C++11, the current standards for the C and C++ programming languages
  • Partial support for the OpenMP 4.0 industry specification
  • Compile and runtime performance improvements
  • Additional performance options
  • New program diagnostics and error detection features

...

C++11 programming standard

C++11 is the latest standard for the C++ programming language, published as ISO/IEC 14882:2011. With V13.1, partial support for the C++11 standard continues with the implementation of the following features:

Defaulted and deleted functions

This feature introduces two new forms of function declarations to define explicitly defaulted functions and deleted functions. For the explicitly defaulted functions, the compiler generates the default implementations, which are more efficient than manually programmed implementations. The compiler disables the deleted functions to avoid calling unwanted functions.

You can use the -qlanglvl=defaultanddelete option to enable this feature.

Generalized constant expressions

The generalized constant expressions feature extends the set of expressions permitted within constant expressions. The implementation of this feature in XL C/C++ V12.1 was a partial implementation of what is defined in the C++11 standard. In this release, enhancements are made to support user-defined constexpr objects and constexpr pointers or references to constexpr functions and objects.

You can use the -qlanglvl=constexpr option to enable this feature.

The nullptr keyword

This feature introduces nullptr as a null pointer constant. The nullptr constant can be distinguished from integer 0 for overloaded functions. The constants of 0 and NULL are treated as the integer type for overloaded functions, whereas nullptr can be implicitly converted to only the pointer type, pointer-to-member type, and bool type.

You can use the -qlanglvl=nullptr option to enable this feature.

N4058: Atomic Smart Pointers -- Herb Sutter

A new WG21 paper is available. A copy is linked below, and the paper will also appear in the next normal WG21 mailing. If you are not a committee member, please use the comments section below or the std-proposals forum for public discussion.

Document number: N4058

Date: 2014-06-12

Atomic Smart Pointers

by Herb Sutter

Excerpt:

We encourage that modern C++ code should avoid all uses of owning raw pointers and explicit delete. Instead, programmers should use unique_ptr and shared_ptr (with weak_ptr), as this is known to lead to simpler and leak-free memory-safe code. This is especially important when lifetimes are unstructured or nondeterministic, which arises especially in concurrent code, and it has long been well-known that the smart pointers would be useful there; for an example, see [1].

Unfortunately, lock-free code is still mostly forced to use owning raw pointers. Our unique_ptr, shared_ptr, and weak_ptr would directly benefit lock-free code just as they do regular code (see next section), but they are not usable easily or at all in lock-free code because we do not support atomic<unique_ptr<T>>, atomic<shared_ptr<T>>, and atomic<weak_ptr<T>>.

...

If we had atomic<unique_ptr<T>> we could (and should) write the following equivalent code that is safer, no slower, and less error-prone because we can directly express the unique ownership semantics including ownership transfer:

atomic<unique_ptr<X>> p_root;
void producer() {
    auto temp = make_unique<X>();
    load_from_disk_and_store_in( *temp ); // build data structure
    p_root = move(temp);                  // atomically publish it
}
This righteous code should be supported...

CppCon Program Preview, 5 of N -- Boris Kolpackov

cppcon-086.PNG

More CppCon 2014 accepted talks have just been announced, below. For past announcements about the conference program, see also:

Early Bird registration is available until June 30.

 

CppCon Program Preview, 5 of N

by Boris Kolpackov

From the announcement:

Jeff Garland: “Rebuilding Boost Date-Time for C++11”
Kate Gregory and James McNellis: “Making C++ Code Beautiful”
Joel Falcou: “Costless Software Abstractions for Parallel Architectures”
Walter E. Brown: “Your Help Wanted: Language Proposals in Flight”
Jens Weller and Jon Kalb: “Founding C++ User Groups”

 

Jeff Garland: “Rebuilding Boost Date-Time for C++11"

Boost date_time is a widely used C++ library originally released in 2001 — including being the basis for elements of the chrono library in C++11. While the library interface has stayed stable for more than a decade, the world around it has changed with the standard library and language changing. It is time for the library to be rewritten to account for C++11. This lecture describes in detail the design decisions and changes to the library for C++11. More generally it describes elements of design for a small valuetype library. Many of these considerations involve new features of C++11 and how they should be used. This includes noexcept, move construction/assignment (R-values), constexpr, enum classes, and user defined literals. Attendees will learn about the design considerations and tradeoffs of using the new language features in their own work while getting a glimpse of boost date_time version 2.

Speaker’s bio: Jeff Garland has worked on many large-scale, distributed software projects over the past 25+ years. He’s a long time participant in the Boost and C++ community including developing Boost date_time, serving as a moderator and Boost steering committee member, co-authoring papers for the C++11 chrono library, and running the annual Library in a Week workshop at C++Now. Mr. Garland holds a Master’s degree in Computer Science from Arizona State University and a Bachelor of Science in Systems Engineering from the University of Arizona. He is a co-author of “Large Scale Software Architecture: A Practical Guide Using UML.”

 

Kate Gregory and James McNellis: “Making C++ Code Beautiful"

Ask a non-C++ developer what they think of C++ and they’ll give the language plenty of compliments: powerful, fast, flexible, and “the language for smart people”. But along with that you are likely to hear ugly, complicated, hard to read, and “the language for smart people”. Is it possible to write beautiful C++? Not arcanely elegant or wickedly compact, but readable, clear, expressive – beautiful! We say it is, and we want to show you how. In this session, you’ll see how to turn pages of “comic book characters swearing” into code you’ll be proud to call your own. By making your code express your intent, using the power of new language and library functionality, and leaving hard-to-read constructs out of your vocabulary, you can give your code a makeover that will stand the test of time.

Speakers’ bio: Kate Gregory has been using C++ since before Microsoft had a C++ compiler. She writes, mentors, codes, and leads projects, in both C++ and .NET, especially for Windows 7 and 8. Kate is a Microsoft Regional Director, a Visual C++ MVP, and has written over a dozen books (the most recent on C++ AMP for Microsoft Press) and speaks at conferences and user groups around the world. Kate develops courses on C++, Visual Studio, and Windows programming for Pluralsight, founded the East of Toronto .NET Users group, and is a member of adjunct faculty at Trent University in Peterborough.

James McNellis is a senior engineer on the Microsoft Visual C++ team, where he is responsible for the Visual C++ C Runtime (CRT) and C Standard Library implementation. He was previously a member of the Microsoft Expression Blend team, developing the XAML designer tools for Windows 8 apps. Prior to joining Microsoft in 2010, he spent several years working on real-time 3-D simulation and robotics projects in the defense industry. James is a prolific contributor on the Stack Overflow programming Q&A website and occasionally writes for the Visual C++ Team Blog.

 

Joel Falcou: “Costless Software Abstractions for Parallel Architectures"

Performing large, intensive or non-trivial computing on array-like data structures is one of the most common tasks in scientific computing, video game development and other fields. This matter of fact is backed up by the large number of tools, languages and libraries to perform such tasks. If we restrict ourselves to C++-based solutions, more than a dozen such libraries exist from BLAS/LAPACK C++ binding to template meta-programming-based Blitz++ or Eigen. Even if all of these libraries provide good performance or good abstraction, none of them seems to fit the need of so many different user types. Moreover, as parallel system complexity grows, the need to maintain all those components quickly becomes unwieldy. This talk explores various software design techniques, like Generative Programming, Meta Programming and Generic Programming, and their application to the implementation of a parallel computing librariy in such a way that abstraction and expressiveness are maximized while cost over efficiency is minimized. We’ll skim over various applications and see how they can benefit from such tools. We will conclude by discussing what lessons were learnt from this kind of implementation and how those lessons can translate into new directions for the language itself.

Speaker’s bio: Joel Falcou is an assistant professor at the University Paris-Sud and researcher at the Laboratoire de Recherche d’Informatique in Orsay, France. His research focuses on studying generative programming idioms and techniques to design tools for parallel software development. The two main parts of those works are: exploration of Embedded Domain Specific Language design for parallel computing on various architectures and the definition of a formal framework for reasoning about meta-programs and prove their compile-time correctness. Applications range from real-time image processing on embedded architectures to High Performance Computing on multi-core clusters. He is a MetaScale SAS scientific advisor. MetaScale mission is to assist businesses in the exploration and subsequently the mastery of high-performance computing systems.


Walter E. Brown: “Your Help Wanted: Language Proposals in Flight"

Want to collaborate in designing and implementing a new feature for C++17? Then this session is for you! After reviewing the process by which a new C++ feature enters the language, we will look at one or two of the speaker’s proposals that have received early favorable review from the standards committee, and that are awaiting sample implementation and/or formal wording. Attendee feedback will be solicited, and collaborators will be sought to help bring the proposal(s) to fruition.

Speaker’s bio: With broad experience in industry, academia, consulting, and research, Dr. Walter E. Brown has been a C++ programmer for over thirty years, joining the C++ standards effort in 2000. Among numerous other contributions, he is responsible for introducing such now-standard C++ library features as cbegin/cend and common_type as well as headers <random> and <ratio>, and has significantly impacted such core language features as alias templates, contextual conversions, and variable templates. He conceived and served as project editor for the International Standard on Special Mathematical Functions in C++. When not playing with his grandchildren, Dr. Brown is an Emeritus participant in the C++ standards process, with several more core and library proposals under consideration. He was recently appointed an associate project editor for the C++ standard itself.

 

Jens Weller and Jon Kalb: “Founding C++ User Groups"

In September “Meeting C++” will have existed for a little more than 2 years. Within those 2 years we went from a few C++ User Groups in Europe to many. We would like to talk about how to continue with founding even more C++ User Groups, but also sharing an overview of the already active User Groups in Europe and the US.

Speakers’ bio: Jens Weller has worked, since 2007, as a freelancer in C++, specialising in consulting, training and programming C++. He started with programming C++ back in 1998. He is an active member of the European C++ community and the founder of the Meeting C++ platform and conference. Jens is an active supporter of C++ user groups and blogs often about C++.

Jon has been programming in C++ for twenty years. He is currently doing this for Amazon’s A9.com. During the last two decades he has written C++ for Amazon, Apple, Dow Chemical, Intuit, Lotus, Microsoft, Netscape, Sun, Yahoo! and a number of companies that you’ve never heard of. He taught C++ at the graduate school at Golden Gate University for a couple of years and is currently chair of C++ Now (aka BoostCon) and of the Boost Steering Committee. Jon’s current interest is coming up to speed with C++11/14.

N4052: WG21 2014-06-06 Telecon Minutes -- Ville Voutilainen

A new WG21 paper is available. A copy is linked below, and the paper will also appear in the next normal WG21 mailing. If you are not a committee member, please use the comments section below or the std-proposals forum for public discussion.

Document number: N4052

Date: 2014-06-10

WG21 2014-06-06 Telecon Minutes

by Ville Voutilainen

Excerpt:

Teleconference information:

  Date:     2014-06-06

  Time:     8:00am N.Am. Pacific Time

  Duration: 2 hours

1. Opening and introductions

Sutter called the meeting to order 8:10 Pacific Time.

1.1 Roll call of participants

In attendance were: ...

CppCon Program Preview, 4 of N -- Boris Kolpackov

cppcon-093.PNG

More CppCon 2014 accepted talks have just been announced, below. For past announcements about the conference program, see also:

Super Early Bird registration has sold out, but Early Bird registration is available until June 30.

 

CppCon Program Preview, 4 of N

by Boris Kolpackov

From the announcement:

Alisdair Meredith: “What’s New In The C++14 Library”
Hartmut Kaiser: “Asynchronous Computation in C++”
Eric Niebler: “Range-ifying the STL”
Michael Wong: “What did C++ do for Transactional Memory?”
John Lakos: “Defensive Programming Done Right”

 

Alisdair Meredith: “What’s New In The C++14 Library"

After the grand expansion of the C++11 library, the extensions in C++14 are more modest, often tweaking and cleaning up existing components. Alisdair Meredith, the Library Working Group chair, walks through all these changes and additions, and a little insight into features that did not make the cut, and are expected to arrive in other Technical Specification before the next standard ships.

Speaker’s bio: Alisdair Meredith is a software developer at BloombergLP in New York, and the C++ Standard Committee Library Working Group chair. He has been an active member of the C++ committee for just over a decade, and by a lucky co-incidence his first meeting was the kick-off meeting for the project that would become C++11, and also fixed the contents of the original library TR. He is currently working on the BDE project, BloombergLP’s open source libraries that offer a foundation for C++ development, including a standard library implementation supporting the polymorphic allocator model proposed for standardization.

 

Hartmut Kaiser: “Asynchronous Computation in C++"

With the adoption of the new C++11 Standard the community sees a revival of interest in the language. This interest is also driven by the demands that new computer architectures and technologies are exerting on application developers and domain scientists. Especially the need for highly runtime adaptive algorithms and applications puts a great strain on our ability to efficiently write code which performs well and which scales satisfactory, as multi-core and multi-threading is the new modality of computation. We argue that new programming models have to be developed if we are to gain continued scalability of computations as we increase the size of our systems. These are programming models which work equally well for inter-node as well for intra-node use. With the degree of complexity and size increasing in new hardware architectures, applications are more and more hindered by the main bottlenecks in computation, namely starvation, latency, overheads, and waiting for contention resolution. We present HPX, which is a general purpose parallel C++ runtime system implementing a new model of computation -- ParalleX, that attempts to address those challenges. We show results from using HPX for leveraging and managing asynchrony, overlapping different phases of computation and communication, suggesting ways to seamlessly expose it to programmers in an easy to use way.

Speaker’s bio: Hartmut is a member of the faculty at the CS department at Louisiana State University (LSU) and a senior research scientist at LSU’s Center for Computation and Technology (CCT). He received his doctorate from the Technical University of Chemnitz (Germany) in 1988. He is probably best known through his involvement in open source software projects, mainly as the author of several C++ libraries he has contributed to Boost, which are in use by thousands of developers worldwide. His current research is focused on leading the STE||AR group at CCT working on the practical design and implementation of future execution models and programming methods. His research interests are focused on the complex interaction of compiler technologies, runtime systems, active libraries, and modern system’s architectures. His goal is to enable the creation of a new generation of scientific applications in powerful, though complex environments, such as high performance computing, distributed and grid computing, spatial information systems, and compiler technologies.

 

Eric Niebler: “Range-ifying the STL"

Range-based interfaces have many advantages over iterator-based ones. That explains why there are several range libraries to choose from. The standardization committee has been hard at work exploring the range library design space, and with luck we’ll have a best-of-breed solution ready for C++17. In this talk, I will present the work of several committee members, myself included, to put together a range library suitable for standardization. The work condenses the ideas from several popular range libraries, some new ideas, and much guidance from SG9, the Ranges Study Group. Come find out how we’re planning to make the STL easier to use, more powerful, and even more efficient than it already is, while keeping everything you already love.

Speaker’s bio: Eric Niebler is a true believer in the power of low-overhead abstraction and a shameless bit-twiddler, which explains his deep and abiding love of C++. Before setting out on his own as a freelancer, Eric worked as a consultant for BoostPro, a library developer for Visual C++, and a systems developer in Microsoft Research. He has authored 4 official Boost libraries, is on the Boost Steering Committee, and is a member of the C++ Standardization Committee. Eric lived for over 2 years years with no fixed address, slinging code from the coffee shops of the world. Buy him a beer and ask him about his life as a tech-nomad.

 

Michael Wong: “What did C++ do for Transactional Memory?"

SG5 is a Study Group within WG21 developing a promising new way to deal with mutable shared memory, that is expected to be more usable and scalable than current techniques based on atomics and mutexes. It promises to be as easy to use as coarse-grained locks, as scalable as fine-grained locks and yet remain composable. Find out where on the Gartner hype cycle lives Transactional Memory. Is it at the Peak of Inflated Expectations, Trough of Disillusionment, Slope of Enlightenment, or Plateau of Productivity? For that matter, just how soon will I be able to use it with the new Intel Haswell, and IBM Power Hardware, or is it one of those mirages where the closer you get to your hardware, the further it moves away. And is it true that one of the lead author of this TM proposal also wrote “Is it just a Research Toy?” This 60-90 minute advanced talk will cover the history of Transactional Memory, various lock elision and optimistic speculation techniques, the technical engine behind Transactional Memory, the recent research in its use cases, usability and performance data that supports its entry into the C++ Standard, and of course the latest details of the SG5 Technical Specification, including our effort at transactionalizing the C++ Standard Library.

Speaker’s bio: Michael Wong is the CEO of the OpenMP Corporation, a consortium of 26 member companies that hold the de-facto standard for parallel programming specification for C/C++ and FORTRAN. He is the IBM and Canadian Head of delegation to the C++ Standard, and Chair of the WG21 Transactional Memory group. He is the co-author of a number of C++/OpenMP/TM features and patents. He is the past C++ team lead to IBM´s XL C++ compiler, C compiler and has been designing C++ compilers for twenty years. Currently, he is leading the C++11 deployment as a senior technical lead for IBM. His current research interest is in the area of parallel programming, C++ benchmark performance, object model, generic programming and template metaprogramming. He is a frequent speaker at various technical conferences and serves on the Programming Committee of Boost, and IWOMP. He holds a B.Sc from University of Toronto, and a Masters in Mathematics from University of Waterloo.

 

John Lakos: “Defensive Programming Done Right“

In our component-based development methodology, each developer is responsible for ensuring that the software he or she creates is easy to understand and use, and not especially easy to misuse. One common form of misuse is to invoke a library function or method under circumstances where not all of its preconditions are satisfied, leading to undefined behavior. Contracts having undefined behavior are not necessarily undesirable, and (for many engineering reasons) are often optimal. Most would agree that a well-implemented library should do something other than silently continue when a pre-condition violation is detected, although these same folks might not agree on what specific action should be taken. Unfortunately, validating preconditions implies writing additional code that will execute at runtime. More code runs slower, and some would fairly argue that they should not be forced to pay for redundant runtime checks in the library software they use. Whether and to what extent library functions should validate their preconditions, and what should happen if a precondition violation is detected are questions that are best answered on an application by application basis -- i.e., by the owner of main. “Defensive Programming Done Right” makes it all possible. In this talk, we begin by reviewing the basic concepts of Design-By-Contract (DbC), and what we mean by the term “Defensive Programming” (DP). We then explore our overall approach to institutionalizing defensive programming in robust reusable library software such that each application can conveniently specify both the runtime budget (e.g., none, some, lots) for defensive checking, and also the specific action to be taken (e.g., abort, throw, spin) should a precondition violation occur. Along the way, we touch on how modern compilers and linkers work, binary compatibility, and the consequences of possibly violating the one-definition rule in mixed-mode builds. We conclude the talk by describing and then demonstrating our “negative testing” strategy (and supporting test apparatus) for readily verifying, in our component-level test drivers, that our defensive checks detect and report out-of-contract client use as intended. Actual source for the supporting utility components will be presented throughout the talk and made available afterwards.

Speaker’s bio: John Lakos, author of “Large Scale C++ Software Design,” serves at Bloomberg LP in New York City as a senior architect and mentor for C++ Software Development world-wide. He is also an active voting member of the C++ Standards Committee, Library Working Group. Previously, Dr. Lakos directed the design and development of infrastructure libraries for proprietary analytic financial applications at Bear Stearns. For 12 years prior, Dr. Lakos developed large frameworks and advanced ICCAD applications at Mentor Graphics, for which he holds multiple software patents. His academic credentials include a Ph.D. in Computer Science (’97) and an Sc.D. in Electrical Engineering (’89) from Columbia University. Dr. Lakos received his undergraduate degrees from MIT in Mathematics (’82) and Computer Science (’81). His next book, entitled “Large-Scale C++, Volume I: Process and Architecture,” is anticipated in 2014.