SE Radio 617: Frances Buontempo on Modern C++
Frances Buontempo, author of the new book Learn C++ by Example, discusses the C++ programming language, a widely used general-purpose programming language. Host Philip Winston spoke with Buontempo about where C++ fits into the landscape of existing programming languages and how recent C++ standards have changed things. They talk about specific language features such as lambdas, templates, concurrency, ranges, concepts along with tips for learning and using C++. Brought to you by IEEE Software and IEEE Computer Society.
Frances Buontempo, author of the new book Learn C++ by Example, discusses the C++ programming language, a widely used general-purpose programming language. Host Philip Winston speaks with Buontempo about where C++ fits into the landscape of existing programming languages and how recent C++ standards have changed things. They talk about specific language features such as lambdas, templates, concurrency, ranges, concepts along with tips for learning and using C++.
Show Notes
Related Episodes
- Episode 159: C++0X with Scott Meyers (2010)
- Episode 91: Kevlin Henney on C++ (2008)
Other References
Frances Buontempo
- LinkedIn – @francesbuontempo
- Mmastodon – @fbuontempo
- Twitter – @fbuontempo
C++
ACCU
C++ Ranges
Transcript
Transcript brought to you by IEEE Software magazine and IEEE Computer Society. This transcript was automatically generated. To suggest improvements in the text, please contact [email protected] and include the episode number.
Philip Winston 00:00:18 Welcome to Software Engineering Radio. My guest today is Frances Buontempo. She has been programming professionally since the 1990s in fields such as banking and quantitative finance. She’s the editor of ACCU’s Overload Magazine and has a PhD in data mining and machine learning. Her new book, which we’ll be discussing today is Learn C++ by Example. She previously published a book titled Genetic Algorithms and Machine Learning for Programmers. Welcome to the show, Frances.
Frances Buontempo 00:00:51 Thank you.
Philip Winston 00:00:51 In this episode, we’re going to discuss the C++ programming language. Most people think of C++ as an object-oriented language, but it’s perhaps more accurately called a multi-paradigm language. What paradigms does C++ enable or support?
Frances Buontempo 00:01:07 Loads and loads of things. I mean, I guess historically C++ started as what was referred to as C with classes. So a lot of people do think of C++ being as object-oriented and you can use it like that. But a lot of people nowadays, particularly with some things like ranges and some of the new features take on board a more functional approach to things. So that gives you a whole different perspective. And then of course at some point during the history of C++ evolution, we introduced templates and somebody observed that you could do a surprising amount of things that compile time with templates, you end up with crazy template meta programming things which are possibly a bit niche can be useful sometimes and they’re just kind of plain fun. But you can do OO, you can do straight up procedural stuff and end up with things that look like C instead, you can do a much more functional approach, which I personally quite like.
Philip Winston 00:02:10 C++ is a compiled language, and its execution speed is one of its trademarks. What are some of the pros and cons of being a compiled language?
Frances Buontempo 00:02:19 The compiler can find mistakes for you if you use the type system well, but that’s something you need to learn to do. It means that you are compiling two specific hardware so various optimizations can kick in and that can give you the speed if you’ve written your code well. I mean you can write bad slow code in any language, but because you are compiling to a specific target, you don’t have levels of indirection going on. So that speeds things up.
Philip Winston 00:02:51 So execution speed, and you’ve already mentioned sort of the type system and touched on generic programming. I think those are all strengths that you hear a lot about. What would you say some of the, the weaknesses might be of C++ or maybe I should say like the challenges of using it in a production environment or learning it?
Frances Buontempo 00:03:11 The usual quote at this point is from Spiderman with great power comes great responsibility. So you are in control and that means that you can do all kinds of silly things, you can get things wrong. Lots of people at the moment are talking about safety. There’s a big discussion going on around that. And I guess some languages like Rust are trying to challenge C++ because you can overrun bounds if you are not careful. If you rely on things like the vector type and various other parts of the language, you can avoid a lot of the problems with overrunning bounds and dereferencing invalid memory addresses and so on. But you can completely mess things up really easily. Some of my early programming was in using embedded devices, one of which was a barcode scanner and I overrun a buffer and it left the laser switched on, which was nearly ended up pointing straight at my face. So yes, you can break all kinds of things because you’ve got the power, and you can see what’s going on. I guess an analogy might be like if you’re driving a car, if you’ve got a manual car or a stick, however you word that you’ve got more control over what you’re doing versus sitting in a self-driving car that does what it thinks. And yeah, you can break things, but you can do things better as well. You’ve just got more power and more choice.
Philip Winston 00:04:44 Part of the safety question with C++ is that it’s a super set of C so you can kind of program in C style without using say smart pointers or standard array. Is that something that comes up when people are learning to program that you have to guide them towards these C++ features?
Frances Buontempo 00:05:07 I guess it depends where people are coming from to start with. I’ve seen so many training materials out there that do go straight into pointers and allocating manually with new and then having to remember to do delete because I think a lot of people are sort of age have come to this from maybe a C background and have learn the new things as they’ve cropped up. But there are just one or two people who’ve managed to go, look, let’s just use the sensible safer things, find out about the danger later on if you really need to. I think if somebody wants to pick up C++ now if you find a book or some teaching materials that have got chapters and chapters on pointers and pointer arithmetic, probably don’t read that first. Find something that tells you about vectors and standard array and doesn’t have the word new or delete anywhere in sight. Stick to the safe, sensible things.
[...]
📄 AndreiAlexandrescu_iterators-must-go.pdf