Algorithms + Data Structures = Programs - Episode 67: How to Get Started with C++
Episode Date: March 4, 2022In this episode, Bryce and Conor talk about how to get started in C++.TwitterADSP: The PodcastConor HoekstraBryce Adelstein LelbachShow NotesDate Recorded: 2022-02-05Date Released: 2022-03-04ADSP Epis...ode 4: How Many Programming Languages?North Denver C++ MeetupGo Programming LanguageSmalltalk Programming LanguagePython Black FormatterC++11 constexprC++17 if constexprC++20 ConceptsJava Programming LanguageRust Programming LanguageBeautiful C++ Code by Guy Davidson and Kate GregorySoftware Engineering at Google by Titus WintersJon Lakos BooksElements of Programming by Alexander Stepanov and Paul McJonesStructure and Interpretation of Computer ProgramsEffective C++ by Scott MeyersMore Effective C++ by Scott MeyersEffective Modern C++ by Scott MeyersEffective STL by Scott MeyersCompiler Explorer aka GodboltVS Code EditorClang-FormatClang-TidyC++ Weekly by Jason TurnerC++ Starter Repovim EditorGithub CodespacesCppCon 2019: Jason Turner “The Best Parts of C++”C++Now 2017: Bryce Lelbach “C++17 Features”SG20 Education and Recommended Videos for Teaching C++CppNorthCppCast Podcastcpp.chat PodcastIntro Song InfoMiss You by Sarah Jansen https://soundcloud.com/sarahjansenmusicCreative Commons — Attribution 3.0 Unported — CC BY 3.0Free Download / Stream: http://bit.ly/l-miss-youMusic promoted by Audio Library https://youtu.be/iYYxnasvfx8
Transcript
Discussion (0)
I do use syntax highlighting, but I'm more and more turned off by syntax highlighting.
What? What? You don't like syntax highlighting?
Yeah.
You sound like an old grumpy man.
I mean, I am an on February 5th, 2022.
My name is Connor, and today with my co-host, Bryce, we talk about how to get started with C++.
New episode. This is going to be episode like 68 or something.
Who knows?
This is coming out probably in March of 2022.
We had a person.
His name, Jeff Erickson.
Shout out to Jeff Erickson.
Hello, Mr. Erickson.
And he sent me a sort of episode request.
So Bryce has gotten zero.
He's going to be off the cuff responding.
But we're going to go ahead and read this message from Jeff Erickson,
and then we're going to answer this live.
Hey, Connor, Jeff here.
I'm a huge fan of your YouTube stuff as well as ADSP.
Well, thank you, Jeff.
It's kind of you to say so.
I wanted to write to say that while sometimes you might think that the audience as ADSP. Well, thank you, Jeff. It's kind of you to say so. I wanted to write to say that while sometimes you might think
that the audience of ADSP is a bunch of C++ people
who also want to branch out,
I think there are also a lot of people like me,
that is, people with 10 plus years as an engineer
who have never touched C++.
Personally, I've worked in Python, R, Go, Perl, and SQL.
I've also been interested in functional languages,
and I'll be honest that I hadn't given C++ much thought since I've avoided it until now, until I started listening to ADSP.
Listen to that, Bryce. We're changing people's views. I love this guy.
I hear that, Jeff. Bryce loves you. But now, I am C++ curious. So I thought it might be worth suggesting to you to do an episode on ADSP where you talk about why you guys like C++ and talk about how someone without any experience could try it out or get started or inspire.
C++ is one of those languages that, to me at least, feels so big and massive that it's extremely intimidating to start learning it as a 35-year-old who isn't learning it in school.
What resources
would or could get someone's feet wet enough to tell them if they should continue the journey?
And also, I think it would be worthwhile to describe your dev tooling also since that too
has been a huge black box to me with respect to C++. Maybe it's just the circles we find ourselves
in, but I feel that while the newer, cooler languages and quotations get a lot of action
in terms of interesting books to read and cool tooling to improve your dev environment, languages like C++ don't seem to get the same
treatment. As experienced C++ people yourselves, maybe that is less clear to you. If it's not
episode worthy, if you could at least maybe give me a few tips for starting points, I'd really
appreciate it. Thank you, Jeff. So Jeff, I think it's a great episode idea. And now we're going to get Bryce's response.
So the question is, in the midst of that big long message, is that, you know, how does someone get started now that they're C++ curious when they're not learning it in school?
Where do you begin?
What resources would you recommend?
And what about the tooling setup?
Bryce, go.
So let's start off with why I like C++.
I think, actually, if you go back, one of our earlier episodes, we talked about how many programming languages should you learn.
And I took the position of, you only really need to learn one or two.
And Connor took the position of, learn all the programming languages.
And I actually think that's one of the nice things about C++ is its versatility.
C++ is a multi-paradigm programming language.
I think that is really the defining characteristic of C++ as a programming language.
That you can, you know, it's an imperative language.
It maps very closely down to hardware.
But also it's, you know, an object-oriented language.
It's a generic language.
It's a functional language.
So you can use a wide variety of different programming paradigms and techniques.
And I think more importantly, you can combine those different techniques together.
And so for me, one of the things that's appealing about C++ is that
for systems programming tasks, you can use it for almost anything
and not be restricted to a particular way of programming.
It gives you many different choices and options. You know, sometimes some of those are foot guns,
which people don't love. But that to me is a big part of the appeal. Now, it doesn't mean that you
can actually only learn C++ because it's, you know, as a sort of a systems programming language,
something that you use to write, you know, underlying things. And as a compiled language,
it's not, you know, as nimble as something like Python. But if you're in that space of writing,
you know, something that needs to, some sort of system software, something that needs to some sort of system software something that needs to be high
performance or that that needs to talk to hardware talk to operating systems etc or you know a lot of
the meat behind a lot of the things that we actually use end up getting written in C++. And to me, part of the appeal is that,
like, you can learn this one skill, how to, like, program in C++, and then there's just a very wide
variety of things that you can do with it. So I think to me, that's, like, part of the appeal
and the magic of it, especially as compared to other systems programming languages.
Yeah, one thing I'll echo, because a lot of the, I like C++ for the same reason. I will say,
on a small tangent, once again, at the Denver C++ meetup, which I think got mentioned a couple
episodes, the most recent topic was like an open conversation on what makes programming fun.
And at one point, I mentioned in the chat that I said, you know, C++ is not fun in parentheses relative to other languages, which was kind of
just a provocative thing to say because I like APL better. But like the thing that I really like
about C++, especially compared to languages like Go, is Go is not programming language enthusiasts' language,
meaning that they really want you to do everything sort of one way.
Like that's sort of the thing about Go
is that they've got sort of one way to do it
and all Go code tends to be very, very similar.
And so you can hop from one code base to another code base
and sort of the tribal knowledge of that sort of code base is very similar. And so you can hop from one code base to another code base. And sort of the
tribal knowledge of that sort of code base is very small. So you can ramp up extremely quickly.
It's a high productivity language. But that means that if there's, you know, there's not a lot of
options as a programmer for how you want to do something. Whereas in C++, it's the exact opposite.
Like C++... If anything, there's too many options.
Exactly.
And which, as a programming language enthusiast, I get to choose the style.
Do I want to code functionally?
Do I want to code, you know, small talk, you know, OO-ishly with messages and, you know, that kind of style.
Like, you can code in whatever style you want.
You want to code, you know, basically with just C with classes, you can do that as well.
Which leads to issues if
you don't have agreement with your co-workers on like how you want to program yeah it's like one
of the reasons why you know coding styles and code guidelines are so important in c++ and i feel like
there's some other programming languages where maybe like people who program in those languages
like this idea that it's
important to have coding styles might be foreign because they're just so used to
like this is the way that you write code in this language but in c++
there are many different flavors and that's the whole thing is you know the python ecosystem as
well like it's not as much the same as go but they try to layer that you know the zen of python
there's one way to write code and, you know, the Zen of Python,
there's one way to write code and just, you know,
black is the formatter
that everyone uses.
Python, once again,
they try to sort of like,
idiomatic Python,
the Zen of Python is like,
there's one clear way to do things.
Whereas in C++,
there's never one clear way to do things.
There's like literally C++ 11, 14, 17, 20,
the way you're going to do metaprogramming
is vastly different
in each one of those because we got
if constexpr in C++ 17
we got concepts in C++ 20
we got constexpr in C++ 11
and more and more constexpr stuff with every edition
like how you do metaprogramming
is like drastically different
in every single standard which
is definitely a thing that is intimidating
well it's like I used to say this.
Mostly I used to say it's about Java.
And you know what?
I'll shit on Java a little bit.
Juicy content.
Here we go.
You know, there's bad C++ code out there, but there's also like good C++ code out there.
Whereas for a language like Java
there's only really mediocre Java code. Shots fired. I myself love all programming languages
and I'm not even gonna say even Java I'm just gonna say Java like is included you know there's
no even there it's all programming languages get a little heart. Fun fact, when I was at LSU, working like my first
six months there before I was a student, when I was just like a college dropout working at the
research center, I worked with this professor, Steve Brand. And for reasons that are still beyond me he asked me to substitute teach for his like intro programming
course one day and it was he was more of a programming languages guy like you actually
we should have him on the podcast sometimes because i just realized that you two are like
shockingly similar in your programming language tastes.
Although he was like, this was a guy who,
if I needed like a script for something,
I could email him with a rough description and he would send back like the most obfuscated Perl script
that you could imagine.
Like no comments, no line breaks,
and it would do exactly what I wanted,
but I'd never know how it worked.
But then I substitute taught for this Java class for like one class. I didn't know anything about Java. I'm not like literally, I'd never written a line of Java code in my life, but somehow I got
through it. I think the students did not realize that I had never written Java code. I think it was early in the semester, so they were still learning about fundamental data types.
And so I just was like, oh, it's like, you know, fundamental data types,
they're basically the same in all the languages.
I can just teach them.
Strings, just plus equal, right?
Yeah.
But that was the one time that I taught a college course.
It was an intro to programming I taught a college course.
Was an intro to programming class in Java.
Yeah.
All right.
Well, back to Jeff's question.
So that's why we like C++, because you can do whatever you want, basically.
Yeah.
And also, when you compare it to sort of the other – that's actually – he asked a follow-up question if we have thoughts on Rust or C++, but I feel like we should save that for another episode when we bring someone on that actually knows about Rust and then we can go back and forth.
So that's why we like C++.
What do you recommend for someone that wants to start learning?
I get this question a lot. A lot of people ask me about book recommendations, and that's always tough for me because I don't really read programming books.
The circumstances that I will read programming books is if like one of my somebody that I know has written a programming book and like I get sent a copy of it.
Like then I'll like read it.
You know, I saw you tweet about Kate Gregory and Guy Davidson's book the other day.
Yeah. And like i've got you
know i've read titus's software engineering at google book but that's not really a programming
book that's a that's a software engineering book there aren't a lot of those um i'm looking at my
shelf here um i've read some of lakos's books um that's john lakos from bloomberg but i don't like
me going to read a programming book
I guess the only two programming books
that I've really ever read have been
Elements of Programming and
Structure and Interpretation of Computer Programs
and Parts of the Art of
Computer Programming Volume 2 and Volume 3
because I only have Volume 2 and Volume 3
as we discussed in an earlier episode
I was gifted those by my mentor Hartmut Kaiser
and I asked where are the other volumes and he's like
you don't really need those.
I don't think that that was his real answer.
I think he just didn't know where they were.
But yeah, I've never really been like a book learner.
So that's always tough for me.
I mean, the way that I, when I started programming, and I think we've discussed this in the podcast before, I wanted to create a text-based game of Mudd.
And I was working with this guy and we were writing it in C++.
And so he was teaching me a little bit about C++.
And then he used one of the Boost algorithms for string splitting.
And then it had a bug in it.
And I went and fixed the bug.
And then I quickly got involved in boost and this was like in like month two or three of me teaching
myself to program um so for me like the way that I learn and get started is I just like
start like I learn by doing I learn by example um so it's hard for me to recommend learning
materials because I have not often used learning materials.
I just like to dive right in.
I don't know.
Do you have books or resources?
Something more useful than what I just said.
I mean, when I really dived into C++, the books that I tore through were Scott Myers books. The effective C++, more effective
C++, effective
modern C++, and then the effective STL
book. I feel like we should publish a book most effective
C++.
Those
are great, although I'm actually not sure
how they've aged. I think they do
actually age quite well, although
now that like 17,
20 are out, I'm sure that there's some stuff
that's out of date and i would definitely say that uh finding i always try and find a
online sort of playground i don't have more effective c++ i only have effective c++
do you have more effective C++?
I mean, the one thing I do like about,
I do particularly like effective C++ and more effective C++
because it's a book that's a list of specific things.
And like, that's something that I can use.
It's like, you give me like a list of like ways to do things.
Yeah, I mean, I feel like,
I feel like most of this is still pretty applicable.
Familiar size, familiarize yourself
with the standard library, including TR1.
That's less applicable.
Familiarize yourself with Boost.
Even though I am a Boost person
and I start enough with Boost,
I feel like that is actually less applicable these days um
yeah i don't know how applicable this this book i feel like i feel like effective c plus plus
um and a lot of c plus plus books of that era era are much more focused on object-oriented design
than on other parts of the language. And at least for me,
it is very rare in my work that questions of the design of inheritance hierarchies or polymorphic objects comes up.
Almost always it's questions of library and interface design
and with simple or relatively simple vocabulary types.
Yeah.
So yeah, if you're looking for a book, honestly,
I would just Google C c++ 20 there's like
five or six c++ 20 books out there so i think i would actually recommend beautiful c++ because
it is a book in the style of like for me it's a good book because it's a book in the style of
effective c++ and that it's like concrete list of, I think it's, hang on, I'll get the copy.
30 core guidelines for writing clean, safe, and fast code. So it's like 30 concrete things
that you can learn and like, or like 30 mantras or takeaway lessons.
And it's just been published. So it's fairly up to date um yeah
and i would say the yeah one of the most useful tools is a compiler explorer which is basically
an online uh compiler that you can just go write your c++ code in the browser. And at least while you're learning, unless if the way you're going to start learning
is by building some project, I would just sort of code there because it's awesome.
Like even half the time when I do development, if I can sandbox it and build up a prototype,
I'll just do it in Godbolt.
Yeah, I do find Godbolt to be a very good resource for learning um and i use it a lot
day to day because if i just want to go answer a quick question about how does something work in
c++ um you know going and doing it on my laptop involves like you know i have to go put a file
somewhere then i have to go find a compiler that works.
And it's like God Vault, it's just the turnaround time is so much quicker.
Yeah.
Yeah, I actually, I think I'm going to be bold and say that, you know,
I rarely actually, like, endorse a book because, again,
like I don't really read them that much
but I really did like beautiful c++ I feel like it's it is a better version of effective or more
effective c++ that has like the guidelines and the rules that I would want to have
so yeah that one that one has my stamp of approval but I don don't know. I think it's good.
I think that sort of book's good if you already know the language
and you want to know how to write it good.
It's maybe not the best for learning the language.
Yeah.
Do we want to talk about tooling?
Well, I think we just did.
We talked about Godbolt.
I know, but outside of Compiler Explorer,
I would say the way that I develop right now is with VS Code and a bunch of extensions.
So Clang Format, Clang Tidy.
And you can, I think, I think Jason Turner,
I'd probably point you to C++ Weekly
because he basically has like a short
five to 10 minute video on every topic under the sun.
And I'm pretty sure
he's got one on claim format he's got one on clang tidy and i think jason turner even has
like a little starter cmake project that has all that stuff set up from the get-go
i feel like my answer is gonna not be very helpful here um which is that what i use vim
i've only ever used vim i started off my career on supercomputers
and uh you know when you work in supercomputing you often you have to go and do stuff on some
obscure system somewhere that's running like rel like a red hat release that was put out
you know before like when you were in high school
and there's like no graphical user interface there's no nice things and like you gotta you
gotta edit some code there and so you know them is the thing that like you can reliably have on
those platforms and or you can easily install um or yourself. Cause I've had to do that many, many a time because the platform had two
engine, a version of them for me to work with and it's like lightweight.
And I've got a little Vim config that I've built up over the years that mostly
functions and I copy that from system to system and that's what I use for my editor.
And like I don't use many Vim features.
One of my colleagues, Mihao, has pointed out that like I don't really know how to use Vim.
I don't know all of the, like every time I'm screen sharing and I'm using Vim, he like
teaches me a new thing and I'm like, wow, that's going to save me so much time.
I don't have it like cooked up with any of the so much time. I don't have it cooked up with any of the IDE features.
I don't use anything like C tags.
I've never used Clang format.
I do use syntax highlighting,
but I'm more and more turned off by syntax highlighting.
What? What?
You don't like syntax highlighting?
You sound like an old grumpy man. I mean, I like an old grumpy man i mean i am an old grumpy
man connor i am an old grumpy man um i mean i i usually i usually use cmake but for a lot of like
little projects i just write a bash script that calls the compiler that I need. I mean, my development life is held together by
bash scripts. So that's me. Yeah. I have used, I did use recently the, God, what is it? I tweeted
about it. I needed to do a PR just on GitHub.
I didn't want to check out anything locally.
And I used the online VS Code thingy on GitHub where if you change the starting URL of a link to something on GitHub, it then drops you into this online VS Code developer environment.
Isn't it just control period as well the shortcut here
let's go try let's go try yeah if i go control dot shift dot yeah shift dot shift setting setting up
the web editor yeah yeah it's if you change it from github.com to github.dev,
then it drops you in this environment.
And I was amazed, listener.
Like, I was like, I need to make this change
where I need to change two files and then, like, submit a PR.
And usually, like, on the GitHub website,
if you need to change one file and submit a PR, that's easy to do.
But if you need to change two files and turn them into a PR, that's tricky. And I was like, I don't want to check this repo out. I have like
10 minutes before I need to leave, but like, I need this change in because like our CI is broken.
And I was able to just like, like I didn't do shift dot, but I did like, I just changed the
URL from github.com to github.dev.
It dropped me into this environment.
I was like able to open up a branch.
I was able to like make my changes and like,
it was just amazing how quickly it was done.
And I was like, this is how I want to write code now.
So yeah.
But I only casually use VS Code.
My day-to-day go-to editor is Vim.
But don't be like me.
Jeff, don't listen to...
Just because I do things this way,
you should do things the way that Connor described.
Use VS Code.
Use Clang Tidal. Do all of those things do all of those good
things don't be like me don't be like me i am i am a bad programmer which is why i mostly don't
write code anymore yep c++ is awesome use a compiler explorer choose whatever book you want
i would also recommend check the show notes i'll'll add a list to the list of talks that the SG, was it 20?
Whatever the education study group is for the C++ committee.
They put together a list of top talks that cover different things.
If it's not included, it definitely should be.
Jason Turner has a talk
that's like you know why i love c++ and it covers the 25 things that he really likes about it best
talks when i was submitting for c++ north i was pleasantly surprised to notice that my talk was
listed my c++ 17 features talk was listed as one of the like talks to like and you should your talks would aspire to
be like this i'm like i kind of put that there for me well but in that talk like did not go great
because i had syntax highlighting on my slides and the blues were too dark for people to read
and like i had to like deal with that mid-talk i don't know how it came out on the recording, but that was rough.
I think maybe I re-recorded because it was bad enough.
I made them re-record it.
Yep.
CPP North.
I mean, Call for Papers is closed,
but I mean, nice try.
Maybe next year at this point.
But you still want people to go to your conference, right?
That's true.
That's true.
That's true. I will true. That's true.
I will probably have to start splicing in.
You're going to throw a – so that conference is like the week of my birthday.
So you're going to throw a ridiculous birthday party for me, right?
Sounds good.
Come to Toronto. You need to start planning that right now.
Should I?
We'll get Louie out from – Louie out.
We'll get Michael out as well uh louie out we'll get michael out as well yeah no like yes
you should be like you should be coordinating with my mother like you should be there's a lot
of things you should be doing right here you have responsibilities sending the pigeons out to the
ducks to let them know to all come make sure that you're in town yeah so jeff i'm not sure if we
really did a good job answering your question i feel like you did a good job of answering the question.
Don't be like Bryce when it comes to programming, apparently.
But yeah, I mean, C++ is a great language.
A lot of great jobs out there.
I mean, honestly, that's...
One of the things he asked was how to get started.
I legitimately think the best way to get started is to just do something.
Do some project in C++. It doesn't really matter what. think the best way to get started is to just do something do some just dive in plus plus um
doesn't really matter what um i feel like i feel like a lot of the times although it sounds like
jeff's a pretty motivated person but a lot of the times when i get that question i'll get people
like just randomly pinging me being like hey i'm interested in topic x like how do i get started
and a lot of the times it's like just dive in. It doesn't matter what talk or what book or what pod.
Find what you like, whether it's audio form or whether it's video lecture form
or whether it's book form or whether it's just literally exploring the language
and breaking things.
Find what method you like the best and just do that.
The hardest part is putting the time in.
I feel like people maybe get a mental block here because they think that becoming a C plus,
like becoming a programmer or learning a C plus plus or learning any new like tech skill,
they think that it's like becoming a lawyer. Like, you know, like what are the, what are the things,
you know, that I have to do to become a lawyer? Like, you know, like there's like this one path
that you have to go through and you have to go get into law school and then you have to do to become a lawyer. There's this one path that you have to go through
and you have to go get into law school
and then you have to get a law degree
and then you have to pass a bar exam in the United States.
It's like there's no certification
for being a C++ programmer.
And I would say there are some things
that are like certifications or programs in tech.
And I think some people think like, oh, well, I go do this and then I will be qualified because I'll have a piece of paper.
And I think that's what trips people up.
It's like that you're thinking that there's some fixed or set roadmap for you to get on like become a C++ programmer. There's not like,
it's different for everybody. So the best way to get started is just, just, you know, figure out
what's the way for you that you're going to learn, you know, figure out what interests you um there's no one fixed path for everybody to enter this you
know this industry yeah yeah absolutely and that's the thing is like i i enjoy all forms i love
lectures i love podcasts i love um reading actually is probably on the lowest on the list but like
i absolutely love listening to podcasts like i listen to like i think at this point like 40 plus podcasts and um yeah cpp cast i think actually we're gonna have to keep track of
this at some point we are gonna be the number two uh c++ podcast out there um currently right now
it depends on how you define what a c++ podcast is because even us, we're like C++++, you know?
But like CppCast is definitely number one.
And I think at the moment, CppChat is number two.
We're going to overtake them.
And if you count us –
Coming for you.
Yeah, if you count us as a C++ podcast, we're number three.
And then –
How are you ranked in terms of subscribers?
It depends. But like on my app that I used, which is CastBox, I believe, it shows both the number of subscribers and the number of plays.
And I sort of they both typically follow.
If you're ahead of in terms of subscribers, you're typically ahead of in terms of views as well.
That being said, so we already just tied CPP Chat on this app with 4,000 views.
But they still have more subscribers.
They've got 274. Don't unsubscribe from them.
Subscribe to us.
I'm kidding.
Don't unsubscribe from them lovely people. Yeah, they've got 274 and to us I'm kidding Don't unsubscribe from them Lovely people
Yeah they've got 274
And we're at 162
But
But our
Our
Our trajectory
Our acceleration
Yes yeah
Is greater than theirs
We've got a lot of momentum
And also
Momentum
A lot of regularity
In that
We've never missed
Also too
Yeah we've never missed a Friday
We're at what
Episode 67 68 What would it take for us never missed a Friday. We're at what? Episode 67, 68?
What would it take for us to miss a Friday?
A pandemic didn't do it.
Oh, yeah.
Should we talk about tail end of this?
All right.
Jeff, I hope that answers your question.
Thank you for putting up with us, Jeff.
We love you.
We love all of our listeners.
We really do.
It's still hard to believe that people want to listen to this.
Yeah, I mean, we did really – we have a little bit fallen off of the wagon.
Yeah, well, don't worry.
Is that wagon?
We can get back on the – no, wagon.
Wagon.
Wagon.
Wagon.
Wagon.
Wagon.
Wagon.
Wagon.
Wagon. say wagon wagon wagon wagon wagon wagon the problem is the problem is is that i'm just having too much fun now
i'm sure i mean i've always i've always described it to people it's like this podcast is all is just
about the bromance chemistry that we have uh
have we mentioned stood reduce in like 10 episodes no uh we haven't but are we having a great time
we should talk about we should talk about stood fold at some point okay all right we'll wrap it
up all right we're having fun good content's coming to actually stop recording because this
is this is how long have we How long have we been recording for?
An hour and 45 minutes.
I've been recording for an hour and 53, so I'm hitting the stop button.
I'm hitting the stop button.
Thanks for listening.
We hope you enjoyed and have a great day.