Feeds:
Posts
Comments

Yesterday I posted three of my proposed talks for CppCon. These are the ones I’ve given publicly before, but they’re not retreads – all are fresh and up to date, with refreshed or new material.

But I’ve also proposed two brand new talks – titles and abstracts are below.

Note: The CppCon program committee will be considering the talk proposals to come up with a balanced program, so it’s possible that not all of these will be in the final program, but I have high hopes for most of these…

CppCon is building well. I don’t know how many talks there will be in the end as this depends on the program committee including in part how long the accepted talks are, but FWIW my talks are submissions #41 and #126-129. There’s some really great stuff in the pipeline on all sorts of topics of interest to C++ developers, not just about the language itself but also tools, specific domains, and lots of cool stuff that will be shown for the first time at CppCon.

I look forward to seeing many of you at CppCon this fall! If we have the right equipment in the main auditorium, there might even be a wind of change…

 

GC for C++, and C++ for GC: “Right” and “Wrong” Ways to Add Garbage Collection to C++ (1 to 2 hours)

“Garbage collection is essential to modern programming!” “Garbage collection is silly, who needs it!”

As is usual with extremes, both of these statements are wrong. Garbage collection (GC) is not needed for most C++ programs; we’re very happy with determinism and smart pointers, and GC is absolutely penalizing when overused, especially as a default (or, shudder, only) memory allocator. However, the truth is that GC is also important to certain high-performance and highly-concurrent data structures, because it helps solve advanced lock-free problems like the ABA problem better than workarounds like hazard pointers.

This talk presents thoughts about how GC can be added well to C++, directly complementing (not competing with) C++’s existing strengths and demonstrating why, as Stroustrup says, “C++ is the best language for garbage collection.”

 

Addressing C++’s #1 Problem: Defining a C++ ABI (1 hour)

“Why can’t I share C++ libraries even between my own internal teams without using the identical compiler and switch settings?” “Why are operating system APIs written in unsafe C, instead of C++?” “Why can’t I use std::string in a public shared library interface; it’s the C++ string, isn’t it?!”

These and more perennial questions are caused by the same underlying problem: For various historical reasons, C++ does not have a standard binary interface, or ABI. Partial solutions exist, from the Itanium ABI which addresses only the language and only on some platforms, to COM and CORBA which do both less and far more than is needed.

It is deeply ironic that there actually is a way to write an API in C++ so that it has a de facto stable binary ABI on every platform: extern “C”.

This session describes current work driven by the presenter to develop a standard C++ ABI. This does not mean having identical binaries on all platforms. It does mean tackling all of the above problems, including directly addressing the #1 valid reason to use C instead of C++, and removing a major obstacle to sharing binary C++ libraries in a modern way.

I’ve been watching the talk proposals rolling in for CppCon, now well over 100 of them, and I was already looking forward to this conference but I just keep getting more jazzed.

For my part, I’ve proposed five talks, with between 5 and 10 hours of material. I thought I’d share some of them here.

Note: The CppCon program committee will be considering the talk proposals to come up with a balanced program, so it’s possible that not all of these will be in the final program, but I have high hopes for most of these…

Below are three of the five proposed talks. These are the ones I’ve given publicly before, but they’re not retreads – all are fresh and up to date, with refreshed or new material.

I’ll cover the other two new talks in a separate post soon.

I hope to see you at CppCon this fall to talk about these and many more interesting topics by scores of great speakers!

 

Lock-Free Programming – or, How to Juggle Razor Blades (~2 hours)

Example-driven talk on how to design and write lock-free algorithms and data structures using C++ atomic<> – something that can look deceptively simple, but contains very deep topics. (Important note: This is not the same as my “atomic<> Weapons” talk; that talk was about the “what they are and why” of the C++ memory model and atomics, and did not cover how to actually use atomics to implement highly concurrent algorithms and data structures.)

