Reports from the spring conference C ++ Russia 2018

    From April 19 to April 21 in St. Petersburg, the C ++ Russia 2018 conference was held. From year to year, organization and holding becomes one level higher, which is good news. Thanks to the permanent organizer of C ++ Russia Sergey Platonov for his contribution to the development of this area.

    Master classes were scheduled for April 19, which, unfortunately, we could not attend, and 20-21 the main program of the conference was held, in which we participated with great interest. Sergey sermpHe did a lot of work and attracted several great foreign speakers as speakers. The first day of the conference was opened by Jon Kalb, the organizer of CppCon and the author of the book C ++ Today: The Beast is Back. The second day began with a report by Daveed Vandevoorde, a member of the standardization committee, one of the authors of the book C ++ Templates: The Complete Guide. In the epicenter of attention was Andrei Alexandrescu, who, after his report on exceptions, at one point gathered a whole crowd of people who wanted to get an autograph and make a joint photo. For the first time, a Herb Sutter report was broadcast on Skype telling about the Spaceship operator for C ++ 20.

    Although the conference was already held more than 3 months ago, the video ( full playlist) it is laid out just now, so it's time to refresh your memories and immerse yourself in the amazing possibilities of C ++.

    Jon Kalb. C++ Today: The Beast is Back

    This talk covers why engineers looking for performance choose C++. Jon presents an historical perspective of C++ focusing on what's going on in the C++ community right now and where the language and its user base is heading. With a renewed interest in performance for both data centers and mobile devices, and the success of open source software libraries, C++ is back and it is hot. This talk explains why C++ is most software engineers' go-to language for performance. You will receive a rough historical sketch that puts C++ in perspective and covers its popularity ups and downs.

    Arno Schödl. From Iterators To Ranges

    Pairs of iterators are ubiquitous throughout the C++ library. It is generally accepted that combining such a pair into a single entity usually termed Range delivers more concise and readable code. Defining the precise semantics of such Range concept proves surprisingly tricky, however. Theoretical considerations conflict with practical ones. Some design goals are mutually incompatible altogether.

    Jonathan Boccara. 105 STL Algorithms in Less Than an Hour

    We are all aware that we should know the STL algorithms. Including them in our designs allows us to make our code more expressive and more robust. And sometimes, in a spectacular way.

    But do you know your STL algorithms?

    In this talk, the author presents 105 algorithms that the STL currently has, including those added in C++11 and C++17. But more than just a listing, the point of this talk is to present the different groups of algorithms, the patterns they form in the STL, and how the algorithms relate together.

    This kind of big picture is the best way to actually remember them all, and constitute a toolbox chock-full of ways to make our code more expressive and more robust.

    Viktor Kirilov. Interactive C++ Compilation (REPL): The Lean Way

    Ever wanted to modify some value or execute some statement while your C++ program is running just to test something out — not trivial or possible with a debugger? Scripting languages have a REPL (read-eval-print-loop). The closest thing C++ has is cling (developed by researchers at CERN) but it is built on top of LLVM and is very cumbersome to set up. RCRL (Read-Compile-Run-Loop) is a demo project showcasing an innovative approach to doing runtime C++ compilation in a platform and compiler agnostic way which can be easily embedded. In this presentation, it is shown how to use it, how it works and how it can be modified and integrated into any application and workflow.

    Victor Ciura. Enough string_view to hang ourselves

    Wouldn't it be nice if we had a standard C++ type to represent strings? Oh, wait… we do: std::string. Wouldn't it be nice if we could use that standard type throughout our whole application/project? Well… we can't! Unless we're writing a console app or a service. But, if we're writing an app with GUI or interacting with modern OS APIs, chances are that we'll need to deal with at least one other non-standard C++ string type. Depending on the platform and project, it may be CString from MFC or ATL, Platform::String from WinRT, QString from Qt, wxString from wxWidgets, etc. Oh, let's not forget our old friend const char*, better yet const wchar_t* for the C family of APIs…

    So we ended up with two string types in our codebase. OK, that's manageable: we stick with std::string for all platform independent code and convert back-and-forth to the other XString when interacting with system APIs or GUI code. We'll make some unnecessary copies when crossing this bridge and we'll end up with some funny looking functions juggling two types of strings; but that's glue code, anyway… right?

    It's a good plan… until our project grows and we accumulate lots of string utilities and algorithms. Do we restrict those algorithmic goodies to std::string? Do we fallback on the common denominator const char* and lose the type/memory safety of our C++ type? Is C++17 std::string_view the answer to all our string problems?

    The author tries to explore the options, together, with a case study on a 15 year old Windows application: Advanced Installer ( — an actively developed C++ project, modernized to C++17, thanks to clang-tidy and «Clang Power Tools» (

    Andrei Alexandrescu. Expect the expected

    Writing code that is resilient upon errors has always been a pain point in all languages. Exceptions are the politically correct means to signal errors in C++, but many applications still resort to error codes for reasons related to ease of understanding, ease of handling errors locally, and efficiency of generated code.

    This talk shows how a variety of theoretical and practical artifacts can be combined together to address error codes and exceptions in one wholesome, simple package. The generic type Expected can be used for both local (error-code-style) and centralized (exception-style) manners, drawing from the strengths of each.

    Borislav Stanimirov. DynaMix: A New Take on Polymorphism

    Software with very complex business logic, such as games, CAD systems, and enterprise systems, often needs to compose and modify objects at runtime — for example to add or override a method in an existing object. Standard C++ has rigid types which are defined at compile time and make this hard. On the other hand, languages with dynamic types like lua, Python, and JavaScript make this very easy. Therefore, to keep the code readable and maintainable, and accomplish complex business logic requirements, many projects use such languages alongside C++. Some drawbacks of this approach include the added complexity in a language binding layer, the performance loss from using an interpreted language, and the inevitable code duplication for many small utility functionalities.

    DynaMix is a library which attempts to remove, or at least greatly reduce, the need for a separate scripting language by allowing the users to compose and modify polymorphic objects at runtime in C++. This talk elaborates on this problem and introduces the library and its key features to potential users or people who might benefit form the approach with an annotated example and a small demo.

    Mikhail Matrosov. Versatile C ++ applied

    In C++, you can solve a single task in a multiple ways. The author picks an actual task from production, and investigate how it can be solved with a number of tools that C++ provides: STL containers, boost.range, C++20 ranges, coroutines. He also compares API constraints and performance of different solutions, and how they can be easily converted from one to another if the code is well-structured. During the way the author also explores applications of some useful C++17 features like constexpr if, selection statements with initializer, std::not_fn, etc. Special attention is payed to topic — standard algorithms.

    Alexander Granin. Functional approach to Software Transactional Memory

    Parallel programming is a very multifaceted and deep topic. For dozens of years of research, a huge number of approaches, practices and tools have been developed, but we can hardly believe that C ++ has kept up with these trends. Starting with the C ++ standard 11, concepts such as std :: thread, std :: atomic, std :: future, std :: mutex were introduced, and in the future it is expected that coroutines, an asynchronous computing model, will be added. Well, these are all interesting things to learn, but the talk in the report will deal with a completely different idea.

    Software Transactional Memory (STM) - the concept of a transactionally variable data model - has existed for a long time and has a number of implementations for all languages. With the help of STM, you express your data model, and run it to change in several streams, competitively, while you do not need to worry about synchronization of streams, about the valid state of data, about locks. STM will do everything for you. It sounds very good, but not all STM libraries are equally useful. Traditional imperative STMs are very complex, subject to non-trivial multithreaded bugs, and difficult to use. On the other hand, in the functional programming world, the concept of combinatorial STM has long existed, in which transactions are composable building blocks from which you build higher-level transactions. The combinatorial approach to STM makes it possible to express a competitive data model more flexibly, clearly and reliably. Parallel programming can also be enjoyable!

    In the report, the author will talk about the features of the combinatorial STM, how to use it, and how it can be implemented in C ++ 17.

    Vadim Vinnik. Collection Processing. Single essence, multiple manifestations

    Along the whole history of programming, sequential elementwise processing of various kinds of collections has been and still is one of the most common practical tasks. Internal representation of the collections, as well as the algorithm used to fetch subsequent elements, may vary in a very wide range: array, linked list, tree, hash table, file et al. However, behind the variety of idioms, standard library functions, ad-hoc solutions, one can reveal the essence that remains invariant for that whole class of tasks. This talk aims to show a step-by-step transition from algorithms based on explicit description of actions over individual elements towards high-level, declarative processing tools that treat a collection as an entity and adequately reveal the logic of the domain.

    Dmitry Banshchikov. Shared libraries without external dependencies

    The author will tell about his experience in developing an antivirus engine in C ++ as a shared library. A unique feature is the absence of any external dependencies (runtime C ++ or C). This whole bunch is built around using the custom toolchain on GCC for a special target, which is used by libc newlib for the same target, on top of which libstdc ++ is built. Accordingly, the shared library is built through a custom toolchain with custom libgcc_s, libc, libcstdc ++ (changes only in the assembly). All interaction with the runtime is done through the shared library ABI. Thus, inside the library, it is possible to use a fully-fledged modern C ++ without restrictions (RTTI, exceptions, iostream, etc), which goes into libstdc ++ libc (newlib) | l ibgcc-abi. A similar approach was tested on GCC / newlib / libstdc ++ for Linux, and clang / newlib / libc ++ for MacOS. The report may be of interest to those who want to use C ++ in shared libraries, but cannot afford it due to external dependencies.

    Ilya Shishkov. How to teach the C ++ language: the experience of creating courses on Coursera

    Over the past year and a half, the author has led the creation of a specialization on Coursera on modern C ++. The specialization will consist of five courses, two of which are already running, and one more is almost ready.

    The report will tell:

    • what problems can be encountered in working on courses (for example, after 3 months of work, the developers threw out all the materials and started anew)
    • how the program of courses is formed and why it is this way (for example, why the word “pointer” did not sound in the first two courses even once)

    In addition, during the work on the specialization a set of principles was developed, which are applicable in everyday work:

    • in the process of integrating a new employee into the project
    • during code review
    • when hiring

    Therefore, the author does not just want to tell you how they are doing specialization, but also tries to shift the experience gained to everyday tasks.

    Ivan Ponomarev. Crash reports Android NDK

    It's not a secret that C / C ++ development places much higher demands on the quality of the code than Java development. The probability of making a fatal mistake is much higher. At the same time, collecting information about such errors is a non-trivial task even for experienced programmers.

    The first part of the report will briefly review the existing developments: how the built-in Android debugger works, what solutions already exist. The second part is devoted to the story of how it works “under the hood”: how to get the processor status at the time of the error, how to unwind the call stack, how to find the line numbers in the source code. An overview of such stack promotion libraries as libcorkscrew, libunwind, libunwindstack will be given.

    The report will be of interest to both Android developers, whose applications use NDK, and everyone else to expand their horizons.

    Fedor Short. Memory is the perfect abstraction

    int * ptr = new int;
    * ptr = 42;
    delete ptr;

    What actually happens when these 3 lines of code are executed? We will look inside the memory allocator, operating system and modern hardware to give an exhaustive answer to this question.

    Alexey Salmin. Memory Management Tips & Tricks

    In 2017, the issue of choosing an allocator in C ++ does not lose its relevance. A new method has been added to the standard to select a local allocator for containers (std :: pmr), global tcmalloc and jemalloc continue to evolve, as do the kernel interfaces on which they rely. This report is devoted to the “bottom floor” of this design: the features of mmap and madvise in the Linux kernel and the influence of these features on the performance of the allocators.

    Herb Sutter. New in C++20: The spaceship operator

    The new spaceship was recently adopted as a language feature for C++20. In this talk, the designer and author of the spaceship proposal gives an overview of the feature, discusses its motivation and design, and walks through examples of how to use it. He gives particular emphasis to how the feature makes C++ code cleaner to write and read, faster by avoiding redundant work, and more robust by avoiding several important but subtle pitfalls in the more brittle code we previously had to write by hand without this feature.

    Anastasia Kazakova. Debugging C ++ Code, Without Running and Compiling

    When you look at patterns, reflection, code generation at the compilation stage, metaclasses, there is a feeling that C ++ set itself the task of “hiding” the final code from the developer as much as possible. And the nontrivial use of the preprocessor (and numerous branches) can make the program's sequence of actions very non-obvious. Of course, these approaches save developers from endless copy-paste and repeating similar parts of the code base, but they require more advanced support in development tools.

    Is it possible to debug the code without continuously restarting it, without a debugger, and even without simply compiling the entire codebase? Is it possible to find errors in code that cannot be built or run on a local machine? There is! Integrated Development Environments (IDEs) have extensive knowledge and understanding of custom code, and they can provide the appropriate tools.

    This report will show you how to “debug” macro substitutions nested by typedef, understand the types of variables (which are often “hidden” in modern C ++), debug different branches of the preprocessor or operator overloads, and much more with the help of truly intelligent IDE. Some of the features are already available in CLion and ReSharper C ++, and some are just interesting ideas for the future that would be interesting to discuss with the audience.

    Evgeny Lukyanets. Docker build using Conan

    You can move the C ++ project assembly inside the docker container, instead of installing the necessary libraries and dependencies into the host system, you can either install them directly into the docker image (for example, Cuda), or install them using the C ++ manager of the Conan libraries (for example, Boost). This results in an isolated controlled (and each time the same) environment for the assembly, in which the Conan cache can be plugged in, so different projects using the same libraries will use the same assemblies. It also eliminates the dependence of the assembly on the Linux distribution, in which the project is assembled, the main thing is that you can run Docker on this distribution.

    Denis Panin. Practical metaprogramming: writing a heterogeneous hash table

    During the talk, we will write a small library of working with std :: tuple. With the help of this library we will make a compile-time heterogeneous hash table. Next - on its basis, we will write a small RPC framework, using the fact that we do not have type erasure.

    There will be a lot of constexpr-calculations, templates and new features of C ++ 17 (specifically, if constexpr).

    Dmitry Sokolov. Kodogeneratsiya as reflection for the poor

    Reflection is often needed to generalize the serialization algorithms. Implementation of various protocols, work with databases. To solve such problems, we have written the homebrew IDL compiler for generating C ++ structures and a library for interacting with the result. Protobuf with pedals and whether it was worth it.

    Daveed Vandevoorde. Reflective Metaprogramming in C++

    Some time ago, the C++ standardization committee created a subgroup «SG-7» to explore how to add reflection capabilities to the language. More recently, that group has added «metaprogramming» to its plate and made some significant decisions regarding the shape of the eventual solution. In this talk the author looks at the past that brought us here and examine a possible path for C++'s first-class support of «reflective metaprogramming».

    Dietmar Kühl. Concept Based Testing

    With concepts being added to the next revision of C++ it is expected that new concepts get defined. Each concept defines a set of operations used by generic code. One such use could be a generic test verifying that all parts of a concept are defined and checking generic interactions between a concept's operations. Ideally, such a test even works with classes only partially modelling a concept to guide the implementation of classes.

    This presentation doesn't use the actual concept extensions but shows how generic tests can be created using features of C++17. For the generic tests the detection idiom and constexpr if are used to determine availability of required operations and gracefully dealing with the abseence of operations. The generic tests should be able to cover basics of classes modelling a concept. Obviously, specific behaviour for classes will still require corresponding tests.

    Simon Brand. Modern C++ Parallelism from CPU to GPU

    Parallel programming can be used to take advantage of multi-core and heterogeneous architectures and can significantly increase the performance of software. Modern C++ has gone a long way to making parallel programming easier and more accessible; providing both high-level and low-level abstractions. C++17 takes this further by providing high level parallel algorithms, and much more is expected in C++20. This talk gives an overview of the current parallelism utilities available, and looks to the future of how GPUs and heterogeneous systems can be supported through new standard library features and other standards like SYCL.

    Andrey Karpov. Effective C ++ (Myers has nothing to do with it :)

    The C ++ language and the infrastructure around it continues to actively develop, which makes this language one of the most effective tools at present. I would like to highlight three factors that make the C ++ language so attractive now.

    • The first: innovations in the standard language, allowing to write effective code.
    • Second: the maturity of development tools and increase the speed of project assembly.
    • Third: mature support tools, allowing you to control the quality of the code and other aspects of the project life cycle.

    This report is an ode to the C ++ programming language!

    Ivan Puzyrevsky. Asynchrony in programming

    In the development of high-load multi-threaded or distributed applications, one can increasingly hear conversations about asynchronous code, including speculation about the need (no need) to take into account asynchrony in the code, clarity (incomprehensibility) of asynchronous code, its effectiveness (inefficiency). In this report, we will try to dive deeper into the subject area: analyze what asynchrony is; when it arises; how does it affect the code we write and the programming language we use. We will try to figure out what the futures & promises are about, let's talk a little about the corutines and actors. Let's touch on JavaScript and operating systems. The purpose of the report is to make more obvious the trade-offs that arise with a particular approach to developing multi-threaded or distributed software.

    Pavel Bulatov. Switching to WebAssembly: Is the game worth the candle?

    The report will discuss the current state of WebAssembly with respect to real products. We will tell you about our experience in porting an application, what problems arose and how we solved them.

    Topics will be covered:

    • Standard support across platforms and browsers.
    • Performance and build size in comparison with asm.js.
    • Interaction with the browser.
    • Build kreshy with the user.
    • VM features.

    Dmitry Kozhevnikov. CMake pitfalls and where they live

    The CMake build system is gradually becoming the de facto standard for cross-platform C ++ programming. However, it is often subject to fair criticism, including for inconvenient scripting language, outdated documentation and for the fact that the same tasks can be performed in different ways, while it is difficult to understand which one is more correct in a particular situation. . The author will tell:

    • frequent popular anti-patterns and why they are bad
    • at what levels of abstraction does CMake work, and when do they “flow”,
    • What is Modern CMake and what are its advantages?
    • how to localize and debug problems in CMake-scripts (including rather exotic tools).

    Sergey Shambir. When procedural C ++ is good

    The pure architecture of the project, simple abstractions on each layer are the dream of any team. For the realization of this dream, many object-oriented techniques have been invented. Being carried away by OOP, developers forget to monitor the cleanliness of the code at the junction of C and C ++. It is here that the procedural style will help bring order, build convenient and safe abstractions that are easily intertwined with the object-oriented code of the project. We will find out:

    • why it is generally necessary to isolate the API in the C language (such as winapi, POSIX, SQLite, OpenGL, OpenSSL)
    • why does the PLO work poorly in this matter
    • how to write a layer of abstraction over the C-style API
    • how to deal with callbacks, error handling and resource management to make traditionally complex and tangled code understandable even for a junior

    Yevgeny Zuev. Semantic API for C ++ programs

    His professional interests are the semantics of programming languages, the design and implementation of PL compilers and other language-oriented tools. Among the most significant achievements are participation in such projects as the creation of a full standard C ++ compiler (Interstron, Moscow, 2000), the implementation of the Zonnon compiler for .NET (ETH Zurich, 2005), the implementation of the Swift compiler prototype for the Tizen platform ( Samsung Research Institute, Moscow, 2015).

    Ivan Čukić. 2020: A void_t odyssey

    C++ has always had a powerful meta-programming sub-language which allowed library developers to perform magical feats like static introspection to achieve polymorhpic execution without inheritance. The problem was that the syntax was awkward and unnecessarily verbose which made learning meta-programming a daunting task.

    With the recent improvements to the standard, and with the features planned for C++20, meta-programming has become much easier, and meta-programs became easier to understand and reason about.

    In this talk, the author presents a few modern techniques of meta-programming, with main focus on the magical void_t meta-function.

    Evgeny Okhotnikov. Actors in C ++: was it worth it?

    The author of the report has been responsible for the development of the SObjectizer framework Open-Source for 16 years. It is one of the few living and developing cross-platform actor frameworks for C ++. Development of SObjectizer began in 2002, when C ++ was among the most popular and widely used programming languages. Since then, C ++ has changed a lot, and the attitude towards C ++ has changed even more. The report will discuss how these changes affected the development of the tool with a 16-year history and how easy and convenient it was to make such a tool for the C ++ language. And whether it was necessary to make such a tool for C ++ in general.

    Rainer Grimm. Best Practices for Concurrency in Modern C++

    With the standardisation of C++11, we got in C++ a multithreading library and a memory model. The library has the basic building blocks such as atomics, threads, tasks, locks, and condition variables. The memory model provides guarantees for the thread-safe usage of this basic building blocks.

    Seven years later, we have a lot of best practices to apply multithreading and the memory model in a safe way. The author's talk is precisely about these best practices to general rules for concurrency, special rules for the multithreading library, and special rules for the memory model. The focus of this best practices is far beyond C++.

    Alexey Malov. Experience of using modern C ++ in the development of desktop applications

    The talk will be about C ++ tools and Boost and STL libraries, as well as architectural approaches to building GUI applications, which we used in developing a tool for creating video lessons.

    • The practice of using the pattern Model-View-Presenter
    • Document Lifecycle Management
    • File storage on smart pointers

    Sergey Vasiliev. Static analysis: looking for bugs ... and vulnerabilities?

    News about the next vulnerability found regularly surface here and there. The collateral losses of $ are usually colossal. Therefore, instead of fixing vulnerabilities, you should not allow them to appear.

    One way to deal with errors in code is to use static analysis. But how suitable is it for finding vulnerabilities? And is there a big difference between simple errors and vulnerabilities in terms of code?

    We will discuss these questions in the course of the report, and at the same time we will talk about how to use static analysis so as to extract maximum benefit from it.


    From myself I want to draw your attention to the mini-intrigue around std :: string associated with the reports of my colleague Andrei Karpov. So, in order:

    1. Fragment of Andrei’s report (C ++ Russia 2016) “Private stories from code analyzer developers” from 30:05 - link .
    2. Easy trolling such as we are from Anton Polukhin (C ++ Russia 2017) in the report “How not to do it: C ++ cycling for professionals” from 2:00 - link .
    3. Andrey's story at the C ++ Russia 2018 conference that we are not dinosaurs and learn new things: “Effective C ++” from 12:21 - link .

    That's all! Have a nice acquaintance with the reports.

    Also popular now: