CppCast - Clang Hacking
Episode Date: January 9, 2020Rob and Jason are joined by Saar Raz. They first discuss blog posts covering a new project management tool for C++ and another about improving Clang support for large integer arrays. Then they talk to... Saar Raz about his work to add Concepts support to the Clang compiler. News A new decade a new tool Waiting for std::embed: Very large arrays in clang C++ Move Semantics Core C++: May 26-27, 2020 Links Clang Concepts Repo Compiler Explorer with Clang Concepts Hack && Tell Boston CppCon 2019: Saar Raz "C++20 Concepts: A Day in the Life" CppCon 2019: Saar Raz "How to Implement Your First Compiler Feature: The Story of Concepts in Clang" Sponsors Backtrace Software Crash Management for Embedded Devices and IOT Projects Announcing Visual Studio Extension - Integrated Crash Reporting in 5 Minutes JetBrains
Transcript
Discussion (0)
Episode 229 of CppCast with guest Sar Raz, recorded January 8th, 2020.
This episode of CppCast is sponsored by Backtrace, the only cross-platform crash reporting solution that automates the manual effort out of debugging.
Get the context you need to resolve crashes in one interface for Linux, Windows, mobile, and gaming platforms.
Check out their new Visual Studio extension for C++ and claim your free trial at backtrace.io slash cppcast.
And by JetBrains, makers of smart IDEs to simplify your challenging tasks and automate
the routine ones.
Exclusively for CppCast, JetBrains is offering a 25% discount for a yearly individual license,
new or update, on the C++ tool of your choice, CLion, ReSharper C++, or AppCode.
Use the coupon code JETBRAINS for CppCast
during checkout at www.jetbrains.com. In this episode, we talk about a new project management tool.
Then we talk to Sar Raz.
Sar talks to us about hacking on the Clang compiler and his work to add concept support.
Welcome to episode 229 of CBCast, the first podcast for C++ developers by C++ developers.
I'm your host, Rob Irving, joined by my co-host, Jason Turner.
Jason, how are you doing today?
I'm all right. Rob, how are you doing?
I'm doing fine. Don't really have too much news to share on my end. You?
No, not really.
No conferences coming up or anything for me to talk about. I mean, that I'm doing anyhow.
No, it's still still early in the year, but I'm sure we'll have lots planned soon enough.
Yeah.
Yeah.
OK, well, in that case, I'll get right to some feedback.
This week, we got a tweet from Robert McGibbons saying, I love the show.
And my ears perked up when heard you mention Sean Bax's Circle in the context of the Stood in Bed saga.
Should have him on for a full episode about Circle.
And yeah, I mean, that's definitely something to consider. We have done a couple episodes on other programming languages like Java,.NET, Rust, D.
So it's been a while since we did one of those.
And I believe Circle is a pretty new language. Like that time we mentioned mentioned it when talking about stood in bed was the first time i ever heard of
it yeah i think so too or well who knows how new it is but it's maybe not got a lot of public
consciousness going uh we'd love to hear your thoughts about the show you can always reach out
to us on facebook twitter or email us at feedback at cbs.com. And don't forget to leave a review on iTunes or subscribe on YouTube. Joining us today is Sar Raz. Sar is a tech and C++
enthusiast from Israel. Sar programs in C++ mostly in his free time. In late 2017, he
volunteered to implement C++20 concepts in the Clang compiler and has been working on
that since, now in the process of merging the work into mainline Clang other than C++ and text are also likes graphic design and playing video games.
Sara, welcome to the show. Thank you for having me. Good to be here.
So are you playing any interesting games right now?
I'm playing Death Stranding. Have you heard of it?
I don't think so. I have. It seems like a very interesting game. I have no idea what it's about. It's like, before it came out,
the more trailers I saw of it,
the less I knew about the game,
so I really liked that part.
It's a very bizarre kind of game.
Isn't there a baby in a backpack?
There is.
It involves some babies and some carrying stuff around.
And backpacks.
I thought it all made sense once I started playing it,
but it still doesn't.
Maybe it will someday.
What kind of game is it?
What's the gameplay like?
Best way to describe it is,
do you know that thing when you have a bunch of stuff in your car
and you have to move it to your house?
You try to pile on a bunch of stuff onto yourself
so you don't have to do too many round trips back to the car.
So that's the game, basically.
It's moving stuff around?
Yeah, but you really don't want to have a lot of round trips
because there are monsters in between that if you touch them,
there's an explosion.
Interesting.
It sounds like that old brain tweezer that's like,
you have a wolf, a lamb, and I don't know, whatever,
on one side of the river.
You need to transport them,
but none of the two can ever be left alone together across the river,
and you can only carry two with you at the time.
That's what it sounds like. Yeah, but if they are on the same boat then there's a huge explosion something like that
okay what's the name of the game again death stranding death stranding all right i'm just
gonna look that up because what the heck all right make a note for later yeah well uh in the
meantime we have a couple news articles to discuss uh Feel free to comment on any of these, Sar, and then we'll start talking more about the work you've been doing on the Clang compiler. Okay?
Cool. He is going over this new tool he created, but first going over why he felt this tool was necessary.
And it's basically a project manager, not another package manager, not another build tool, but a tool you can use to manage those things.
It's called DDS, which is think stood for Drop Dead Simple, right?
Did you review this?
I got lost in this article.
Me too, actually.
I can say I have confirmed, in fact, because this is completely off topic,
but several months ago I asked Twitter if I should read Harry Potter
because I said I knew it would be a huge investment for me because I'm a slow reader. And I have confirmed via the Kindle app that I in fact read at one
half the speed of the average reader. Because it'll be like, you have 90 hours left in the book.
The average reader finishes Harry Potter in 50 hours. And I'm like, I am in fact a slow reader.
But yes, it looks like it's meant to work with other build tools no it's not on its own right
right and and also with other package managers it looks like he's configured in such a way that it
could be the library or package manager itself but if you are using vc package or
conan then you could use this with that and the idea is when you
actually you know go to build something it's pretty simple like you know just dds and the
target like msvc or clang or gcc um so it certainly seems like a promising idea he's
definitely saying this is just an alpha right now yeah Do you have any thoughts on this one, Sar?
One nice point I picked up from the article is that he was aiming to
solve, not sacrifice the small edge cases
for the large majority
of libraries that don't need them, which is a good approach, I think.
But I haven't played around with it yet. Maybe I will.
I, yeah, I also kind of picked up on this, on the aspect that you're saying, Sar, and then there's
this one quote, admittedly, closer to the beginning, that really caught my eye. He says,
if you have qualms with me saying that most projects are not special,
it is very likely that your project is not special. And as a trainer, I run into this all
the time and talking to people in the C++ community that like everyone feels like,
oh, we're doing something special. So we have to do X and Y. We, we, we're allowed to invoke
undefined behavior because we're doing something special no like no
one is actually doing anything that different than anyone else well very few people are okay
uh this next one we have is a blog post um from quarantine jabot hopefully i didn't mispronounce
that um we had him on a couple months ago and and he wrote this post, Waiting for Stood in Bed, Very Large Arrays in Clang.
And this kind of refers to the ongoing Stood in Bed discussion.
We've mentioned several articles about that recently.
But in this post, he specifically talks about one thing that you might do now without Stood in Bed,
which is just including large arrays in your C++ code and why it's so slow and he
decided to take it upon himself to look into a possible change in clang and went to start
implementing it to see if he could speed that up and he says he you know admits he still has a lot
more work to do before he could try to maybe get this merged back into Clang. But he did get some gains, I think about like a third the time
to compile an example program with a large array of ints.
And specifically, he implemented an AST node
that is optimized for large arrays of literals.
Right.
Yeah, that looks pretty cool.
Yeah, so I was going to say, of the three of us,
I'm pretty sure only one of us here has actually hacked on Clang.
So I'm curious about Sar's opinion.
I actually read through the article and it brought back memories, I think, of things I tried to implement.
And like Quarantine, you ran into similar problems like facing like enormous accident
like you just run into this function which is like super complex um but then you like you just
you know uh hack stuff around make it work for this simple case and then you iteratively make
it better um so i was actually very happy reading that article. It was encouraging that he didn't quit at any point and just stuck through.
So props to him for that.
And it's a very good approach.
And it sounded like, if I read the article correctly, that the way array literals or the the way, uh, initializer lists are parsed.
That is he has like a hundred places ultimately to change in the code,
something like that. And hasn't quite done all of them yet.
I think that's what I read. Did you have similar experience,
like trying to find all of the places that you needed to? Well, we,
we can talk more about your work in a moment too.
Uh, yeah, there's a lot of overlap
but yeah uh a thing he said there is that um finding where where to put the code is like
um that most of the work is that just like reading through the code and finding the place to change
right um and you often like put it in the wrong place then you realize later and fix that
like uh after the fact uh after like a night of debugging then um but yeah um we'll talk about
more about that later i do think though he does ultimately a good job of why of highlighting
in my opinion the conclusion isn't we need to hyper-optimize arrays of literals.
It was, let's just go ahead and come up with an embed solution.
Because there's so many use cases for it.
Use cases that even, I mean, I've been a huge fan of embed since the beginning.
And things that I hadn't thought of that he outlines at the top of the article.
Yeah, definitely.
Okay, this next thing we have is an announcement that Nikolaj Jusudis has written another book. And this is C++ move semantics. You can check out the details at cppmove.com. And this is an ebook. So I think you can get it now on LeanPub. And it's going to be updated iteratively. But you can go and get it now. Right?
Yeah.
Yeah. Yeah.
He says buy early, save money.
And we have, we've never had a Nikolai on before, have we?
We have not.
We should consider having him on because he's written several books and give lots of talk
on C++.
We should, uh, yeah, we should try to get him on.
I have something of a morbid curiosity as to how long this book is going to be. i want to know what the current page count is yeah that's a good question yes is there
really a full book's worth on on move semantics yeah i feel like i want to hope that there isn't
and i teach move semantics right so like the description of the book is like uh i'm gonna
explain the like reasoning behind
semantics why they're like useful and stuff and then all the pitfalls and all the things you need
to know so that part is probably like uh pretty well that's the bulk of it yeah yeah i see now
it does say 25 000 words and it is 75 complete oh now considering that i had just been looking at my own personal
reading speed i know that all of harry potter is a little over 1 million words so i don't really
know how to scale that to 25 000 words though yeah well that means it should take you less
than 90 hours though that's good i would imagine that's true i think 25 000 actually puts
it in the relatively short side no okay and then the last thing we have uh is you know last week
it was just jason and i and we spent some time talking about all the different conferences
coming up this year and one that we i think we may have mentioned but we didn't have a formal
announcement for yet was core c++ and they did make the formal announcement right after we got that episode
out like 12 hours later.
So it's going to be a May 25th to 27th.
Uh,
and you can submit your talk right now.
And,
uh,
the deadline for submissions is going to be February 15th for core C plus
plus.
And it's in Israel again,
right?
Is it the same place?
It's not the same place.
But Sarga, I think,
could talk more about it, yeah.
Yeah, a different place.
Not that very far.
Not that much far away.
But still, I can tell it'll be very...
It's farther from the beach, though,
I might say.
Yeah, it is.
It is.
Yeah, but you should definitely come.
I enjoyed it very much last year. it. Yeah, but you should definitely come.
I enjoyed it very much last year.
That was actually my first
conference, my first C++ conference
ever.
But it was
pretty high quality, and the talks were good,
and the people were good.
So after that, you did Core C++,
and I know you went went to cbp con
did you do any other conferences last year uh no not yet not yet okay so you are planning to submit
to core c++ again i assume uh i want to i don't have any ideas yet okay well you got a month
five weeks uh yeah but i'm well like i'm pretty have a lot of work this time so one thing
you did not mention your bio and i think it's a good opportunity at the moment is uh what do you
do do you see plus plus professionally uh no actually not right now uh i did um uh i did for
a short time during my uh military service um which is like where which is where I picked up on it again
after I relearned it and got the pretty much
dumb language. But since then, I've only been doing side projects
with C++, unfortunately.
Most people don't think
I programmed in C++ during my military service, but that's not that unusual in Israel, correct?
Okay.
Okay.
So do you want to start off by telling us how you got interested in working on the Clang compiler?
Yeah.
It was like I never sat at home and thinking which side project I should do now
when Hacking on Clang just came up.
It was more of a gradual slippery slope thing.
It started out with me working on another C++ side project.
It was sort of like a game engine of sorts.
It was pretty early stages of it.
And the main thing that got me interested in that direction
is when I got into a situation where the compiler I'm using
and the tool chains available to me
were not enough to solve the problem that I was facing. For example,
in that specific case, I was using
GCC with the concepts implementation that was available back then.
So I was like very, I was told that it was very cool that GCC did have an implementation way back then and I wanted to use
concepts because they were they were cool, but I then ran into like limitations that GCC did have an implementation way back then. And I wanted to use concepts because they were cool,
but I then ran into limitations that GCC had.
And the language as a whole, for example,
I was having a hard time debugging heavily templated code,
which is, I think, a problem many people are facing.
But the toolchain that they had, GCC, didn't really allow me to work on this.
I was feeling that I was hitting the limits of what GCC could provide in terms of debugging,
and I was getting absurdly large error messages and compile times, and the compiler was at its limit, which is the point where I said,
the only way forward in this project
is to do something about it, or drop the project,
or do something like move to a lower standard version
and switch compilers or something.
But the only way to really go forward with this project standard version and switch compilers or something.
But the only way to really go forward with this project was to do something about hitting this limit on the tool chain.
The first thing I did was static print,
which Jason featured on his T++ Weekly.
I did. That was a long time ago.
Yeah, it was a long time ago. Yeah, it was a long time ago.
That was my first attempt at
making things better for myself
with GCC.
It was this
very simple idea. I'd have this
statement that you put
somewhere in your
source and give it some compile time thing
and it would just print the compile time
thing during compilation.
Really handy idea.
Yeah, it was very simple.
It was very understandable and very useful.
It's a simple tool that could be useful for a lot of things.
For example, I wanted to use it to do
poor man's profiling of my compile times.
It's like, put a static for before and after something
and see how long they take to compile
and see the bottlenecks of it.
That's what was the original premise.
So I said, how hard could it be to actually add this right now?
I knew that there was some, like, papers in circulation that were going to add something like this, constexpr trace, I think it was called.
Right.
But it wasn't available to me at that point, and it probably wouldn't be for another couple of years.
But the cool thing about hacking on compilers is that you get to use the features right away.
You don't have to wait for anything.
You may have to wait for them to use it, for example, at work or something.
But this was like very much, you know, a debugging thing that I had to use to write the code.
So I just went for it. And I guess this was what got me hooked.
And after I did that, I ran into the problem that I needed a faster compiler with a concept.
And it seems that no work was being done at the moment to actually get this. It wasn't coming anytime soon.
And then I also said, how hard could it be?
And I guess the basic thing is having something that you,
this problem that you ran into and you want to solve and you're passionate about it and it seems easy enough.
And that was the thing for me that got me interested, I guess.
So did you start by trying to improve GCC's concept support in compile times?
Got concept support, excuse me.
No, I didn't.
Mostly because of my experience hacking on GCC and the static print project.
GCC's code is pretty tough and a friend told me that Clang's code is simpler and more
well written. So I thought implementing it in clang may be more
might be easier than actually trying to optimize bcc which is like this very complex thing and i'd
had to like understand the implementation uh as it is right now like i understand a lot of things
about the compiler uh it seems like a higher barrier of entry for me right uh then just start you know trying to hack
this thing together uh small steps uh i'm sorry go ahead i know okay if um i before i forget i'm
also curious is what is the current status of your static print patch is that still just living on
like are you still maintaining it has it been like that okay no i'm not uh but uh using my
current knowledge in clang it could you maybe add it in a day or something but uh in clang okay yeah
and i have this in gcc i could probably try to hack this together but i'm more focused on
concepts right now right uh so maybe i'll go back to that uh someday just curious so what was
the learning curve like to uh really get going in clang i mean i know you said you didn't do much
in gcc but uh do you feel like you got productive fairly quickly what was it like um yeah so so
in gcc uh doing static print print actually got productive surprisingly quickly.
Like, I managed to get the thing working in, like, a couple of days, maybe, like, three days, getting, like, the initial version working.
Which was, like, a very important, like, positive feedback that I needed to write prove to myself that this is even
a logical thing to try to do
because
it doesn't seem that way. It doesn't seem
that you can just walk into a compiler
and manage to do anything
because they're
advertised as these
things you have
to do compilers your whole life
to understand anything about them
so it was very
surprising and
suspicious that I could
get this working so fast
but again
the work I did on GCC was just like
the work I did in GCC was just like, uh, the work I did in
Clang initially, it was not very, uh, uh, I guess, uh, correct or, um, or it wouldn't
get like merged into GCC just like that.
The fact that it's like working right now is it doesn't mean it's like, uh, drunk ready,
uh, quality code.
Um, but that's not, uh, but, but it's not expected to be, I think.
The thing I did with
concepts was
trying to
break down concepts.
I just went through the paper,
the concepts paper, and broke
it down into these steps that
each of them was like...
I could
describe it in my head,
like the things that we need to do, like conceptually need to do. And there were like,
I don't know, one or like a few, like two, three things that I needed to do to get that part
through. For example, first thing I did was, I'm going to add the concept declaration,
which is this very simple thing.
It's just a template with the concept keyword, a name,
and then an expression.
It's a very simple thing.
And once you look at this small little problem,
it's suddenly not this huge, one of the biggest features in C++ today. It's
this small thing that you need to add. And once you have that, it was very similar to
static print for me. Which, by the way, the thing I did with static print and most of concepts was just like, you know,
I have this thing that I want to add and the compiler already has a lot of things from C++
implemented. And the thing I mostly did was just, you know, copy paste things around. Just like
find the closest thing to a concept that
I could in the language
do a file search for every
occurrence of that name and
copy it
just copy it
and change the name concept
it was this mechanical process
and it worked
pretty quickly
compilers are even built in a way that, for
example, if you add a new declaration, a concept declaration, if you add it to somewhere in
the compiler and you try to compile it, it will tell you the places where you need to
put it will pop up pretty quickly. For example, you have a switch case that handles
everything and it will tell you need to add this case in this switch over here to handle concepts.
And then if you look at this, they're very small things. It breaks it down into these small
problems. They become manageable. You don't really know what you're doing at first. You're just
copying and pasting things around. But I was able to get most of the feature implemented just by doing copy-pasting
and really not understanding anything too deeply.
So this got me to a state where I could write a simple program with concepts
and it would compile.
That sounds like an important
moment to take for a second here and say this is why you don't want defaults in your switch
statements otherwise you would not have been able to easily find all of those yeah yeah it's taken
much longer yeah yeah it's a good lesson no but but like um it is true that the clang for example
is very it's like a very uh a very impressive piece of software engineering.
The code is built very, very well.
Every line of it is very well thought out and written to prevent future problems
and make it relatively easy to come in and make changes without too much hassle.
That's cool.
Yeah, so I was very positively impressed with the code.
And it's like C++11 using relatively modern features
and has a lot of RAII and templates when needed.
And it's a good piece of code.
I want to interrupt the discussion for just a moment to bring you a word from our sponsors.
Backtrace is the only cross-platform crash and exception reporting solution
that automates all the manual work needed to capture, symbolicate, dedupe, classify,
prioritize, and investigate crashes in one interface.
Backtrace customers reduce engineering team time spent on figuring out what crashed, why, and whether it even matters by half or more.
At the time of error, Backtrace jumps into action, capturing detailed dumps of app environmental
state. It then analyzes process memory and executable code to classify errors and highlight
important signals such as heap corruption, malware, and much more. Whether you work on Linux,
Windows, mobile, or gaming platforms,
Backtrace can take pain out of crash handling.
Check out their new Visual Studio extension for C++ developers.
Companies like Fastly, Amazon, and Comcast use Backtrace to improve software stability.
It's free to try, minutes to set up, with no commitment necessary.
Check them out at backtrace.io cppcast do you have did you have any advice or resources
when you were going through this process that were helpful to kind of get working in clang or
do you have any advice you can give to someone who wants to get started in clang themselves
um yeah the first the first thing is is fighting something that you want to
solve you know like uh like the um the stood in bed thing um uh it's like this very uh um
it's probably a problem that the tool chains have right now um and once you find that thing that uh
that you wish your compiler or language could do but can't right now and
you know it seems simple enough. Even simple enough could mean that there is something
like very similar in the language already that does something very similar. If I could just
copy and paste this thing and just change it a little bit. Even if you don't know how to do this yet, but you have this thing that is not like radically different than,
or even like this big thing that you can break down into these steps.
So that's like the first step,
just finding this problem that will get you started.
After that,
you would probably do well to read a little bit of manuals.
The plan comes with a bunch of developer manuals, which can be a little scary at first.
But the things you don't read in the manual, you would discover later after a time session of debugging when you do something that you thought was
okay but was actually very wrong and you found out the wrong way.
The code is good, but it doesn't always protect you from making big mistakes.
But you shouldn't be afraid of making those mistakes.
In the blog post of Corentons, he mentioned that he ran into the function that handles
initialization, or the file that handles initialization in Clang, which is like this huge, huge file
with millions of edge cases.
Not literally millions,
but this huge, huge file
that handles what happens
when you take this array of structs
and initialize it with inline initializer lists.
And you can do all sorts of crazy things with this,
and the compiler has to handle all of them.
Right.
And it's often the case that when you read the code of a C++ compiler,
you find it hard to believe that someone could write this code
that handles this much edge cases.
But that shouldn't keep you from trying to hack on it anyway. The code was built iteratively,
adding stuff over time. So you don't have to at the first try write code
that handles all the edge cases.
But you need to just do the simplest thing you can.
Just try the simplest solution you can think of.
Copying something that seems similar enough
and do just the simplest solution
without thinking about
all the edge cases and do and improve the code via iterations, just like every piece of code.
Write some tests, you find out something doesn't work, you debug it, you find out what was wrong,
and then think of another, the simplest solution that would incorporate the new information.
But the best tip I can give is just don't be afraid to get things wrong. Just copy-paste things around, and you don't need to handle all the complexity at first.
You just need to try the simple things.
And by trying the simple things
first, you get enough
track record with debugging
and understanding the code that
the more complex things
you'd have to do later would
become simpler as
you progress. Because
debugging a code base
is the best way to actually get to know the code base.
Right. So get just, you know, clone the sources, get them, compile them in debug mode and start
and do the simple things, the simplest thing you can think of first uh and it's it probably will be simple uh to do
the simple thing uh surprisingly simple this cup and then you're final what and then you're hooked
yeah yeah and once you get that positive feedback that you can do something if you get if you get
the simple solution working you probably can get the uh the eventual thing working as well through iterations.
But you just need to break it down into simple steps and start working.
Oh, and a very important tip is to use a strong machine to compile the thing.
Otherwise, you don't have to buy a very stock machine
first but if you
get into it seriously
then consider buying
a cloud machine
to do your compilation on
because compile times
of LLVM can be
tough especially
in debug mode
I use a strong
cloud machine to do all my compiling.
Yeah. So have you continued
then to work on these patches since you first presented
on it at Core C++? Yeah, I'm
still doing this in this free time
in any free time I'm getting. I'm not getting a lot
of it but uh
uh yeah it's like an hour every morning a couple uh after work before work um an hour every morning
i would say is that it's a decent commitment for a side project yeah yeah um i'm i've been working
on it for a while but um and it's also uh it it's also at the point where it's not only depending on me right now
because I'm in the process of merging it in.
So I'm also waiting for a code review,
which is like if I had all the time in the world,
it would all depend on me.
It would probably be done right now.
But it's like actually getting it merged is like this slower process,
but it's a very good one.
The code did improve a lot from that process.
So is what you're trying to merge in feature complete
for C++20 concepts?
Yeah.
Right now I'm working on it.
As far as you know.
What was the question again? I... As far as you know. What was the question again?
I said as far as you know.
Since you were talking about all the edge cases earlier,
I was just making a bit of a joke.
As far as I know what?
That it's feature complete.
As far as you know, it's feature complete.
Yeah, it is.
It is feature complete.
Yeah, sorry.
Yeah, the biggest new feature that was added to concepts
was the ter syntax.
You can just write a concept name before any auto keyword.
That was the newest thing.
And actually, my C2P comp presentation gave me the boost I needed to actually get this one implemented.
But yeah, right now it's feature complete.
It's actually also very pretty stable
because I had a lot of people in the community
just helping me test it,
just using it in their projects and reporting bugs.
And so I fixed a lot of them
and there's nothing that replaces actual user feedback
for detecting bugs.
You can write all the tests to do one,
but people actually using it in real projects is the best way to detect bugs.
So I'm pretty satisfied with how the code turned out in the end.
Right now I'm working on, uh, actually merging it, uh, into, uh, uh, Clang.
Hopefully I'm going to get it, uh, in time for Clang 10.
Um, the deadline for that is in seven days from now.
What in the world are we doing?
Taking your time up right now?
Uh, yeah, but, uh, so, um um like everything is implemented so i'm basically just uh waiting for uh cr and fixing cr problems i have uh about uh five out of ten commits uh like the the thing i mentioned
earlier where i broke down the feature into like small steps yes so i'm like five steps in like the merging process um um and most of most of the
other remaining steps have already been through a few like cr iterations what does cr stand for
code review oh okay just making sure um richard smith is doing my cr He is the editor of the standard and the also
code owner of Clang.
A very encouraging thing to know
is that
Richard also started out
his compiler endeavors
by just
having this problem that he needed to solve in a
compiler and cloning the
sources and copying and pasting things around.
We talked about it back in CppCon, and he said that he also just started by copying,
pasting things around, and now he's implemented most features of C++ 11, 14, and 17 in the
Clang compiler.
So there is hope.
That's the way actually to start working on stuff like that.
For example, the first feature he implemented was the ranged for loop.
So that's a very encouraging thing.
So he's doing my code review. A code review from Richard takes a while to fix, but
it's all very very helpful. I'm also learning a lot about the
compiler from his code review, which is very much in a
teaching...
in this very welcoming and teaching attitude. is very much in a teaching,
in this very welcoming and teaching attitude,
like explaining why things are the way they are and just getting the Scogar view
is a very helpful thing
to actually get to know the compiler better.
You don't always,
you can't learn everything through debugging,
so that's, I guess, the final step of actually learning how things work.
That sounds incredibly helpful.
Yeah.
Educational.
Yeah, very educational.
And he's a very nice guy also.
So we have not yet actually mentioned this,
but your fork is currently on Compile Explorer.
It is. It is, yeah.
So anyone who wants to can go play with it, yeah.
Yeah, Matt was kind enough to put it on pretty early, and I guess that was a very big boost to the stability
because people could just experiment with it and find bugs.
Since then, a lot of more people who were hacking on compilers got their experimental
build up in Compiler Explorer. So there's a bunch of experimental builds on the site, like Clang
with experimental concepts, with experimental, a bunch of other implementations of things,
which is pretty cool. And it allows people to experiment with the feature early on and to get
feedback from people.
So you can try it out there.
You can go to concepts.godbolt.org, and it pops up this screen with GCC
concepts and clan concepts set up so you can try out concepts right now.
Or you can even build the compiler yourself.
There is instructions on my GitHub.
And it's not very hard.
LLVM is not very hard to build. It takes a long time, but it's not very difficult.
There's a tutorial on their site and it uses CMake, so it's pretty cool. And another
very cool integration that I got recently was with JetBrains, which were, like, I came
up with this idea that a very cool thing to have would be...
The most annoying thing working with concepts back then,
back when I was using them for my own project,
was that my IDE would not understand what the heck I was doing.
Then the entire code was errors,
and I was wondering when would the time come when my IDE would understand the code that I'm writing.
So I came up to JetBrains and the good thing about hacking on Clang is that it has built-in IDE integration through ClangD.
So they basically could use my branch
and get instant IDE
support for concepts, which is very cool.
It's another incentive to work
on Clang
because you can get IDE support
out of the box from it.
So are you using CLine then for this hacking?
I am using CLine, although
I'm not using concepts in my
LLVM implementation.
Oh, sure, you couldn't.
Well, I mean...
Yeah, LVM is still C++11, but you can use CLion 2019.3, I think that is.
And it has built-in concept support with auto-completion based on concepts.
Nice. It's very, very on concepts and uh nice it's
very very uh it's very cool and i like it a lot um so yeah that was also very nice surprise that
uh that my work i didn't know that when i started out but then working on clang would give me also
ide support was very very cool surprise and uh and jetways dead brains were JetBrains were awesome in this process as well.
That's very cool.
Very cool.
I want to say also just for my own personal experimentation,
your patches seem to be, at least at the moment,
quite complete and robust.
Well, I did a C++ Weekly episode using some of them,
but I was doing things like constraining the return type
of an auto return type function with the ter syntax,
and GCC would allow me to do it,
but would ignore the constraint ultimately.
It would let me return anything.
But your patches would properly fail to compile.
Cool, thanks. GCC did have a big change merged recently
into their concepts implementation,
so I'm not sure about the state of it right now.
No, I'm sure it's all...
I've refrained from submitting any bug reports
on any of these things
because I know everyone's actively working on it.
So I was just going to wait until everyone said our concepts implementation is stable, and then I'll start comparing them against each other and stuff more.
Yeah.
Okay.
Was there anything else you wanted to go over before we let you go, Sar? Yeah, there's another cool thing that I recently,
there's C++20 has the concepts header,
which gives you like standard concepts you can use for your,
just for your programs, like, I don't know,
same as, which is the concept that checks the two types are the same, or callable or assignable from, or all these standard concepts.
This concept header is not yet available in libc++.
But I recently learned that Chris, Christopher DiBella, is working on,
actually, he has an implementation
that's working with my branch and he is working on um merging it into a leap c++ um so maybe we'll
get that support too uh sometime nice uh he said he wasn't inspired by my work to start working on it, so it was a pretty cool side effect.
And yeah, I think that's it.
Sounds like hacking on...
Go ahead.
Sorry.
No, you can go ahead.
It sounds like
hacking on these compilers is a great way to meet people.
Yes, and it got me
to
CppCon.
It was
probably the best thing
I could have asked for
out of this thing.
CppCon does pay the travel
expenses. I probably
wouldn't go there if it wasn't for this
project. It was a very nice gift
that I didn't even think I would get.
Yeah, I think at this point, I think I've officially reached the point where I'm going to mention this. project so that was a very nice gift that i didn't even think i would get but yeah i think and and i
at this point i think i've officially reached the point where i'm going to mention this
on literally every single episode rob since there do seem to be some misconceptions that comes up
people misunderstand what the conferences are willing to pay for not cbp con absolutely is
willing to pay for your travel and hotel and ticket if you're your airline ticket
your hotel and your uh entrance to the conference if you are a speaker you have to request the
support they prefer that your company pays for it but if you're someone like sar who doesn't have a
company that's able to pay for this or willing to pay for it uh then they will pay for it and um
you just have to provide your own food, which admittedly
can be expensive. But I've also watched some of the students bum food off of people and eat very
cheaply. So I know there are options. Yeah. Yeah. And again, conferences are awesome.
I'm really hoping to go to more this year i'm just need to uh i have my uh motivation to think of
another talks talk uh topic um yes the talks are a lot of work but um but i think it's worth it in
the end it's a very uh it's a very unique experience uh for me like meeting richard
smith was uh was worth the entire thing.
Okay.
Well, it's been great having you on the show today,
and great work for everything you've done for Clang,
getting concepts added.
Very good.
Thanks for coming on.
Thanks so much for listening in as we chat about C++.
We'd love to hear what you think of the podcast.
Please let us know if we're discussing the stuff you're interested in,
or if you have a suggestion for a topic, we'd love to hear about that too. You can email all your thoughts to feedback at cppcast.com. We'd also appreciate if you can like CppCast on Facebook and follow
CppCast on Twitter. You can also follow me at Rob W. Irving and Jason at Lefticus on Twitter.
We'd also like to thank all our patrons who help support the show through Patreon.
If you'd like to support us on Patreon, you can do so at patreon.com slash cppcast.
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 was provided by podcastthemes.com.