This talk is about the “how to use them successfully” part of atomics, including:

  • Best practices and style for using atomic<>s
  • Three or more examples, including lock-free mail slots and iterations of a lock-free linked list, all in portable Standard C++
  • Defining and applying the different levels of “lock-freedom” (wait-free, lock-free, obstruction-free) to develop highly concurrent algorithms and data structures
  • Explaining and applying key concepts including especially: linearizability; trading off concurrency vs. promptness; and trading off concurrency vs. throughput/utilization
  • Demonstrating and solving the ABA problem, with clean and simple code – that’s right, did you know that in C++11 you can solve this without relying on esoterica like double-wide CAS (which isn’t always available) or hazard pointers (which are deeply complex) or garbage collection (which isn’t in the C++ standard… yet)?

 

Standardization Update: C++14 and the Seven Dwarfs (1 hour)

Standardization has accelerated: By the time we meet at CppCon, C++14 might already be ratified. But that’s only one of eight (so far) work items now in flight. In this session, I’ll give a brief summary of the new features coming in C++14 itself, and then a tour of the seven (7) near-term separate Technical Specifications already underway – think of these as the “C++14 wave” of deliverables.

The ISO C++ committee has transitioned to a “decoupled” model where updated versions of the standard are published more frequently, while at the same time major pieces of work can progress and be published independently from the Standard itself and delivered asynchronously in the form of Technical Specifications (TS’s) that are separate from the main Standard and can later be incorporated into the Standard. Come to this session to see how this is helping both the standard and C++ compiler implementations near you stay current with the latest in C++.

The topics covered will be:

  • C++14: What’s new in the new standard due this year
  • File System TS: Portable file system access
  • Library Fundamentals TS (small): string_view and optional<>
  • Array Extensions TS: Language and library dynamic arrays
  • Concepts Lite TS: Templates + constraints = ++usability and ++diagnostics
  • Concurrency TS: Nonblocking futures (.then, .when_*), executors, and (maybe) await
  • Parallelism TS: A whole new Parallel STL with both parallel and vector execution support
  • One of:
    – Networking TS (small): IP addresses, URIs, byte ordering
    – Transactional Memory TS: Language and library extensions for transactional memory instead of mutexes for many kinds of concurrency control

This session will present an overview of each set of features, what it looks like and how to use it, and why it’s important for the standard and for your own portable C++ code.

 

Modern C++ Style: Idioms of C++11/14 (1 to 3 hours)

This session will cover modern and current C++ style, focusing on C++14. It will demonstrate how major features and idioms from C++98 are now entirely replaced or subsumed and should be used no more; how other major features and idioms have been dramatically improved to the point where your code is cleaner and safer and you’ll even think in a different style; and how pervasive styles as common as variable declarations are changed forever, and not just for style but for serious technical safety and efficiency benefits. For one thing, you’ll never look at auto the same way again – and if hearing that makes you worry, worry not, just attend the session to dig deep into the good reasons for the new reality.

Why C++14? Two reasons: First, it really does “complete C++11″ with small but important consistency features like generic lambdas and make_unique that let us teach modern C++ style with fewer “except for” footnotes. Second, C++14 “is” C++ for the next several years and it’s real; it is feature-complete and in the final stages of standardization, and more importantly we are already seeing near-complete conforming implementations becoming widely available around the same time C++14 is expected to be formally published.

C++14 is a small but important improvement on C++11 that really does complete the language. What this means is that we’re going to have a complete and simpler set of idioms and styles to learn and use.

Anubhav asked:

An interesting question has come up in our project while debating operator new as a class member function. Specifically, the question is about whether such a class should be allowed to be instantiated on stack. The understanding is that a class providing its own operator new would likely have special layout considerations which would not be met if the object of such a class is instantiated locally.

The class specific operator new is used when allocating on the heap, but objects can still be allocated on the stack. The only way I know to prevent an object from being instantiated on the stack is by forcing creation through a factory function that always allocates on the heap, for example:

#include <memory>

class X {
// make all ctors private
X();
X(const X&);
// and any other ctors go here

public:
// Factory function (or it could be a nonmember friend)
static auto make( /*…*/ ) { return std::unique_ptr<X>(new X( /*…*/ )); }

// the usual public member functions go here
};

int main()
{
X x; // error
auto x2 = X::make(); // ok
}

