CppCast - CppDock and nbdl

Episode Date: April 19, 2018

Rob and Jason are joined by Jason Rice to discuss C++ Web Application Development and his libraries CppDock and nbdl. Jason is a web applications programmer with an appetite for C++ metaprogra...mming having made small contributions to Boost.Hana. He is actively working on the library Nbdl, waiting for the day when C++ takes over the web. News #include C++ Blast from the Past: Borland C++ on Windows 98 Boost 1.67.0 Released Jason Rice @JasonRice_ Jason Rice's GitHub Links CppDock Nbdl C++Now 2017: Jason Rice "Nbdl: A library that uses metaprogramming... A lot" Sponsors PVS-Studio JetBrains Hosts @robwirving @lefticus

Transcript
Discussion (0)
Starting point is 00:00:00 Episode 14 of CppCast with guest Jason Rice, recorded April 18th, 2018. This episode of CppCast is sponsored by PVS Studio, one of the most powerful static analyzers for C, C++, and C-sharp source code. With PVS Studio, you'll detect errors early, during the coding phase, and spend less time debugging difficult problems later. Try the demo version today at viva64.com slash pvs studio. And by JetBrains, maker of intelligent development tools to simplify your challenging tasks and automate the routine ones. JetBrains is offering a 25% discount for an individual license on the C++ tool of your choice. CLion, ReSharper, C++, or AppCode. Use the coupon code JetBrains for CppCast
Starting point is 00:00:45 during checkout at jetbrains.com. In this episode, we talk about revisiting Borland C++. Then we talk to Jason Rice, author of CppDoc and Nibdl. Jason talks to us about his upcoming C++Cast, the only podcast for C++ developers by c++ developers i'm your host rob berving joe my co-host jason turner jason how you doing today i'm all right rob almost over my cold from last week yeah i think less coughing i'm assuming you edited out the coughing and weird sounds and stuff i hope i got them all outers can let me know if I forgot to edit something out. I apologize for that if I did.
Starting point is 00:02:07 Right. Yeah. Anyway, at the top of our episode, I'd like to read a piece of feedback. We got a comment on last week's episode on the website. This is from Alan saying, Entering pedant mode, with regards to thinking you've never used an octal number in your code, you actually do this every time you use the literal zero both the c and c++ standards mandate that zero is an octal literal and he actually references the parts of the standard where you can read that and it's just
Starting point is 00:02:37 a happy coincidence that octal zero has the same value as decimal zero and yeah we talked about that octal zero is considered harmful blog post last week and that's kind of infuriating that we're using octals that often i did not know i i'm not sure what to say about that okay so it's parsing an integer literal and if an integer literal starts with zero then it's an octal. So a zero by itself is an octal. A zero by itself starts with zero. I guess it's, I feel like there should be like a special rule,
Starting point is 00:03:13 like zero factorial is one, right? So, you know, zero by itself should be, but how does it even matter? It's an, it,
Starting point is 00:03:21 it, what? I mean, why does it matter that it's an octal like why did they have to specify that in the standard if it's the same either way yes i feel like this is like a holdover from c oh where it was simply easy like i mean a holdover from like 1970 where it was simply easier to say oh it starts with starts with a zero, therefore it's octal, we'll parse the rest of it as if it's octal. And then
Starting point is 00:03:48 that accidentally became part of the standard. That's, like, I have to assume that's what happened. I really hope that someone who has actually written standard proposals has either seen that blog post or listened to our discussions and maybe wants to take
Starting point is 00:04:03 that on and try to get rid of this and replace it with something more sensible we'll see what happens yeah 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 cpcast.com and don't forget to leave us a review on itunes joining us today is jason rice jason is a web applications programmer with an appetite for c++ metaprogramming having made small contributions to boost hannah he is actively working on the library nbdl waiting for the day when c++ takes over the web jason welcome to the show thank you you. It's actually Nibdl. Nibdl, okay.
Starting point is 00:04:45 Kind of like Wizzdl. Yeah. Oh, okay, okay. Okay, so I'm sorry. You are a serious C++ template metaprogramming person who is a web developer. Yeah, the majority of my professional career has been web programming,
Starting point is 00:05:03 and I had a little bit of C++ when I first started programming, and then I got back into C++, and I found Meta programming, I found Boost HANA, and I've been kind of working, running with that, using it to make Nipdil. And so, I was going to say, is your day job as a web application developer, does it involve a lot of C++? Lately. Okay. I'm doing some freelancing stuff where the client's letting me use it. Okay. That's cool.
Starting point is 00:05:32 Do you, well, should it wait for the interview portion or do you mind if we ask, like, how you are using C++ web development? Have you heard of the Emscripten compiler? Yes. So it's basically like a fork of Clang and LLVM, and it has a back-end that can turn C++ code into what they call either Assembly.js, and now they have a bytecode called WebAssembly.
Starting point is 00:05:57 Right. And so right now I'm compiling to Assembly.js because the WebAssembly is still kind of new as far as getting support from the browsers. But the JavaScript, it uses a typed array as a heap, so it kind of simulates the whole memory management model that C++ uses. Okay. So what kind of applications are you working on? Right now, I'm working on, it's basically just a simple web-based chat application. All written in C++? Yeah, so there is some JavaScript in it,
Starting point is 00:06:33 but that's kind of like the system-level stuff, like when you make a system call to do something in Linux, it's external to the code that you write, but JavaScript is a system. And I make calls to that from C++ land. You know, we've talked to people about WebAssembly before, but I don't know if we've talked to anyone who's actually actively working on something
Starting point is 00:06:55 that would be considered a web app in C++. Yeah, I've mostly talked to people who are making pet projects just to demo that it works. Or using WebAssembly to port their game to something that can run in the browser. I mean, it's really cool to see DOSBox and stuff and games running in your browser, but I feel like this is something different.
Starting point is 00:07:17 I like it. Yeah, Emscripten supports the whole porting, like the DOS programs. So they have a lot of APIs for that. So you can use the file system API, or it even supports SDL. And WebGL
Starting point is 00:07:33 using, I think, the same interface as OpenGL. But yeah, they have a lot of support to port over existing games and stuff. And I think that was the real commercial driving force that got so much popularity for Emscripten. So how are you writing the components of your chat client? Is it cute? Is it SDL? I mean, what are you doing?
Starting point is 00:08:00 It's Nibdl. It's Nibdl. It is Nibdl. Yeah. All right, then we will talk about that in a moment. Just start describing exactly what it is and how it works. Let's go through some of the news articles and stuff, and we'll definitely go into Nibdl and some of the other projects you're working on, okay? You have already caught my attention.
Starting point is 00:08:16 Yeah. Okay, so like I said, we have a couple of news articles to discuss. Feel free to comment on any of these, Jason, okay? Yep. Okay, so this first one is include C++. And we've talked about this a couple times on the show. I guess we've talked about it with Guy Davidson and Simon Brand. I guess the idea came just from discussions at a conference or over the CPP chat. Yes, Slack. So they put out a website, which is includecpp.org,
Starting point is 00:08:52 and it looks like it's mostly kind of a set of resources for C++ conferences and other communities that want to make sure they are trying to be as inclusive as possible. So if you're a conference, you should really have a code of conduct. And they have a template code of conduct for any C++ conference to use, or really probably just any conference. And yeah, it's a great resource. I'd like to see kind of where where they might be going with this
Starting point is 00:09:26 like what else they might uh try to do yeah i believe maybe not all those uh people who are mentioned to the administration team which is like uh most of them we've had on our show or have talked about yeah in addition to simon and guy there's Patricia Oss, Kate Gregory, and a couple other names that I don't think we've had on. No, Fred, I don't know how to pronounce his last name, but he is the creator of Clickbench. Oh, okay. So it's definitely someone we've talked about before. Yeah, I know at least some of these people have publicly said that they will not speak at a conference unless there is a code of conduct. Yeah.
Starting point is 00:10:07 And I respect that for sure. And also there's a note here that they have started their own discord server, which I have not checked out before, but I've seen it mentioned by a few other people. Um, so that's another way for C++ people to communicate. It's supposed to be a welcoming community for people learning and wanting to talk about C++ and stuff. Did you want to comment on anything on the include C++ thing before we move on? The cool thing I like about it
Starting point is 00:10:36 is that they're getting more people involved in the community, like C++ community specifically, and then junior programmers have different perspectives if they give talks. They can give us insight to what barriers there are to entry or a user of a library could show you how your interface is just too convoluted or something like that.
Starting point is 00:10:58 So different people's perspectives from different walks of life is always a good thing. For sure. Yeah, absolutely. Yeah, I'm often reminded of this image. It's from like, I think I, I risk now me saying this wrong,
Starting point is 00:11:11 but I think it was a brand new Apple office building that had a spiral staircase that went up to the second level and it was all glass see-through stairs. And they're like, if a woman had been involved in the design of this building they never would have made a glass staircase because someone underneath the staircase someone's scared or something yeah yes like it's a terrible design idea yeah yeah okay uh next article um this is an interesting one blast fromast from the past, Borland C++ on Windows 98.
Starting point is 00:11:49 So this developer, Chris Wellens, who writes this blog, decided that he wanted to see what the tools that he first learned C++ on, kind of how they would hold up today. So he set up a VM and put Windows 98 onto it and then got Borland C++ 5 and kind of evaluated how the tools held up
Starting point is 00:12:14 and he kind of was surprised that in large part they were better than he kind of expected that they might be. But still not good enough because apparently he quickly switched to Vim. Yeah. um but still not good enough because apparently he's quickly switched to vim yeah may as well use your cross compiler if you can yeah but uh he he has uh some library that he works on and he was able to get his library which he specifically designed to be very uh kind of cross-platform compatible to be able to run on C++ 5 and on Windows 98.
Starting point is 00:12:48 He was able to get it all to work, which is a pretty impressive feat. I can respect the effort, and I respect this concept, but having a C89 code base. Yeah. He specifically wrote it in C89 with this theory that if it could work with a compiler 20 years ago, it'll still be able to work 20 years in the future.
Starting point is 00:13:16 And I just couldn't do that. It would have to be at least... What's that? It's hard to go back. Yeah, it would have to be at least... What's that? It's hard to go back. Yeah, it would have to be at least C99. I want, like, scoped variables and stuff, right? Yeah. Yeah, it's going to be really hard
Starting point is 00:13:33 to not be able to use any of the more modern features. Yeah. Well, and C, even. I mean, come on. Yeah. I used to use Borland C++ 5, and it would always, it would, like, you'd click on the project file,
Starting point is 00:13:50 and it would open it, and then it would crash, and it would, like, overwrite the file, so I'd lose all sorts of work before, like, I knew about revision control. And ultimately now I use Vim, so I thought that was kind of funny. You know, everybody that started with Borland ends up using Vim and Linux.
Starting point is 00:14:06 I didn't... Ran away screaming. I mean, Borland 5, you said that's what you... Is that what you started with? Turbo C++ is what I started with. Yeah, so when I saw your blog, I totally related with... You know, it's like nostalgic. Yeah, that's... I mean, they were neat tools,
Starting point is 00:14:27 but, you know, you said before you knew about revision control systems, I mean, what would your option have even been on DOS or Windows? Would there have been one? Yeah, well, Borland C++, the development suite or whatever, came with, like, Install Shield, and I don't remember the name of the revision control system, but it had one whatever came with like install shield and i don't remember the name of the revision control system but it had one with it i did not know that okay i didn't know it at the time either it's like i used git or you know svn and git for a while before i like looked at
Starting point is 00:14:57 the box and i saw that that's what that was i don't remember the name of the revision control system, though. Huh. Yeah, I mean, I've run most of the gamut, source safe to CVS to SVN to get with the most, yeah. But no, I didn't even know about it until I started my first professional job, I think. Yeah. Okay, next article is Boost version 1.67.0 is out and uh the main uh updates here are there two new libraries one is contract and the other is high order functions or higher order functions yes so contract fit sorry sorry go ahead it's it was previously known as FIT. Sorry. Sorry, go ahead. It was previously known as FIT. I didn't know that's what that was.
Starting point is 00:15:47 Okay, yeah, that's authored by Paul Foltz II, and I talked to him a very long time ago about FIT, I believe. Yes. Yeah. A very long time ago. Contract programming, is that being worked on in the standard, though? Is that based on this? Does anyone know? I couldn't tell if this is based on the on in the standard, though? Is that based on this? Does anyone know?
Starting point is 00:16:05 I couldn't tell if this is based on the proposal for the standard or not, but I would assume that they are related. And we talked to Bjarne about this briefly, I believe. That's when it came up on the show. Yeah, that sounds right. What is it? Okay. The contract programming library, it's a new one in Boost.
Starting point is 00:16:24 Is contracts like runtime checks or something? You can specify preconditions and postconditions, and then it can either be compiled in or not. And looking at the very bottom of it, it does say the authors of this library advocate for contracts to be added to the core language. So this does seem to be directly related to the proposal okay is there anything else you guys wanted to call out in the uh boost update i was wondering if any of the other libraries that we had talked about recently on
Starting point is 00:16:57 the show were in here or had been updated in this release but i don't see it. Anything else that is? Nothing we've talked about super recently. I mean, we've probably talked about a lot of these libraries. You know, Beast is mentioned, but that's a pretty small update. Just saying they fixed a defect in WebSocket stream. I was surprised. I mean, we saw Expected got accepted, right? Yes.
Starting point is 00:17:25 So I expected to see it expected in this release. But my expectations were not met. I don't know if that means I throw an exception or if I just get back an empty result. I'm not sure. I'm guessing that he was accepted with maybe a couple minor things that he had to address before it would be fully accepted into the release. Okay. Yeah. Okay.
Starting point is 00:17:52 Well, Jason, so we already talked a little bit about Nibdl. You're going to be giving two talks at C++ now in May. Before we talk more about Nibdil, I'm kind of interested in the other one that you are talking about, which is Docker based C++ dependency and build management. We've talked about build tools a lot on the show, but not so much about Docker. Could we start by just giving us an
Starting point is 00:18:17 explanation of what Docker is for listeners who aren't familiar with it? Docker is like a way of building and managing Linux containers, but they actually have it working on Windows now, so you can do Windows containers using PowerShell, which is not something I've tried yet, but it's
Starting point is 00:18:33 basically like you have a Docker file and it's a way of making a deterministic and what they call a pure build. So you have like a certain set of inputs and it expects that a certain set of outputs for that given input will always be the same. So it can cache layers in a build system, and you can build an environment in Linux that's isolated from your
Starting point is 00:18:56 host system. So you can install things like compilers, do cross-compiling without accidentally overwriting your system compiler you know having accidental you know pulling in libraries from another system or something like that. Well that's the way I'm using it for C++ a lot of people use it for building like their either their development environment or even their production environment. And even you can make a Docker file
Starting point is 00:19:27 that can generate test data or something and you can put them all together and it works in a little simulated network. And they can have databases and stuff like that as well. Okay, so you said that's kind of the more traditional use case of Docker, but you're using it to set up your compiler and development environment? Yeah, I wouldn't say that there is a traditional use,
Starting point is 00:19:53 but it is pretty predominant that people are using it for web apps. You can have a Docker image for Apache or Nginx and then a Docker image for MySQL. So it's a way of separating things. You could put it on one computer, or you could put it on multiple computers. There's Docker Swarm, so you could do horizontal scaling and whatnot. That's what makes it popular, I think, is the scalability aspect of it. Okay, so then what does your
Starting point is 00:20:27 project CppDoc do? Right now it's just like a Python script that does, so the Docker command line is kind of general use. So if you want to build a library or pull in different libraries of like specific revisions, CppDoc will look at an any file, and in that any file you can specify what revisions you want to, or not revisions, but what libraries you want to pull in.
Starting point is 00:20:56 And right now it just uses GitHub, but it looks at the ref logs, or not the ref logs, the git ls remote, so it gets the current revision for that branch. So it's kind of like making a lock file, so that when it builds an image, you can guarantee that it's going to be that exact version of that software. So if you specify the master branch, and you build two separate images, there's really no guarantee that you would have more commits from a newer version of master. So if we specify the revision, we can guarantee, like, if we built two different machines at the same time,
Starting point is 00:21:32 or even a year apart or something like that, it would be exactly the same. So it's kind of like guaranteeing the compatibility, too. So did I hear you right that it actually can deal with dependencies requirements too? Yes. Okay. Right now that's kind of all it does. So it takes like an any file and just using like the GitHub, like you could do boost.org slash HANA and then specify the master branch.
Starting point is 00:22:03 Okay. When you run cpp.build, it'll look at the.ini file and overwrite master with the actual revision that it's currently at. Okay. So that when you run all your tests, like on a specific compiler, because you specify the revision of the compiler too. Okay. So it's not just libraries. It's actually any kind of system dependency.
Starting point is 00:22:25 So sometimes libraries will build with a specific version of CMake, but not another one. This is a way of putting everything together in one package. So, you know, like if you try to update the compiler and it doesn't work, you can just go roll back your cppdoc.ini file to the previous revision that you're using in it using and it'll work. So you can specify
Starting point is 00:22:50 multiple projects that you want it to pull in, I assume you're saying. Yes. Does it compile each of them then for you automatically, like look for CMakeList kind of thing? Yeah, so I have recipes and the default recipe is like a typical CMake build.
Starting point is 00:23:05 So it starts out with Yeah, so I have recipes, and the default recipe is like a typical CMake build. Okay. So it starts out with like a platform image that has like the compiler and CMake and Git and what is the important one? Oh, yeah, it has a CMake toolchain file for the compiler. So if your library uses CMake, you don't have to specify a recipe. It just automatically uses a bootstrap CMake for you, and it'll build that, and it
Starting point is 00:23:33 installs it to a special install directory that'll later get installed to the final image when it slaps everything together. But you can override the recipes with a bash script at the moment. So what do we expect? What compilers are currently available
Starting point is 00:23:52 in Docker image? Like what base OS are you using? What kind of compilers can we pull in? So right now, the way I'm using it is it's Linux containers. Okay, yeah. I'm just cross comp it's Linux containers. Okay, yeah. And I'm just cross-compiling from there. So, like, actually that one, the Borland C++ guy, the blog post,
Starting point is 00:24:12 he was actually cross-compiling using what I think is called MingW. Yeah, right. From Linux to Windows 98. So that's one option. There's also Docker supports Windows containers now. You could do that if you wanted to. But the way I'm using it is it's Linux and the
Starting point is 00:24:34 compiler, you kind of build it yourself. Like I have a couple of example ones you can use by default. And it pulls in the scripting compiler. But you can build just default. And it pulls in the scripting compiler. Okay. But you can build, you know, just any kind of system you want, just as long as it is the default compiler for the system.
Starting point is 00:24:52 So I could use, like... Oh, okay. So I can't just arbitrarily say I want, like, G++7 even though this is not, there's no package for it currently in Docker or something like that. Right now you would have to build it yourself.
Starting point is 00:25:08 There is a Docker package for GCC. They have their own Docker account. You could theoretically pull that in. I did not realize that GCC had their own Docker images. I'm fairly certain about it. I think Clang and LLVM
Starting point is 00:25:24 might too, but if not, there's other people that have it out there. I can certain about it. I think Clang and LLVM might too, but if not, there's other people that have it out there. I can almost guarantee it. Yeah, I know. I mean, I believe you, but I just looked it up, and sure enough, you can say, I want Docker from just about any version of GCC, and it'll give it to you.
Starting point is 00:25:42 Yeah, Docker's pretty big. It's well-supported. It has been long enough ago since I looked at it that when I last looked at it, the Docker for Windows that you were talking about had just been announced, but you couldn't actually try it yet. Right.
Starting point is 00:26:01 So it would be cool to actually try it, I think, at some point. Yeah, you have to have a actually try it, I think, at some point. Yeah, you have to have a special version of, I think, Windows. I'm not really a Windows user, but I think you need the professional edition or something like that to do the Windows container stuff.
Starting point is 00:26:17 But it almost looks like... No, no, go ahead. It almost looks like the Windows containers are exclusive to being managed by Docker. I couldn't find a way to do it without Docker, which was interesting. That is interesting, yeah. And I was just looking. I don't see LLVM or Clang having their own Docker images, as far as I can tell.
Starting point is 00:26:38 But cool. So going back to CPP Dock, I guess the idea is if you want to try out a new library and you don't want to necessarily set things up on your system, you could just set up a CppDoc Docker instance in order to test everything out, compile the project, and then kind of investigate it? Yeah, right now I'm having a feature added that can make that super easy. Just type in CppDoc dev and then the name of the image for the platform,
Starting point is 00:27:08 like the compiler, like Linux x64 or whatever. And it just mounts the current directory as the source directory, and it runs the CMake thing in a separate build directory. And then you can just start running targets like make, check, or whatever. I'm doing that when I do Boost HANA. I don't have the compiler that can run it on my system, but I have it in Docker land. I wanted to interrupt the discussion for just a moment
Starting point is 00:27:36 to bring you a word from our sponsors. Development of qualitative software is impossible without the use of static code analysis tools. These tools detect errors on the coding phase, i.e. at the very early stage. The earlier a bug is detected, the cheaper it is to correct it. One of the powerful static analyzers is PVS Studio. This tool detects errors and potential vulnerabilities in the source code of programs written in C, C++, and C Sharp.
Starting point is 00:28:01 It works on Windows, Linux, and macOS environments, and it conveniently and easily integrates into the Visual Studio IDE versions 2010 to 2017. You can easily check your CMake-based project or use a compile monitoring if you use your own build system. The analysis can be conveniently integrated on the CI servers by using a command console.
Starting point is 00:28:20 To reduce the analysis time, you can apply incremental analysis and Incredibuild. The analyzer can identify potential vulnerabilities due to compliance of the PVS Studio diagnostics to classification of common weakness enumeration. To ensure continuous quality control of the source code, the analysis results can be uploaded to SonarQube. Try the demo version of PVS Studio and find errors in the code of your project. So, do you want to tell us a little bit about the other library you work on, Nibdl. So, Nibdl is a state management library, as kind of like some of the
Starting point is 00:28:55 JavaScript state management libraries that are coming out to complement UI libraries like React and Angular. What it does is it has like a context object. What it does is it has a context object and it owns a composition of state machines. It also owns a fixed set of actors that can be producers or consumers
Starting point is 00:29:16 of messages that these messages are like actions on the state machine. A producer could be a client to a server and a consumer can be something that renders HTML. So when it receives a message
Starting point is 00:29:34 it detects that a piece of state changed and it can modify the DOM accordingly. Okay. So that's how I'm doing the web app stuff is that it actually uses instead of like markup it's like functions like div
Starting point is 00:29:52 and then you can specify like a class and it's actually the way it works is it's it's stateless and it just kind of creates this big ugly type that it uses to create a series of functions that renders the DOM. And when it detects a specific state change,
Starting point is 00:30:12 it looks it up by its type, so it can eliminate a lot of the, you know, like checking to see if a DOM element changed or something like that, like they do in JavaScript right now with the virtual DOM. So I, when you first mentioned this, assumed that you would be using your C++ within Scripton to write to a canvas, but you're just, you're creating web component or web elements, page, whatever, web page elements.
Starting point is 00:30:40 You can write to a canvas, but it's not the most efficient for something like a web application. Sure. It's like you'd render something, and when something changed, you'd have to render the change, and that's something the browser handles for you already anyways. To reimplement that in a canvas would be not the most efficient way of going about that. I had no idea that from Inscripten you could manipulate the DOM. Yeah.
Starting point is 00:31:07 I can make calls to JavaScript LAN, so it's kind of like a system. There's like an implementation of the functions that modify the DOM, and that's called from C++ LAN. So you build the set of things that you want to change, and then do you have to
Starting point is 00:31:25 basically serialize that to javascript that executes some blob of javascript what does this actually look like what's the interface between the two look like it's it's not really serialization um so the calling the functions it usually happens using a macro uh provided by mscript and the compiler actually whatever you give it is just a block of text that gets turned into a function and it takes whatever inputs that you would give it at run time
Starting point is 00:31:54 so it's creating kind of like a routine that's run in JavaScript and one way you could go about it is like you could make just like allocate something and use its pointer value as a handle to a hash table, and you could use that to look up a JavaScript object from C++
Starting point is 00:32:14 just by using the pointer as a unique value. That's an inefficient way to go about it, but that's one way you could access JavaScript from objects from C++. Okay. So you call JavaScript functions directly to some extent from your C++. Yeah, so
Starting point is 00:32:35 it gets compiled to JavaScript eventually. Right. All the C++ code is in this cryptic assembly.js format. Right. But that doesn't mean that it can't call a function that's outside of the assembly.js. And that's what it's doing. Okay.
Starting point is 00:32:51 That's interesting. All right. Do you have to combine, you know, when you're writing a web application this way, are you writing some C++ that goes through the Emscripten compiler and some just regular JavaScript? Do you have to combine the two? Or are you mostly writing C++?
Starting point is 00:33:09 I've been trying to make it more C++ than anything. The problem with JavaScript, like I've done a lot of JavaScript programming, and it's like the flow is like you write a bunch of code, or you write some code, and then you run it, and then you have to go back and make iterative changes to make it work. So I try to put as much into C++ as I can, but one of the things I'm doing in the chat is using the WebRTC API.
Starting point is 00:33:37 There's some stuff that doesn't really match with C++ well and it would just be needlessly complex to try to cram as much of that into C++ when it's just kind of running in the background anyways. So what is WebRTC, if I might ask? It is a way of having a browser, two browsers connect peer-to-peer using UDP. Oh, I think we have discussed this at some point with someone else who was doing...
Starting point is 00:34:06 Anyhow. So that's how your chat client then, I assume, is talking. Yeah. It's kind of complicated to set up the peer connection. It has to involve a signal server.
Starting point is 00:34:21 So that's kind of the complexity with the JavaScript. So the signal server is actually marshaled from C++ land, so I have to send the messages from WebRTC and then to the signal server and back and forth. So that part of it's done in C++.
Starting point is 00:34:39 So what kind of performance are you getting? Does it seem to be working out well? I haven't noticed really. Nothing is really CPU intensive or anything. We are doing encryption in the browser using the library Libsodium. Okay. It's really fast.
Starting point is 00:35:03 It's supposedly only four times slower than native, although I've never benchmarked it myself, but I have never noticed a speed problem, or I haven't really noticed it being any faster. But the thing I like about it is the code's smaller than, like, when you do a big JavaScript project and you pull in a bunch of tools, you can't seem to get rid of dead code,
Starting point is 00:35:24 and it ends up making a big, you know, like 500K to one megabyte JavaScript file, whereas with the C++ build, it can be as small as 50K. And then you have to minimize your JavaScript and do all that stuff. Yeah, and Scripting handles a lot of the minimization on the C++ side, so it makes a really small build. That's kind of funny.
Starting point is 00:35:48 It strikes me as funny every time I hear that we can do web programming faster, simpler, and faster-performing code in C++. That doesn't seem right. I mean, I'm okay with it. It doesn't seem natural. I wouldn't say that it's simpler yet. mean, I'm okay with that. It doesn't seem natural. I wouldn't say that it's simpler yet. Like, I'm working on that.
Starting point is 00:36:09 Right now, it is kind of difficult, but what I'm trying to do is make a user interface that's safe, which is why I'm using the stateless values that gets handed over to some metaprogramming thing that creates the rendering stuff. But I believe the end result will actually be something that's easierrogramming thing that creates the rendering stuff. But I believe the end result will actually be something that's easier to use than a lot of the JavaScript frameworks.
Starting point is 00:36:30 And it doesn't give you a lot of rope to hang yourself with either. Okay. Aside from the projects you're working on yourself, do you have any other users of your library? Are you possibly getting any help from the community in building this up?
Starting point is 00:36:50 Not on the Nibdl thing, no, I don't. I think it's just me. I'm a lone wolf. Okay. I know it seems crazy. That's why. Probably why I'm all by myself. You will be talking about Nibdol at c++ now correct i did last last year actually oh last year i'm sorry the focus was kind of like on the the internals of the how it's using metaprogramming stuff and boost hana and whatnot but the the talk i'm doing this
Starting point is 00:37:21 year in addition to the docker one, the full duplex kind of builds on that, so I'm taking my promise stuff and the full duplex endpoint composition stuff, and I broke it out into a separate library. And I'll be talking about that at CPP now as well. Okay. So
Starting point is 00:37:39 this is based on the work that you did with Nibdl. But it's a whole different library? Yeah, it's... So I've been building a bunch of stuff in Nibdl, and then now it's being broken apart into separate pieces that don't need to be together. It's like isolating the scope. So this part that you've split off is not specific to web development, you're saying? No, and in fact, Nibdl is not specific to web development, you're saying? No, and in fact, Nibdl is not specific to web development either.
Starting point is 00:38:08 So what I've been working towards is generic programming. So it's an interface that could be used on any platform. So I use it on the server side, I use it on the client side, I can even use it for native apps, which is kind of the whole point. And you mentioned Boost HANA when we were talking about CPP Dock, and it looks like, does
Starting point is 00:38:33 Nibdl use HANA? I would say extensively, yes. Okay. I'm curious, what features you get from HANA that have made Nibdl possible versus I don't know, what you might have done by hand or whatever? Actually, the most obvious part is the Promise interface. It's actually implemented as a HANA monad, so I'm not only using the functions provided in HANA,
Starting point is 00:39:01 I'm using its concepts or the semantics it provides for making a monadic interface. Use the M word, Rob. Which means we can't explain monads without having to read papers and papers on monads, right? Yeah.
Starting point is 00:39:19 I'm going to have to find a YouTube video on monads or something at some point. Yeah. Have you used Promises in JavaScript? I've heard the concept. I've never used Promises, though. Let's say you want to get a value from the network or something that involves IO, and you don't want to sit and wait for it. You could give it a callback.
Starting point is 00:39:43 What a Promise does is instead of nesting callbacks, it's a way of flattening it. So you basically chain off these different operations, and in that chain you give it a function that receives a value, and then you can create a new promise from that. So it's like chaining network calls or any kind of asynchronous calls. Okay. It's kind of similar to futures, right? Well, it sounds like the futures.then that they want to add to futures. Yeah, it's the exact same
Starting point is 00:40:16 thing, only it's not tied to threads. Okay. So you spoke at C++ Now last year, correct? You just mentioned that on Nibdl. You've got two talks coming up this year. Have you given, this will be your three total talks there? Yeah, second and third. Okay. How many years have you gone to C++ Now?
Starting point is 00:40:39 I went the year before that in 2016. Okay. So what was your decision? In 2016, you did not give a talk? No. Okay. Well, I'm curious what your decision was to go from not a speaker to being a speaker and what you might have to say to people who are considering this kind of thing.
Starting point is 00:41:00 I don't know. I think I'm crazy or something. The original reason I even started going to the conference was I was messing around with Bustana, and Louis Dion invited me, and, you know, I didn't even think about speaking at that time, and I saw other people speaking, and they were talking about their libraries and stuff. So I thought that, you know, it would be fun, and I kind of wanted to get the idea out there, even though it's kind of a crazy idea. But I think, you know, getting it out there and getting some feedback, it's kind of like, you know, the talks are kind of almost like a discussion
Starting point is 00:41:37 with, you know, experts in the field. Right. Especially at CPP now. But, yeah, the speaking part of it's just kind of a fun thing I guess so we still have a couple weeks left for people to make decisions and buy tickets
Starting point is 00:41:56 when this airs we'll have exactly two weeks until the conference starts I believe so what would you say to those people that have not yet made a decision to go? Do you have any comments for them? So,
Starting point is 00:42:11 the first year I went, I tried to brighten my horizons. I felt like I knew C++. I felt like I knew Meta programming. So, I actually avoided those talks, and I went to things like lock list shared pointers and queues and stuff like that, stuff I'm not familiar with.
Starting point is 00:42:31 Tony's talks. Yeah. The problem with that was I was just completely lost. So the next year I went to the talks, and I felt like I already knew everything. And those are the ones that I got the most out of, and it was inspiring. And I would say, like, all the work I've done on Nibdil and some of the other stuff I've been doing builds off of the things that I learned at these conferences. So it's not just like, you know, you can read a blog.
Starting point is 00:42:59 But, you know, being there and kind of being a part of the discussion, it's way more inspiring. Like, in the evenings, I was, like, trying out different ideas. And, like, you know, for weeks afterwards, I was just playing around with, you know, watching the talks over again and playing with the libraries. But I would say, you know, for someone who does decide to go, you know, more about the stuff you think you know everything about. And you promise they'll probably learn something more. Oh, yeah. Yeah, it's better than just being lost in something you're unfamiliar with. See, now I find this...
Starting point is 00:43:41 I'm sorry, go ahead. Well, as far as getting people to go to their first conference, it's a hard sell to get somebody. For me, I do freelancing, so I don't have a company to pay for me to go or anything, or maybe they have to convince their employer. But if what you're doing is C++, there's a huge return on it.
Starting point is 00:44:04 Like the talks I watched, you know, Jason Turner. Every one of the talks I either watched online or I attended, I always picked up some trick. Like whether it's like an idiom for setting up, like the move from a constructor. I remember the... I always thought if constexpr would be faster than
Starting point is 00:44:31 so fine I, but apparently it's not. I had made an assumption, but now I know for sure that the best practice probably isn't this. It's better to go along with these because this guy has already tested it out and proven it.
Starting point is 00:44:49 It is a fun conference for sure. And I've also had this theory for a long time that I've never actually tested myself, that I should go to all of the talks that I think look the least interesting because then I'd be the most likely to learn stuff that I don't know already. But it seems that you basically tried that your first
Starting point is 00:45:10 year, but had way more fun going to the talks that you thought you already knew about. Yeah, maybe it was also because it was relevant, like I don't have a use case for some of the concurrency models and stuff like that, or a shared
Starting point is 00:45:24 lockless shared pointer, or I don't even remember if that's what that talk was about. But I also, I attended one that was actually really entertaining about the processor cache, and like how, you know, there'll be dragons when you, when you end up going into memory or whatever, as far as performance goes. But I retained some of it
Starting point is 00:45:46 but i don't use it on a day-to-day basis so it isn't really that relevant to me right right okay well it's been great having you on the show today jason thanks for having me yeah thanks for coming on 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. I'd also appreciate if you like CppCast on Facebook and follow CppCast on Twitter.
Starting point is 00:46:21 You can also follow me at Rob W. Irving and Jason at Leftkiss on Twitter. You can also follow me at Rob W Irving and Jason at left kiss 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.