CppCast - stlab Concurrency

Episode Date: June 14, 2017

Rob and Jason are joined by Felix Petriconi to talk about his contributions to the stlab Concurrency library and the future of C++ futures. Felix Petriconi is working as professional programme...r since 1993 after he had finished his study of electrical engineering. He started his career as teacher for intellectually gifted children, freelance programmer among others in telecommunication and automotive projects. Since 2003 he is employed as programmer and development manager at the MeVis Medical Solutions AG in Bremen, Germany. He is part of a team that develops and maintains radiological medical devices. His focus is on C++ development, training of modern C++, and application performance tuning. He is a regular speaker at the C++ user group in Bremen and a member of the ACCU’s conference committee. News CppCon 2017 Keynote Speakers ACCU: Kotlin for C++ Developers Configure-cmake Beast v52 released, 3 weeks until Boost review Felix Petriconi @felixpetriconi Felix Petriconi's GitHub Links stlab concurrency stlab GitHub ACCU 2017 'The Art of Writing Reasonable Concurrent Code' ACCU 2016 'Leaving The Dark Side - Developing a C++ Based Medical Device' Sponsors Backtrace Hosts @robwirving @lefticus Better C++/Chicago

Transcript
Discussion (0)
Starting point is 00:00:00 This episode of CppCast is sponsored by JFrog, the universal artifact repository, including C++ binaries thanks to the integration of Conan, C, and C++ Package Manager. Start today at jfrog.com and conan.io. CppCast is also sponsored by CppCon, the annual week-long face-to-face gathering for the entire C++ community. Get your ticket now or submit a talk. The deadline to get in a submission is June 11th. Episode 105 of CppCast with guest Felix Petriconi, recorded June 14th, 2017. In this episode, we talk about the CppCon keynote speakers. Then we talk to Felix Petriconi. Felix talks to us about the ST Lab and Currency Library and the future of futures. Welcome to episode 105 of CppCast, the only podcast for C++ developers by C++ developers.
Starting point is 00:01:30 I'm your host, Rob Irving, joined by my co-host, Jason Turner. Jason, how are you doing today? I'm doing well, Rob. How are you doing? I'm doing pretty good. Are you getting ready for your Chicago training? Yes, lots of prep work to make sure I have everything ready for it. It's looking good excited anxious to do it july 12th 13th and 14th okay and you'll be selling tickets up until that day i guess there's no deadline for that actually there is a deadline for ticket sales of july
Starting point is 00:01:59 midnight at the end of july 10th because i have to give 24 hours notice to the building for the people who will be allowed entrance. Gotcha. Okay. So until July 10th, uh, there will be a link on the website if you're interested in going to that and you're in the Chicago area. Yeah. Okay. Well, at the top of every episode, I'd like to read a piece of feedback. Um, we actually got several different people, uh, contacting me on social media about this issue. This actually came after I thought the problem was fixed. But Jordan wrote in, guys, I love what you're doing, but something horrible happened to the website. I'm viewing on mobile and now everything is squished to the left side.
Starting point is 00:02:39 Oh, no. Yeah. So the website was completely messed up after last week's episode. The style was just missing, so everything was different sizes, and it was just kind of raw text on the page. I can go into what happened a little bit if we want to, but I did look at it on mobile, and mobile is still having some issues. I'll have to look into it a bit more this week to get it fully fixed. But this, in a nutshell, sums up why you do not do web development. Is that correct?
Starting point is 00:03:14 Yeah, I hate web development. It's horrible. Just for listeners who have some curiosity about it, we use a thing called DocPad to generate the website which is a node plugin and the reason i use that is just because when we started the web the podcast on the website i'm friends with another podcast host the host of the ms dev show and they had a website and i literally just forked their site and changed it up to look like what CppCast looks like now. And it was a really easy way to maintain the websites through a git page. So I just post a new show notes episode
Starting point is 00:03:53 file, and it runs something on Azure and website gets updated. It's a nice black box. It works really well up until last week. Up until one of the 10,000 dependencies that NPM installs changed something somewhere, possibly. Yeah, and I still don't know what happened because it was just a regular show. I didn't change anything with those dependencies or with the script or anything, but somehow it broke the SAS plugin that converts SAS to CSS was failing, and I wound up just committing the compiled version of the CSS file, and that has fixed the site since then. I bet we have at least one listener who actually understands those things that you just said, and if they are willing to debug why the mobile rendering doesn't look
Starting point is 00:04:41 correct, shout out to Rob. Absolutely, yeah. If you you have any experience with SAS, CSS, Node in general, and you feel like helping us out with improving the website, please feel free to reach out to us. And like Rob said, it's all on GitHub. Yeah, it's all on GitHub. You can put in a pull request to help me fix this or to modify show notes if you ever see an issue with a particular link that was
Starting point is 00:05:05 wrong in the show notes or something like that anyway we'd love to hear your thoughts about the show as well you can always reach out to us on facebook twitter or email us at feedback at cbgas.com and don't forget to leave us a review on itunes joining us today is felix petriconi felix is working as a professional programmer since 1993 after he had finished his study of electrical engineering. He started his career as a teacher for intellectually gifted children, freelance programmer among others in telecommunication and automotive projects. Since 2003, he's employed as a programmer and development manager at Mevis Medical Solutions AG in Bremen, Germany. He's part of a team that develops and maintains radiological medical
Starting point is 00:05:46 devices. His focus is on C++ development, training of modern C++, and application performance tuning. He's a regular speaker at the C++ user group in Bremen and a member of the ACCU's conference committee. Felix, welcome to the show. Thanks for having me. You know, it's great to have you on. At some point, we're going to have to dig into your radiological medical devices background, which I did not know when we were preparing for this interview. But I am curious, it sounds like you immediately went into programming after getting a degree in electrical engineering.
Starting point is 00:06:20 And I'm just curious if you considered computer engineering or computer science or how you made that transition or um it was during all the time at my at the university i was already working as a programmer at the university and it was some kind of natural way staying in that area and didn't go further into the electronics. So that's the way I went into the programming, and that's the way I'm still today, and I'm very lucky to be there. Okay. Well, Felix, we have a couple news articles to talk about. Feel free to comment on any of these,
Starting point is 00:06:58 and then we'll start talking to you about C++ futures, okay? Okay. Okay, so this first one is the 2017 keynote speakers have been announced for CppCon. We have Bjarne Stroustrup, of course, Herb Sutter, Lars Noll, who is the QT
Starting point is 00:07:17 or Qt Company CTO and the Project Chief Maintainer. And then, of course, we also have Matt Godbolt from Compiler Explorer. And I love this snippet from Matt's bio. project chief maintainer and then of course we also have matt godbolt from compiler explorer you know i love this snippet from matt's bio which one is that compiler explorer project has made his last name both a noun and a verb yeah that's great i think we just discussed that uh recently how people now refer to themselves as god bolting some code yeah god bolting some cold on god bolt yeah yes i remember yeah and um i think it's interesting that they're bringing uh lars
Starting point is 00:07:52 to keynote for uh for qt i think i remember having a conversation with someone at cbb con last year that uh cute or qt has kind of been kind of underrepresented at CppCon. It'd be nice to get some more speakers from that community. Yes, it's a heavily used framework, and it's pretty old. So it's already available for many, many years. And, for instance, we use it in our company, I think, since 15 years ago. Okay. Interesting. And do you have any idea, Jason,
Starting point is 00:08:26 what Matt's going to be actually talking about? Like, is he going to be talking about Compiler Explorer in his keynote, or is that unknown to you? I believe he has publicly stated to expect that Compiler Explorer will probably come up in his talk. Okay. Okay. Next thing we have is this article from from accu kotlin for c++ developers
Starting point is 00:08:49 um i just heard of kotlin uh just recently because i think android developers can now use kotlin instead of java um which is interesting kotlin apparently is a language that was started by JetBrains and this article is basically talking about why the language might appeal to C++ developers. When I first saw the headline I thought it might be more about
Starting point is 00:09:16 Kotlin to C++, kind of similar to what JNI does, but it's not really about that. It's more about Kotlin native, which is the language can now target Linux and OSX platforms directly without the JVM. With the help of LLVM.
Starting point is 00:09:38 Right. So, yeah, what did you guys think about Kotlin? Have you heard about it before? I heard about it, and we had a talk at the recent SSU about Kotlin, which I did not attend, but I knew that the language exists, but I've never tried it out.
Starting point is 00:10:00 And since I'm, from my job, mostly focused on Windows development, this way is, at least at the moment, not something I will look into it because it has no usage for me at the moment. offer for this native approach is i think mac linux ios and raspberry pi so windows is not there perhaps they added in the future i have seen the name kotlin but until i actually clicked on this news article to read the article i did not know it was a programming language for some reason it had completely just gone right over my head yeah well i i am interested to see you know if there is a good way to go from colin to c++ because it was just again what i thought the article was going to be about um because i know on android at least uh you know with java j9 c++ the android documentation kind of tells you like not to use it which is interesting yeah like they just don't think it's a great way to uh develop an application but you know
Starting point is 00:11:19 plenty of game developers and other applications do rely on J9 and that. So I'm wondering if Kotlin is going to have a better story for, for their C++ story. That's an interesting question. And I also am very curious about the actual quality of the code generated from LLVM. Yeah. Like I want to see this thing on compiler Explorer so that I can compare it to the C++ equivalents.
Starting point is 00:11:44 Yeah. Yes. Okay. Next article. Oh++ equivalents. Yeah. Yes. Okay. Next article. Oh, go ahead. Sorry. And one thing they stated as Kotlin for C++ developers, but as far as I read the code, it interacts with C libraries.
Starting point is 00:12:01 Or is it just the example? And so is it possible to use real C++ code and, for instance, to use inheritance or exceptions? This is something at least this article doesn't say. Right. Yeah, it doesn't mention anything like exceptions. But they also said it's meant to be a short article and you obviously can't cover everything.
Starting point is 00:12:26 So maybe we'll get a more detailed article. Maybe, yeah, we'll see. Yeah, and we do sometimes do interviews about other languages. We've done D in the past in Rust, so maybe it would make sense to do an interview with someone about Kotlin. I'll have to look into it a bit more. Yeah. Okay, next article is it a bit more. Yeah. Okay. Next article is actually
Starting point is 00:12:47 a GitHub page. It's configure CMake. This isn't something I'm too familiar with, but it seems like if you're more used to auto tools, but you're trying to switch to CMake, then this might be a helpful tool for you to
Starting point is 00:13:03 make that transition. Is that accurately representing it to you, Jason? What do you think? Yes. The Reddit comments were kind of funny, though, because the first couple of top-rated comments were like, wait, CMake was developed because we all hated autotools. So why do we want to make CMake look like autotools? But, you know whatever i can
Starting point is 00:13:26 see it's it's the syntax or some like a basic configure telling it what prefix you want it to install in and what packages you wanted to use is more succinct than trying to do that from the command line in cmake so i find it interesting i don't see myself using it but i find it interesting. I don't see myself using it, but I find it interesting. Felix, do you agree? Yes, I agree. So normally I don't do much configuration where the command like for CMake, I just have for different platforms, just for Windows, for Mac or for Linux, just specify the target and that's normally what I do.
Starting point is 00:14:08 Other things I don't do with CMake. But probably there are users that need more advanced features, and then it might be perhaps a good option for them to use it. Right. I know that CMake is the most popular cross-platform framework. Is AutoMake one of the second most, or AutoTools rather? AutoTools was never intended from the beginning to be cross-platform, really. When I first started doing cross-platform development,
Starting point is 00:14:44 it was extraordinarily painful to use AutoTools on Windows. From what I've heard, that is maybe a little bit better. But at this point, I don't see any reason to not use CMake because it is the de facto standard. You know it's going to work on every platform as you expect it to work. Okay. Okay. And this last article I have is Beast version 52
Starting point is 00:15:07 has been released. We talked about this with the author Vinny Falco a couple episodes ago. Beast is a cross-platform C++11 library for WebSockets and in a few weeks they're going to be going into the formal Beast or Boost review.
Starting point is 00:15:24 So if you want to help out the Beast Library in preparing documentation and testing the library to help prepare for the boost review process, Vinny would really appreciate the help. We got an interesting insight into what that boost review process was like
Starting point is 00:15:40 when we talked with Niall, and hopefully we'll get a follow-up. Hopefully Vinny has listened to the episode with Niall, so he knows what he's getting into. I followed a little bit the review itself on the Boost mailing list, and it was tough from my point of view. That's the reprocessed Niall is going into? Yeah, yes, exactly.
Starting point is 00:16:05 I think it's already over, I think, for a week about. And there was a heavy discussion between several aspects. At the moment, I think it's not accepted that what I received so far, what he has reported at the end. Oh, that's unfortunate. Yes. But it sounds like a very rigorous process yeah yes i don't know how many hundred emails uh the complete review took so it was uh really tough
Starting point is 00:16:35 what they did i know when he was talking to us it was already like 600 emails or something like that so it's a lot of work. Yes, exactly. Okay, so Felix, let's start talking a little bit about futures in C++ 11 and 14 before we get to the actual library that you've been working on. Do you want to tell us a little bit about your thoughts on the state of futures in C++ 11 and 14? Well, the futures were introduced in C++
Starting point is 00:17:06 11 as a higher level abstraction for asynchronous programming. But I think they're not very useful at the current state because they don't have continuations. So
Starting point is 00:17:21 there's only one way to see or to get a result is of a future is either by a blocking call on wait or get or one has to pull if the result is there so this is from my point of view not very practical. And then the continuations came with C++17, but at the moment they're in a TS. So I think there was time for a new approach. And that was the reason that I joined the project with Sean Parent.
Starting point is 00:18:02 So if you don't mind, you mentioned continuations, and I see that come up over and over again when people talk about C++11 futures and saying that this is where there's a big inadequacy. But I personally kind of have a hard time really visualizing what does a continuation
Starting point is 00:18:20 get me that just calling.get when I know that i want the value doesn't get me i guess uh well for instance um if you have an ui application and the user user triggers a certain operation and you want that the ui keeps or stays responsive And then after the calculation is done, then the UI shall be notified in a certain way that, for instance, the result is there for the user. And for this point, so then you could start a future, which actually does the calculations
Starting point is 00:19:00 in a different thread or in a thread pool. And after that, you tell it with a dot then, and then it should update to UI or give a notification to the user. And that's, for instance, one way to use a continuation or that you have, for instance, you need different calculations and the result of all these calculations
Starting point is 00:19:26 then should be joined into a new future so that a new calculation could start. So this is another way of using, for instance, for using the continuations. So does the continuation run on the same thread that the future ran on, or does it run on the main thread? Well, I think that's a problem.
Starting point is 00:19:55 I think in the standard, I have to admit that I don't know. It might run on the same, but it may be that it triggers a new thread. But this is something, a detail I'm not that very familiar with. I just know it how it is in our library. There you can specify where the continuation should run. Okay. Aside from continuations, are there other major deficiencies in C++11 futures that you want to point out before we go into the specifics of your library?
Starting point is 00:20:31 Yes. For instance, the futures as they are today defined C++11 and 14, and it is still the same with 17 TS that the futures are not copyable. So that means you cannot have a split. That means you cannot go continuation in two different directions. I think that's one big point. And the other one is that the futures doesn't support cancellation. So for instance, if you use a trigger to a certain operation and then a little later you say, well, I don't know.
Starting point is 00:21:11 I don't care about this result anymore. Then he wants to stop the operation. There's no way to do this. So there's no way that the function which is bind to the future, that this got cancelled. And I think this is a big problem, especially if you have a big chain of continuations. Then you have to calculate everything until the very end, even if you're not interested anymore. Then the interface for the futures is, from point of view not very nice at the moment the function takes a future of t as an argument if you just have one argument then it's not that
Starting point is 00:21:55 bad but for instance when you come to and when all so that takes several futures as an argument then this becomes a little bit ugly because then it is a future of tuples of futures. And if you see it in the code, I don't want to write such a thing. And another thing is that the futures at the moment don't support any kind of executors. So you just have a very limited interface at the moment don't support any kind of executors.
Starting point is 00:22:29 So you just have a very limited interface where the function should be executed. And I think one needs a way to specify where this function shall be executed. For instance, if we're talking about a continuation that later should update the UI, then this must run in the UI thread and not in a worker thread, because normally UIs have to be updated in the main loop. And so this is another problem.
Starting point is 00:23:04 And futures as they are today, for instance, they don't have joins. They come with 17, but they're still not there. So this is from my point of view the topics which I think could be improved.
Starting point is 00:23:18 I would kind of like to dig into the cancelling of futures because I was toying around with a Mandelbrot renderer and i wanted to do it using futures but cancel the futures while i'm zooming for example because i don't need it to render the whole thing if the user is requesting a zoom um so how how do your canceling how does that actually work in your futures? So if the future has not started, then it will never start.
Starting point is 00:23:55 So if you destruct the future, then the function will never be executed. Okay. If the future has already started, but then you delete it, then the function, of course, will continue until its end but no other continuation will be triggered. Okay. Is there any way to manually cancel a future except for deleting it? What do you mean with canceling?
Starting point is 00:24:22 I don't know. I was just thinking if you had like.cancel, I don't really know what the point would be, but I was just curious. Well, the future library that we developed, that has something that you can say, well, just reset and then it
Starting point is 00:24:39 cancels this execution, but the future is as in the standard standard they don't support it at all okay so before we get too much further maybe we should go back a little bit and tell the listeners about what the actual library is this is st labynchronous Library. Is that right? STLAB is the acronym for Software Technology Lab. It's a formerly organization which was run inside Adobe by Sean Parent. And I think, as I got it, I hope I got it correctly, during the time when Sean Parentrin ran this software technology lab,
Starting point is 00:25:29 a bunch of libraries were developed. And they are all open source, I think, for many years. And now at the moment, he is in the process of transferring all these libraries to this new platform, to this stlab.cc. Okay, and this is open to other contributors? So you've been contributing to the futures library that is part of stlab? Yes. So I think everybody is welcome to join the work at the moment. Most of the futures, all the future work was done by
Starting point is 00:26:05 Sean Perrin and myself. And just recently, another colleague from Adobe joined in the work, and at the moment, we are three developers in this library. So how would you compare your library, you've
Starting point is 00:26:21 compared it to the C++11 futures and the C++17 futures. How does it compare to what's in Boost? Boost is a little bit ahead of the standard libraries. So for certain things, which they are already available, for instance, joins are already there, I think, for some time. But all the other things which we think are deficiencies, they have the same problem. So they are not compatible. They don't support cancellation.
Starting point is 00:26:58 The interface is that complicated. And so that's from my point of view, they are quite similar. that complicated. From my point of view, they are quite similar. The Boost and the Standard Library are quite similar? Yes. What does the STLAB library provide that you think is worth looking at compared to C++11 Futures? We have Futures and we support compared to C++11 futures? So we have futures, and we support joins,
Starting point is 00:27:30 like when all, when any. We have continuations with.then, and we support a very important split, so that you can have a.then on the same future in two different directions. You can say on the same future,. do do a and dot then do b and this is something what the other libraries don't support. And then we have executors so they have a way to specify where the function should be executed. The default is that they are executed on
Starting point is 00:28:05 a thread pool and for the platforms which we provide, either we use the thread pool which comes with the operating system and for those that don't have a thread pool, we have a custom implementation of a thread pool.
Starting point is 00:28:22 But it's very easy to implement your own executor. You just have to implement a very simple interface and then you can have an executor so that your function is executed in, for instance, in a UI thread of the framework that you use, for instance. So that ends...
Starting point is 00:28:44 Oh, no, I'm sorry. Go ahead. Yes, and the third part, what the library provides are channels. So this is a persistent way of doing asynchronous operations. Future is just one shot. You just can say, send one value or a group of values through it,
Starting point is 00:29:04 and then you are done. Then the future is gone. And you can set up similar graphs with channels, and they persist, and you can send and send and send values through the graph. So it's some kind of a persistence way of calculation graph. So this is with some words most of what the library currently is doing.
Starting point is 00:29:33 The example you've given a couple times with continuations and executors being able to say, okay, when all this is done calculating, now update something on the UI's thread. I'm having a difficult time visualizing how you can go and say, now I want this to run on a completely different thread.
Starting point is 00:29:53 What does that look like from the programmer's perspective? So the executors are the first argument in a.then, for instance. And the standard is what we call a default executor. So that means that the function is executed on the thread pool, for instance, on lib dispatch, on Megawise, or on the window thread pool on the Windows environment. And if you, for instance, with very few lines of code,
Starting point is 00:30:28 you can write an executor for the Qt environment. So then you say that the function then should be executed on the Qt main loop so that you then can update their UI elements or whatever you want. So would it then basically push an event into the Qt event queue effectively?
Starting point is 00:30:58 Yes, it pushes in, well, in Qt you create a Q object, and then you transfer the ownership of this Q object into the main loop, and then you send an event to this object. And inside the main loop, the event is then propagated to this Q object, and there the event is then propagated to this queue object, and there the event is executed.
Starting point is 00:31:27 Okay. I can visualize it now. Thank you. I hope that wasn't too complicated. No, no, no, not at all. It took me a minute to catch up. I wanted to interrupt this discussion for just a moment to bring you a word from our sponsors. JFrog is the leading DevOps solution provider that gives engineers the freedom of choice. Manage and securely host your packages for any programming
Starting point is 00:31:49 language with Artifactory. With highly available registries based on-prem or in the cloud, and integrations with all major build and continuous integration tools,
Starting point is 00:31:57 Artifactory provides the only universal, automated, end-to-end solution from development to production. Artifactory and Bintre now provide full support for Conan's C and C++ package manager. Thank you. validated in the field to provide a flexible, production-ready solution, and with a growing community, Conan is the leading multi-platform C++ package manager. Together, JFrog and Conan provide an effective, modern,
Starting point is 00:32:31 and powerful solution for DevOps for the C++ ecosystem. If you want to learn more, go to jfrog.com and conan.io. So are the STLAB futures built from scratch or are they built on top of what C++11 gives us with futures? I think I have to go a little bit into the back. So Sean Parent needed for his project at Adobe a certain functionality and he could not get it
Starting point is 00:33:06 from the standard library. And so there he started to build Futures from the scratch. Okay. And that's where we then continued to work on. Okay. So it does not rely on the future
Starting point is 00:33:22 that the compiler provides? No. Okay okay so what exactly motivated you to get involved with this library st lab you know it's coming from adobe um but you decide to join it for what reason yes uh i think it was nearly about two years ago that you had Sean Parent on the show. And I listened to it and I liked the talks he did at CppCon and Going Native and so on. And so I listened
Starting point is 00:33:53 very carefully to what he said. And a little bit later I just dropped him a note and he was very welcome so that I could join the project. And so that's the way I got into it. And, well, it makes lots of fun to do it.
Starting point is 00:34:14 And I learned lots of things from him. And I think it's the best if you can learn something with fun. Right. What types of things did you learn while working on the Futures library? I mean, it sounds like a pretty powerful library. Yes.
Starting point is 00:34:34 It's quite of one way is how to design a library, to look for symmetry so that you can design your code around symmetry so that you don't do several things again. And other things in regard of multithreading, he has lots of experience
Starting point is 00:34:59 and that's what he taught me. Or he will, I wrote a push request and then he said, well, no, you cannot do this. This is the deadlock on the single threaded environment and so on. So this is a way I learned many things. Because he was working at that time in a very special environment where you just have single threaded code. And then that's very easy to have deadlocks and so he
Starting point is 00:35:30 was very keen on looking that nothing of these problems come into the library. Yeah, I've learned that it's interesting way to detect bugs in your code is to accidentally set up your VM with only one processor and then you get different and
Starting point is 00:35:45 interesting behavior from your multi-threaded code yes that's true were there any particularly difficult problems that you ran into that you might want to share um it took me quite
Starting point is 00:36:02 there was a certain problem in developing a join for the channels and there was one point it was a hard time for me to figure a solution for it because uh many approaches that i chose uh just uh worry were bad and didn't, and I had lots of runtime problems. And so at the end, the solution was I needed a variadic abstract base class. And then to implement the concrete, I had to implement the interface for these abstract base classes and to do it in a variadic way. And that's lots of template code that I learned at that point new from scratch.
Starting point is 00:37:00 I've never done this before. Sorry, I cannot explain it very good, but if one is interested, one should look into the library of the channels and then you see at a certain point the code looks complex. Needless to say, C++11 was pretty much a requirement for a code like this. But have you found yourself using
Starting point is 00:37:23 cutting-edge C++14 and C++17 kind of features working on it? Well, so what we use a lot of is auto return time deduction because it eases lots of writing of the code. But
Starting point is 00:37:41 at a certain point, I stepped into bugs in the Clang compiler because I think auto friend function there's a bug because they're not support to adjust cause an error, which is not understandable and GCC
Starting point is 00:37:57 and Visual compile it correctly so that's a way I had to find a workaround, but Stack Overflow was a good help at that point. Go ahead, Jason. I was just going to say, you know, you're doing interesting work when you hit compiler bugs. Yes.
Starting point is 00:38:20 And if one is at the beginning of template metaprogramming or going that deep, the first point is I'm looking at myself. What was my mistake again? And what did I do wrong? But at a certain point, you come to the point, it's not your fault, it's the compiler's fault. And yeah, that makes things more difficult.
Starting point is 00:38:46 Right. So STLAB, as you mentioned, is coming from Adobe. Sean Parent and others from Adobe are working on it. Do you know, is it production ready? Is Adobe actually using the Futures library in their production code? I don't
Starting point is 00:39:02 know if they're using the library as it is today, but I know that he uses part of the futures that he developed at the beginning, and he's using this in the product. Okay. It sounds like you've mentioned several different compilers and platforms right now.
Starting point is 00:39:26 What all do you guys support? So we run on Mac OS, on Linux, on Windows, on Pinnacle. That is portable native client in Chrome and Emscripten. Because both the latter, so Pinnacle and Emscripten is the platform that Sean Parent is using at Adobe.
Starting point is 00:39:55 And beside that you need I think C++14 capable compiler. At that point Visual Studio 2015 GCC I think C++14 capital compiler so at that point Visual Studio 2015 GCC I think
Starting point is 00:40:09 3.6 and sorry Clang 3.6 and GCC 6
Starting point is 00:40:16 I think they should work fine with it sounds like a pretty wide range yeah
Starting point is 00:40:23 are there other libraries you're familiar with from STLAB aside from the concurrency futures library? Is there anything else interesting in there? I think they have quite a nice extension of the algorithm part of the STL. So a bunch of extensions, which are algorithms that are not there in the standard template library,
Starting point is 00:40:52 but that are very helpful. And then they have this part that's, I think it's called Adam and Eve. So this is a way of describing UIs and implementing UIs and dependencies within UIs. I started, I wanted to use it, but at that time I had some problems to compile it within Windows.
Starting point is 00:41:24 And then I changed it to the future libraries, and at that point, I did not look further into it. But I think the library is of high quality, and it's worth to have a look into it from my point of view. I have a question about how these joins work that you've mentioned. You've got any of and all of, I believe you mentioned. Yeah, it's called when all or... When all and when any, is that what you said?
Starting point is 00:41:53 Yes, exactly. So in the when any case, so the first value that comes in is the one that wins, I guess? Yes, that's right. Does it automatically then cancel the other pending operations? Yes, if they have not started, the other operations
Starting point is 00:42:12 are cancelled. And the same is true for instance if they win all and one of their operations fails, then it cancels all the others as well because the continuation cannot be fulfilled in a meaningful manner anymore. So in the hypothetical case that multiple
Starting point is 00:42:33 operations come in at the same time and you do a win-any, do you get all of the results that were available or just the first one that it happens to hit? Just the very first one. Okay. There's inside an atomic flag and this is switched and then from there on the continuation is propagated. So in your bio, you mentioned that you do radiological work. I'm curious how this relates back to what you do professionally. So what we do is mainly is display of radiological images. So most of the time, the biggest project which we have is a reviewing workstation to display mammography images for for women's breast cancer. Okay. And so it's all done on standard PC hardware
Starting point is 00:43:29 and we have the requirement that each and every image change must happen within one second. So we have, from the very beginning, we're working with lots of thread code. And over the time code and over the times over the last 15 years when the product is on the market
Starting point is 00:43:49 the code became very complicated at certain point and I was looking for a way to to simplify this kind of code and that's the reason that I joined the project and now that we have reached the version 1.0 release,
Starting point is 00:44:08 then I will start using the library in our product. So at least that's my plan. You plan on using STLAB in your medical software then? Is that what you're saying? Not the complete, not everything what is available in SD-Lab, but the concurrency library, yes. And you anticipate this will help you clean up
Starting point is 00:44:34 or simplify a lot of your code? Yes, that was my motivation behind this because in certain areas it's really, I wouldn't say it's a mess but it has grown in how do you say in English in not a good manner over the last years and
Starting point is 00:44:55 it can definitely be improved and much more important it can be simplified so reading such a threaded code can be very ugly. And if you have a way to structure your way, so you structure your operations in a continuous way, for instance, with continuations or with channels,
Starting point is 00:45:18 then it will help for the readability a lot from my point of view. So you said each update must happen within a second. Is your goal then that when a second has passed, you just display whatever is available? No. This is something which we cannot do. But we do lots of caching of the pixel data, and so we load the images in the background. And if there's a certain condition that loading image took longer, then it will take more than a second.
Starting point is 00:46:01 But our goal is to be as fast as possible. And therefore, at the moment, we do lots of sending events through the system, and it's not very readable. So it's lots of kind of callback API. And if we change this more for continuations, then I think it will be much more readable. Okay. Going back to the concurrency library for a moment, you mentioned that there is some work to change features in the C++17 TS, but it's still not enough in your view compared to what's offered in the STLAB library. Do you know if there's any plans to make proposals to the Standards Committee based on some of the improvements you've been making to futures?
Starting point is 00:46:52 Yes, we are at the moment and writing in a proposal for the committee, but we are not done with it. And we are looking for more contributors for this so that we have more experience in other areas so that we have a better foundation to
Starting point is 00:47:13 convince the committee that perhaps a different approach might be better. Okay. Interesting. Well, I think it's interesting that you decided to join this library's open source work after listening to the show with Sean Parent. I hope you're not the only listener who's been motivated to do some open source work after listening to the show. We talked to so many different open source contributors. yes i think it's it's a great way of learning programming so i was not a newbie when i started or when i joined a project but even there are so many things that i think one can learn from others or which experience in other areas i think it's really worth doing and and on the other hand, many, many people use
Starting point is 00:48:06 in their commercial products, they use open source libraries and if we want to use them, then we have to invest into these libraries as well. So we just cannot only consume the open source
Starting point is 00:48:21 work, but I think we have to contribute to the libraries in the same way. So that's my personal view on this. I'm wondering if the techniques that you've learned while working on this open source project have affected the way that you program in your daily job.
Starting point is 00:48:41 Not in the area of multi-threaded programming, because this is something which does not happen every day. But the other way of analyzing and finding, structuring the code and finding symmetries,
Starting point is 00:48:57 this is something which influenced me and what I will try to bring into my work and bring it to my colleagues as well, yes. When I have looked through Sean's code on ST Labs, it has struck me as some of the most simple, easiest to read, complex code I have ever seen. Yes, that's true and um sometimes it's at the beginning it was
Starting point is 00:49:29 difficult for me to understand what what actually is happening there but later when i'm when i'm used to it um it's obvious why he did certain things that way and not in a different way. But yes, you're right. And the point is the library got more complicated now during the last two years because we added more features to it. So at certain points, the code gets more complicated. And this is something which we want to clean up now with the next releases. So to see if there are certain perform things that we might improve or simplify the code
Starting point is 00:50:12 so that it compiles faster. So this is something for the next release on our agenda. Okay. Well, is there anything else you want to tell us about before we let you go um where can people find you online felix well um i have a twitter account but i'm not very i'm not using it very often but most of the time I think they find me find my work on GitHub. So that's GitHub slash Felix Petriconi.
Starting point is 00:50:51 So there's as well the tutorial I gave at the SECU with all the material from the tutorial regarding this library and in general of concurrency work that might be interesting for others and yes so
Starting point is 00:51:09 well and correct me if i'm wrong but you also help moderate the iso cpp website is that right yes we had there were plans or there was a decision to set up a new portal for the conference. And unfortunately, one of the contributors had to leave the project because of family reasons. And so I had to jump into the project and, well, I had the hard time to learn HTML and web application because this is an era which I avoided as good as I could for the last 20 years.
Starting point is 00:51:54 Do we? And so I joined this project to set up this conference website and we are still improving
Starting point is 00:52:10 it and working it for the next year but I hope they find better web developer than me for the next work okay well it's been great having you on the show today, Felix.
Starting point is 00:52:27 It was fun to be here. Thank you very much. Thank you. Thanks so much for listening in as we chat about C++. I'd love to hear what you think of the podcast. Please let me know if we're discussing the stuff you're interested in. Or if you have a suggestion for a topic, I'd love to hear about that too. You can email all your thoughts to feedback at cppcast.com.
Starting point is 00:52:47 I'd also appreciate if you like CppCast on Facebook and follow CppCast on Twitter. You can also follow me at Rob W. Irving and Jason at Leftkiss on Twitter. And of course, you can find all that info and the show notes on the podcast website at cppcast.com. Theme music for this episode is provided by podcastthemes.com.

There aren't comments yet for this episode. Click on any sentence in the transcript to leave a comment.