A lot of you have been asking me whether there will be some sort of C++ and Beyond in 2014. Also, over the past few years many of you have also asked me if there will ever be a C&B outside North America. I’m pleased to report that we are doing a ‘European Encore’ event reprising previous C&B material.

Today on the C&B blog, Scott announced that yes, there will be a “C++ and Beyond Road Show” in 2014… in Germany! Note that this is different from previous C&B’s because the purpose is to largely repeat the C&B 2013 program at an event in Europe, in order to make it accessible to people who were not able to fly to North America for previous C&Bs. So think of it as a “C&B Encore” or “C&B Greatest Hits Roadshow Edition.”

From the announcement:

You can think of this event as the C&B Road Show, because the organization is a little different from how we’ve done things in the past:

  • Most of the talks will be updated versions of the presentations we gave at C&B 2013. (See the schedule here.) If you were unable to attend C&B this past December, this is your chance to see what you missed.
  • A group dinner on the first day is included.
  • The schedule is a bit compressed, so some aspects of previous C&Bs are not present. These include group breakfasts and evening discussion sessions.

For this event, we’ve partnered with QA Systems, the same company I’ve worked with since 1999 on technical seminars in Europe. They’ll be handling registration and all other logistical and administrative aspects of the event. Consult their web page for C&B 2014 for all the details of this event.

This will be the only C&B in 2014, so we hope to see you in Stuttgart at the end of September for the first-ever C&B in Europe!

For those of you who have attended C&B before and others who’ve been asking me whether there will be a “regular” C++ and Beyond in North America this year with new material, the answer is not this year; we don’t do a new one every year, and we’re skipping this year. If you are looking for a C++ event in North America with new material, do check out CppCon on September 7-12 in the Seattle area – I am currently planning to create some new talks for CppCon, as well as to repeat some of my C&B talks there. I hear tell that Scott and Andrei might be there too, as well as dozens and dozens of our closest speaker friends.

I’m looking forward to seeing many of you at C&B Europe and CppCon this fall!

That was fast!

Tim just added this comment on the GotW #3 Solution blog post from last year:

Are you sure you can use auto in lambda like this?
I can not compile the code and I’m pretty sure auto does not work here.

If you mean auto as a lambda parameter type, such as

[](auto& s){ use(s); }

then yes, it’s (now) legal): That’s a new feature in currently-being-finalized C++14 standard, and it’s called “generic lambdas.” It means that the compiler-generated closure object’s

operator()

is a template, so you can call the same closure object multiple times with different types and get the templated operator stamped out for each set of types it’s called with.

Major compilers are now adding support for this. As of this writing, all of GCC, Clang, and Visual C++ have implemented the basic feature and you can get it in CTP/preview/alpha releases of each, such as GCC or Clang trunk, or Visual C++ November 2013 CTP. I can’t remember offhand which of those compilers have shipped an official release since adding it (VC++ has not) but they’ll all have it in their next released versions.

By the way, isn’t it wonderful that, for the first time in the history of C++, multiple major compilers are in pretty good sync like this, both with each other and with the standard? I think that’s awesome.

If you’re at Build in San Francisco tomorrow afternoon, I invite you to swing by and spend an hour with us in session 2-661:

Modern C++: What you need to know

by Herb Sutter

Build 2014, Room 2005
2:30-3:30 pm, Thursday April 3, 2014

If you’re new to C++, this talk is aimed directly at you. I was asked to give a “foundational talk” about C++, and I decided that meant I should focus on addressing two questions that I get a lot these days:

  • FAQ #1 (1-2 slides): When should I use C++ compared to another language – on all platforms in general, and on Microsoft platforms in particular?
  • FAQ #2 (lots of slides): What should I know about C++ if I’m a {Java|C#|JavaScript|Python|…} developer?

Even if you’re a seasoned C++ developer, there are some nuggets and data points in the middle of the talk that I think you will find useful in your own work, and I hope that the talk as a whole will be helpful to you in providing a way to explain C++’s value proposition and give (or link to) an answer when someone asks you FAQ #2.

I think it will be recorded, and will post a link here when the recording is available.

I look forward to seeing many of you there tomorrow afternoon.

Follow

Get every new post delivered to your Inbox.

Join 2,171 other followers