Using Monads in C++ to Solve Constraints: 1. The List Monad—Bartosz Milewski

Bartosz Milewski starts to explain Monads in his recent article.

Using Monads in C++ to Solve Constraints: 1. The List Monad

by Bartosz Milewski

From the article:

I am sometimes asked by C++ programmers to give an example of a problem that can’t be solved without monads. This is the wrong kind of question — it’s like asking if there is a problem that can’t be solved without for loops. Obviously, if your language supports a goto, you can live without for loops. What monads (and for loops) can do for you is to help you structure your code. The use of loops and if statements lets you convert spaghetti code into structured code. Similarly, the use of monads lets you convert imperative code into declarative code. These are the kind of transformations that make code easier to write, understand, maintain, and generalize.

So here’s a problem that you may get as an interview question. It’s a small problem, so the advantages of various approaches might not be immediately obvious, especially if you’ve been trained all your life in imperative programming, and you are seeing monads for the first time.

CppCon 2014 Defensive Programming Done Right, Part I—John Lakos

While we wait for CppCon 2015 in September, we’re featuring videos of some of the 100+ talks from CppCon 2014. Here is today’s feature:

Defensive Programming Done Right, Part I

by John Lakos

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

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.

CppCon 2014 How you can make a Boost C++ Library—Robert Ramey

While we wait for CppCon 2015 in September, we’re featuring videos of some of the 100+ talks from CppCon 2014. Here is today’s feature:

How you can make a Boost C++ Library

by Robert Ramey

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

The purpose of this presentation is to encourage C++ programmers to create and submit new quality C++ libraries to Boost.

Premises: a) C++ needs more quality libraries b) There are many C++ programmers who would like to contribute libraries but they are discouraged by the amount of effort and associated heartache.

Methodology: Walk through the website from the point of view of a C++ library contributor. It will address issues related to requirements, suggested tools, user feedback, library promotion. It will assume that the attendee is an intermediate to advanced C++ programmer with an idea for a library.

Large-scale cluster management at Google with Borg—Abhishek Verma et al.

borg.PNGC++ is used to power much of our civilization, but is often unheralded, so people always underestimate how widely it is used. We think many C++ developers like to know about major/cool systems written in C++, so from time to time we'll post an article like this. Enjoy:

Large-scale cluster management at Google with Borg

by Abhishek Verma et al.

From the article:

All components of Borg are written in C++...

A cluster usually hosts one large cell and may have a few smaller-scale test or special-purpose cells. We assiduously avoid any single point of failure. Our median cell size is about 10 k machines after excluding test cells; some are much larger...

CppCast Episode 10: SQLpp11 with Roland Bock

Episode 10 of CppCast the only podcast by C++ developers for C++ developers. In this episode Rob and Jason are joined by Roland Bock to talk about sqlpp11 and some of Rolands ideas for the future of C++.

CppCast Episode 10: SQLpp11 with Roland Bock

by Rob Irving and Jason Turner

About the interviewee:

Roland Bock is Head of Development at PPRO Financial Ltd, an FCA regulated e-Money institute offering prepaid MasterCard card programs and comprehensive financial solutions for international electronic payment transactions. Since 2008 he has been using SQL in C++. Being unhappy with the string-based approach of most SQL libraries, he decided to do something about it and developed a type-safe EDSL for SQL in C++: sqlpp11. In his spare time Roland is working on sqlpp11, experimenting with Concepts Lite and trying to write a proposal about compile-time configurable names for C++ standard. He lives and codes in Munich (Germany).

Boost Your Productivity with Modern C++

A new training with Peter Gottschling, Head of the German ISO C++ Delegation in June:

Boost Your Productivity with Modern C++

by Peter Gottschling

From the Course Description:

Based on many years of programming experience—e.g., developing the Matrix Template Library—I want to share my C++ knowledge with you. This experience is spiced with the accumulated proficiency of Bjarne Stroustrup, Herb Sutter, Scott Meyer, and other C++ experts whose advises also originate from programming experience.
Target Audience

Modern C++ Workshop at Polyglot Unconference 2015

This workshop is an introduction to new features and best practices of modern C++. We will delve into the core of C++ and all new features introduced in C++11 and C++14.

Introduction to Modern C++ Workshop happening at Polyglot Unconference 2015 in Vancouver, BC.

by Alejandro Isaza

From the workshop summary:

  • Write C++ code using the latest language features while following the best practices
  • Use third-party libraries and frameworks



CppCon 2014 Optimization Tips - Mo’ Hustle Mo’ Problems—Andrei Alexandrescu

While we wait for CppCon 2015 in September, we’re featuring videos of some of the 100+ talks from CppCon 2014. Here is today’s feature:

Optimization Tips - Mo' Hustle Mo' Problems

by Andrei Alexandrescu

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

Reasonably-written C++ code will be naturally fast. This is to C++'s excellent low-penalty abstractions and a memory model close to the machine.

However, a large category of applications have no boundaries on desired speed, meaning there's no point of diminishing returns in making code faster. Better speed means less power consumed for the same work, more workload with the same data center expense, better features for the end user, more features for machine learning, better analytics, and more.

Optimizing has always been an art, and in particular optimizing C++ on contemporary hardware has become a task of formidable complexity. This is because modern hardware has a few peculiarities about it that are not sufficiently understood and explored. This talk discusses a few such effects, and guides the attendee on how to navigate design and implementation options in search for better performance.

Breaking Changes in Visual C++

From the Visual C++ Porting and Upgrading Guide (referring to Visual Studio 2015 RC):

Breaking Changes in Visual C++

by Microsoft

From the article:

When you upgrade to a new version of the Visual C++ compiler, you might encounter compilation and/or runtime errors in code that previously compiled and ran correctly...

C++ Today: The Beast Is Back—Jon Kalb and Gašper Ažman

A new O'Reilly book from two well-known C++ community experts, freely available courtesy of the makers of CLion:

C++ Today: The Beast Is Back

by Jon Kalb and Gašper Ažman

From the announcement:

Now that software development is shifting primarily toward mobile and cloud computing, the venerable C++ programming language is returning to the dominant position it held during the object-oriented boom of the 1990s. In this O′Reilly report, you′ll learn why C++ is once again the preferred choice across several diverse industries...

Table of contents:


1. The Nature of the Beast

C++: What’s It Good For?

2. The Origin Story

C: Portable Assembler
C with High-Level Abstractions
The ’90s: The OOP Boom, and a Beast Is Born
The 2000s: Java, the Web, and the Beast Nods Off

3. The Beast Wakes

Technology Evolution: Performance Still Matters
Language Evolution: Modernizing C++
Tools Evolution: The Clang Toolkit
Library Evolution: The Open Source Advantage

4. The Beast Roars Back

Standard C++ Foundation
Boost: A Library and Organization
Conferences and Groups

5. Digging Deep on Modern C++

Type Inference: Auto and Decltype
How Move Semantics Support Value-Semantic and Functional Programming
No More Output Parameters
Inner Functions with Lambdas
Lambdas as a Scope with a Return Value

6. The Future of C++

Setting the Standard
Never Make Predictions, Especially About the Future