QtWS15- Reactive programming and Qt, Ivan Cukic, KDE
Qt World Summit 2015, OCTOBER 5-7, BERLIN, GERMANY
Reactive programming and Qt:
Reactive programming is an emerging discipline which achieves concurrency using events-based programming. Today, It is mostly used for writing very scalable web services that can achieve high concurrency levels even on a single thread.
The concept is simple - make a system that is fully event-based, and look at events not as isolated instances, but as streams. When we have streams, we can manipulate them as if they were simple ranges. We can filter them, modify them, combine multiple streams into one etc.
Reactive programming is not only applicable to the web services, it can be used in any event-based environment. In our case, in normal Qt applications, to enrich the power of signals and slots.
The talk will consist of two parts. In the first part, ranges will be explained (through the boost.range library, and Eric Niebler's range library proposal for C++17). We will show that ranges, and range transformations are a natural extension to the library in STL, which allows writing more concise and safe code that deals with collection structures like lists, vectors or maps.
The second part will deal with what reactive streams are, and their relation to ranges. We will show how to create streams using Qt's signals and slots mechanism, how to manipulate them, and connect the transformed streams back to the UI or other application components.
We will show a multitude of examples of how this can make the code more composable, clean and more declarative.
The examples will require some prior C++11/14 knowledge, while the features needed from the forthcoming C++17 standard will be explained.