Carbon is a programming language developed by Google as a successor to C++, and it aims to provide modern safety features while maintaining high performance. It's designed to offer seamless interoperability with C++ while addressing shortcomings of C++, such as slow compilation times and lack of memory safety. Carbon also introduces features like a more readable syntax, improved generics, and automatic memory management while still allowing low-level control. Chandler Carruth is the creator of Carbon, and he leads the C++, CLANG, and LLVM teams at Google, and he also worked on several pieces of Google's distributed build system. In this episode, he joins Kevin Ball to talk about carbon and the future of the language. Kevin Ball, or KBall, is the Vice President of Engineering at Mento and an independent coach for engineers and engineering leaders. He co-founded and served as CTO for two companies, founded the San Diego JavaScript Meetup, and organizes the AI in Action discussion group through Latent Space. Check out the show notes to follow KBall on Twitter or LinkedIn, or visit his website, kball.llc.
Chandler, welcome to the show. Really happy to be here. Really happy to be here. Yeah, I'm excited to dig in. So let's maybe start with a little bit about you, your background, and a little bit about what Carbon is and what led to it. Sure, sure. I mean, I've been a software engineer at Google for a long time now. And when I started, I was pretty fresh out of university and didn't really know what I was doing. Kind of got thrown into a bit of a deep end. And I was working on a C++ project with a bunch of amazing folks who are largely teaching me how to be a good software engineer. And I was incredibly frustrated because the C++ project was just holding me back. Every single step of the way working on the C++ code base was painful. The tools were bad. The experience was bad.
And it seemed like it really, it just, it became an overwhelming kind of problem that we needed to solve. And that kind of kickstarted me diving a whole lot deeper into first compilers, because I thought maybe the compiler was the problem. And as we got better and better compilers, then into the programming language, joined the standards committee, really tried to figure out ways we could much more radically improve C++, the experience for all the developers, and also the quality of the actual software we were able to put out. At a certain point, we weren't actually able to achieve the kind of improvements we needed to. We kept seeing really fundamental risks facing C++, really fundamental problems that needed pretty radical changes to the programming language as a whole and the kind of how the programming language worked in order to credibly address them. Today, I think the obvious and really great crystallization of this is around memory safety and the questions around whether we can use memory unsafe programming languages going forward. But that's just the best example of the fundamental problem that we need to make radical changes to really address programmer needs. And the committee and the standardization process and the C++ language were not realistically going to be able to make the kinds of changes we thought were needed here to address that. And that's where we started working on Carbon.
The flip side of this is we have just, I work at Google and we have an incredibly large C++ code base, right? We have hundreds and hundreds of millions of lines of C++ code we've written. We depend on hundreds of millions of lines of C++ code that the rest of the industry has written in the open source community. And we can't throw that out. Like that's not going away. We don't have the luxury of rewriting all of that. We don't have the time or the teams to do that. And so we needed something we could actually bring all of that code along with us, but get the kind of radical transformative change we're hoping for here. And that's kind of how Carbon started off and really what keeps me really excited about it is to see if we can make those transformative changes to the programming languages.
while bringing the C++ code and existing software along with us. Yeah, let's talk a little bit about what that means to bring it along. Because when I was looking at the website for Carbon, there was a great line which said, existing modern languages already provide an excellent developer experience. GoSwift, Kotlin, Rust, and many more. Developers that can use one of those existing languages should. Now, what in this big legacy C++ code base keeps you from using one of these languages and connecting it through message passing or something? Sure. I mean, sometimes we do. And that's awesome. I mean, Google has almost as much Java code as it does C++ code. And that's great when we can use it.
We have tons of Go code getting written. We're increasingly writing Rust code. When you can do that, when you can just have message passing or some kind of nice API boundary, some abstraction boundary between the C++ software you depend on and new code, that's fantastic. And using one of these languages is amazing. But these abstraction boundaries tend to need to be pretty robust abstraction boundaries. Message passing dimension is a great example of one. We actually have a lot of projects to try and get finer grained abstraction boundaries, lower cost abstraction boundaries, but it's hard.
And so the question is, what about all of the code we need to write that doesn't have that abstraction boundary, that is immersed in an incredibly complicated, often tangled mess of C++ code with no abstraction boundary in sight? We still want that code to move as well. And that's the code that's kind of getting left behind. Yeah. So this reminds me a lot of TypeScript in some ways, of TypeScript being something that you can take an existing, extremely messy JavaScript code base and start just file by file as you're adding new things or you're touching something, upgrading. And then once you compile it, the program doesn't know. It's just fine. Yeah, absolutely.
And I think TypeScript is a great thing to think about because there are also different approaches you can take here. TypeScript takes a really important approach. It basically is a superset. If you have valid JavaScript code, it's basically valid TypeScript code as well. This is super valuable for TypeScript and for languages historically, like C++ did this with C. C, to a certain extent, did this with B before it in BCPL. This is a very, very valuable approach, but it has some limitations. You can't make as radical of changes with that approach.
And for a long time, this was still the only real approach we had. But I think with languages like Swift and Kotlin, we're seeing a different kind of way to do this, where instead of being just a strict superset, you actually have some deep and fine-grained interoperability. But the new code gets to be written entirely in this kind of fairly new, clean space that really relies on very advanced compiler technology that's kind of come around in the last few decades. And so that's why you see this in Kotlin for Java and Swift for Objective-C. Why not TypeScript? And I think this is kind of confusing to a lot of people. It seems like if this is such a better path, why wouldn't TypeScript use it? I think the thing you have to realize is that so much of the JavaScript in the world wasn't compiled. Even though we have that compiler technology, if you haven't been compiling your JavaScript code, you don't have it available. And so they needed to reach back to the superset model. One of the interesting things we're doing with Carbon is leveraging the fact that we do have compilers for all the C++ code. We have a rich build system there. We can take this kind of more advanced approach, which it opens up more freedom. It gives us more opportunities.
So let's maybe dive in a little bit deeper on what that looks like. I think the one that I'm slightly more familiar with is the Java Kotlin example. But there you have the JVM, and you have Java bytecode as a sort of target. And so long as you can compile down to that intermediate language, now you've got an easy form of interoperability. What does that look like in, you mentioned, I think, Swift and also in the Carbon world? This is a great question. And I don't know that I know enough about Swift. I'm not a Swift expert. I don't want to speak for that community. We can just go in Carbon, too. What does this look like for Carbon? Yeah, in Carbon, we can really dive in there. So superficially, it seems like we have something similar, because we have LVM.
And LVM is kind of this very nice base layer that all these languages sit on top of. And so if we compile down to LVM, things seem happy. The interesting problem with that is that LVM is way too low level. The JVM actually exposes the vast majority of Java semantics. If you can get to the JVM, you can actually interoperate pretty well with Java. But LVM doesn't expose any C++ semantics. I don't know if you've looked at the intermediate representation of LVM for some C++ code. It looks nothing like the C++ code. It's gone, right? And so we need something other than that. And that is actually a real challenge. I think we couldn't have done this without the technology that we got in Clang, which is a...
complete production quality C++ compiler. We use it for basically all the C++ code across the entire company of Google, all the platforms, they all use Clang. And this compiler gives us not an intermediate representation or a bytecode like the JVM bytecode or LVM's IR, but it gives us some way of understanding every aspect of the C++ code. Basically, it's the C++ AST that Clang builds. We can't lower it into that, though. It's too specific to C++, but we can use that to build bridges. And so what we do is on the Carbon side, we're going to basically look at the C++ AST, figure out how that should kind of manifest inside of Carbon.
right? Synthesize anything we need in order to kind of realize that interaction with C++ in the carbon side, and then use a combination of both carbon and clang that both of these compilers kind of lower that into LLVM IR to actually implement that interaction. So he's clang to get the fidelity, to get the language semantics, the nuances, the details, and then we lower into the common layer of LLVM for kind of execution and behavior. So when you're compiling carbon, is that also targeting an AST and it's a different type of thing? Oh, this is a great question. It's also a super deep topic because it isn't. So we have a pretty novel architecture for the compiler in carbon.
It looks completely different from anything in Clang, from anything in your textbook compiler. I'm only aware of one other modern compiler that's even going in the same direction. We actually both ended up going this direction in parallel. It's the Zig compiler. So we don't have an AST at all. We have your traditional Lexer that produces a stream of tokens. We have a parser that doesn't have any semantic information at all. It doesn't even know what the language constructs are. It's just basically the grammar productions. And it turns the token stream into a very naive parse tree. But we don't ever build a semantic AST the way you would expect from a programming language. From that very syntactical and structural parse tree.
we generate what we call a semantic IR. It's kind of like an LLVM IR, but also the opposite, where LLVM IR basically throws away all of the semantics other than the execution model and lowers it as far as it can as quickly as it can. We keep everything. And so it represents every nuance of semantics, exactly how all those things work. Everything you would expect in an AST is actually in the semantic IR, but it's represented as kind of an executable IR. It's something you could evaluate or lower into LLVM's IR. And this is a really fun model. It makes it really easy to lower into LLVM IR. It's now a much more direct lowering step.
It also makes it really easy to do stuff like compile time evaluation. And compile time evaluation and metaprogramming have ended up becoming absolutely pervasive in modern programming languages. And so having this representation that tailors itself to those needs gives us a ton of advantages. It also is a lot easier to design this in a way that's fast on modern CPUs. And so one of the big goals of all of Carbon is to have just the fastest compile times that are conceivable across the board. So then putting this together, if I understand, if you're wanting to integrate something Carbon and C++, what you're going to do is you're going to use Clang to compile the C++ down to AST level.
You're going to take that IST over, pass it off in some way to the Carbon compiler where it will translate it to the Carbon IR in a way that can interface. You then also compile your Carbon down to the Carbon IR. That's the layer at which they're going, and then you'd lower that into LLVM. Yes, and it's more complicated, though. OK, keep going. You can do all of that.
But you also, in parallel, have to build synthetic ASTs in Clang to represent all the carbon constructs. Yeah, so it's bidirectional. Bidirectional. Yeah, yeah, yeah. So you have basically like two compilers going through. And on the carbon side, it's all in the semantic IR. And the Clang side is all this AST. And they're each kind of telling the other, I need this construct or I need that construct. These are basically like very, they're veneers, right? They always kind of dispatch back into the actual implementation on the other side. But this builds this bidirectional communication. And then we kind of, both of these compilers, then emit a bunch of LVMIR, which we merge together, and we get the output, right? And this lets us have almost arbitrary carbon semantics exposed in C++.
also arbitrary C++ semantics in carbon, and even better, it lets you bounce back and forth between them. Because you can't say on one side of this, if you have a carbon type, you want to pass it to a C++ API, that API is going to instantiate a C++ template on that carbon type. And that template's then going to call carbon methods. But those aren't just normal methods. They're going to be generic methods that it needs to pass C++ types to. And that's going to go back into the carbon side to figure out how that generic treats that C++ type. And it's going to discover a callback from C++ in that type that it has to call back into the carbon. It goes back and back and forth. Is there any performance cost when you cross that boundary?
I mean, there has to be some. This is a real abstraction that we're keeping. And this is actually a thing we want to do. We want to have an abstraction between carbon and C++, between carbon and clang. We want that abstraction to be fairly rigid so that we can manage the technical debt that we inherit from C++, because we are worried about that. But we don't want it to be a small abstraction. We don't want it to be an expensive abstraction. And so we're trying to make it as inexpensive as possible. We're doing everything we can architecturally to let that abstraction be as near zero cost as it can be. But it can be free. When you are passing data across these layers, are you able to...
do it in a zero copy way and just pass the pointers around? Or do you have to do copies to get it into the new domain? No copies. It has to be zero copies. So we have basically the same memory model. For all of the interrupt, we have to be able to realize kind of the identical ABI and memory layout on each side. And so C++ types, even when we use them in carbon, they have to be laid out according to the C++ rules. Carbon types, even when C++ is using them, have to be laid out according to the carbon rules. And this really does dive into why this is such a tight coupling. Even though we try to maintain this abstraction, the coupling isn't loose. It's a deep, deep impact. And this also means we have some constraints. We don't expect to be able to...
make perfectly exposed carbon types to C++ code that we don't compile. Because we need to tell the compiler how to do fancy layout things, potentially things that don't fit into the C++ model at all. We're going to have the best support we can for kind of pre-existing C++ binaries, but they're going to be much sharper limits there. The best experience of kind of our top priority is you can compile your code with Clang, right? Which means that we can compile your code with this kind of joint Clang plus the carbon compiler and actually give a custom semantics, custom AVI, lay out everything just right so that there's no copy. We don't expect any realistic runtime overhead here. The overhead we expect is compile time, right?
We want Carbon to be a really fast compile time environment, but we are going to take a compile time hit when we reach the C++. We kind of have to. All right. That makes sense. Any other nuances related to this sort of interop layer and how these things are working together? I mean, there are so many nuances here. I think one thing that is really useful to think about is what does it take to do this kind of interrupt? Because I don't think it's obvious when you're kind of looking at it from outside the programming language of the compiler world. People always like to think about really complicated things. Let's think about simple things. What if you have a boring, old-fashioned...
abstract class in C++ with virtual types. We're doing object-oriented polymorphism. I know it's not a trendy thing, but it still is a thing that people do. There's a lot of code out there that does this, right? Yeah, I mean, if you're maintaining millions and millions of lines of code, I'm sure some of them are going to be utilizing this. They were written a while ago. You don't get that overnight. You don't get it overnight, right? And so you've got these things in there, and you need to do this. Well, this means that in order to use it, you've got an API, and it's going to accept a pointer to this abstract base class. And the API documentation is going to tell you, well, you call this by deriving from that, overriding these virtual functions with your specific behavior, and then passing me your object. That's how my API works. But think about what this means. This means that in Carbon,
We have to be able to derive from a C++ base class, get the virtual functions, override them in carbon with virtual functions that we can call using the C++ V table because there's some code that never saw your carbon instance. Like you can't customize this. And then you have to hand that back to C++. And the client has to do the right thing, even though it no longer knows there's a carbon type under the hood. It just has an abstract base class pointer and a V table. And it's like, I don't know, I'm going to do it to a virtual function call. It'll get there eventually. And we have to make all of that work. And so, okay, so there's a lot of compiler infrastructure needed just for this, right? There's also language implications. This means your programming language needs to have inheritance.
right rust doesn't have inheritance goes inheritance doesn't look anything like this like what language are you going to be able to model this kind of dispatcho right this is one feature yeah we can keep going through all of them every aspect of carbon's design actually has to look at c plus plus design and think about like okay what features need to show up in carbon from c plus plus through interrupt what's the model we need to have for this how do we make that work and this adds so much complexity if you look at modern programming languages basically none of them have overloading or variatics the way c plus plus does right the only modern programming language has even tried to do variatics in recent years is swift They have an incredibly cut down minimal version and they added it like in what Swift 5, Swift 6, right? Like they didn't add it in Swift 1. We have to have variatics and like complex, wildly fancy variatics on day one because half of the C++ APIs we want to interoperate with are variatic APIs. They're std format and all of its friends, all of these different APIs that use all of these C++ features. This means we have to start off with both a very specific feature set and a very large feature set to have any hope of success. And that is a real challenge. We've been working at this.
for a few years now because it's so hard to build up this body of design that can actually support the interrupt. I think it's hard for people to see the design impact there. Yeah, well, and this leads us into another area of conversation that I think will be interesting, which is about the language itself, right? Like there's a set of things that you have to implement in order to have C++ interrupt, but also part of your goal here is to get away from some of the C++ systems and build in some new modern things. So what does this language bring us? Great question. So there are a few things. We've already talked about one of them, actually. One of them is fast compile times. I know I harp on it a lot.
It seems like it doesn't actually matter. We have build servers and build farms. It matters so much. It is so painful to sit there. We measure compile time for C++ code in minutes.
So I want you to think for a minute. All of you using Veet that get your millisecond turnarounds in the browser seeing the UI difference. Yep. Let's think what is a computational activity that we do in the modern world and modern computers that takes minutes. I mean, look, we're in the LLM world now, so there's more and more of those going on. Asking like this LLM, this billion variable LLM to synthesize like the work of Shakespeare or some nonsense, whatever it is that we're doing a video, right? Synthesizing a video from a neural network is the kind of thing that takes minutes. We're compiling text.
A few hundred thousand lines of text and we're waiting minutes for it. They have played us for fools. This is absurd. And so I get really upset about compile times. We're not even in the right order of magnitude. We shouldn't be measuring compile times in minutes or in seconds. We should be measuring it in milliseconds. We should be measuring it in things that are kind of interactive speed. We need to get down to that. So that's the first thing we want to bring. And if we look deeper into the language design, one of the biggest things we want to bring is we want to bring some path to kind of the modern requirements of programming languages. The big one is memory safety.
But it's interesting to kind of decompose what you actually need to achieve memory safety, particularly for high performance. Like either you have to sacrifice performance and have a garbage collector reference calendar or something like that. Or to get memory safety in all the performance, Rust has really taught us what we need to do. We need a parametric type system. And we need to be able to parametrize the type system with all of the information that kind of enforces correctness, enforces safety of lifetimes and ownership and all of these things, right? But that parametric type system is kind of the elephant in the room when you get into the PL space, right? Because C++'s parametric type system are C++ templates. And templates aren't super fun.
They don't give you good error messages. It's hard to program with them. They don't have API boundaries. And they also have incredible code size costs and compile time costs. Every programming language that is trying to achieve this kind of guaranteed compile time memory safety is doing it by having definition-checked generic programming facilities. Rust has generics that are checked at definition time. Swift does. They're adding ownership and lifetime things to Swift now. If you look at the predecessors of Rust, all of them modeled this in the type system.
And the nice thing about doing this without templates is they can actually avoid generating a different version of every function for every lifetime equation that it ever shows up in. We already have enough duplicate code in C++. We don't need to multiply that by 10 or more to get memory safety. But that means we have to go back to one of the most controversial features that has ever attempted to be added to C++, the original C++ concepts back before C++ 11. Doug Greger, the eventual designer of Swift, tried to bring this kind of definition-checked generic programming model to C++. It hit a lot of problems, and eventually it hit.
just insurmountable problems. And the insurmountable problems it hit were tied to backwards compatibility issues. The entire design of the C++ standard library needed to change and evolve to leverage this new type system, right? And that was too much of a change. It broke everything. It would have set us back another 10 years, and so the committee had to pull it out. We got concepts, but we didn't get the concepts that actually give us this feature. We got concepts that work with the existing design of C++. That's great for that design, but it doesn't give us the parametric type system that memory safety needs. So the very first thing, probably the biggest single thing that we're adding in Carbon is this idea of definition-jecture generics. But because we're coming from C++, we don't get to just add.
We also have to innovate. We have to build not just a definition check generic system, but we have to build one that includes templates because of Interop. So we have a generic system that can both do definition checking and allow future kind of lifetime memory safety facilities and supports raw templates instantiated just like in C++ with all of the quirks and oddities and behaviors that kind of are necessary to support Interop. But now you get to start moving away from those quirks, right? You get to incrementally say like, you know what? I actually do have an API that this generic conforms to. You can remove the template from it. We'll check it.
right will actually give you code size benefits will give you ergonomic benefits the beautiful error messages all that stuff will start to arrive and you get to adopt that incrementally and i think it's going to be absolutely amazing to have that for kind of library authors for anyone writing generic code to be able to move out of the template world into kind of this checked generic programming world but not leave all of your dependencies behind is going to be amazing and i think that's probably the single biggest like there's a banner feature that really we already have it's going to be that one and the one we're working on next and we just kind of announced that we're actually getting ready to start on designing the memory safety pieces on top of that and so over the course of this year and next year i think you're going to start to see how We're going to layer memory safety as well. And so you both get this more powerful type system and then more powerful safety system as well. Can we maybe talk about what that migration path looks like? So say somebody's built out a bunch of stuff in templates and they want to start migrating over to Carbon generics. What does that look like? Sure. So the first thing is to use something like generics, you need new language constructs, right? And the whole reason we're doing Carbon is that we didn't want to have to try and fit all of these new constructs into C++. Technical debt, complexity, it just didn't make sense. So the first thing you do is you basically take your existing design as it is and you just translate it into Carbon, right? This doesn't give you magically better everything.
We can detect easy cases and be like, we can prove that this didn't need to be a template. We can do some easy cases. But we always have this fallback of like, nope, we're going to faithfully move your C++ code into Carbon. That's going to be fairly automatic. We want that to be kind of click button in the IDE, like as automated as conceivably possible. Once you're there, right? You don't have the better code yet. I mean, there's syntax and keywords. We can talk about that if you want. But like once you're there, then you can start incrementally doing this. And so the first step is you can add a constraint to your template, right? And C++ concepts allow you to somewhat do this. But when you add a constraint to a template in Carbon, we're going to check it more thoroughly.
Because we're going to basically check, if this weren't a template, would it fail? It's still a template. We're going to give you that behavior. But we're going to actually validate that, yes, you actually abide by that constraint. So as you add those constraints, you can then propagate them. Because you have to teach everyone who's using your template to satisfy that constraint. You can propagate them slowly. Because it's still a template, it's OK if there's a layer that hasn't yet documented that it satisfies that. As long as the template did work, you're fine. Once everyone does, you can remove the template. And now that constraint isn't just checked to be correct. It's also required.
And now it can be required and we can leverage it. And so you basically have this free way of adding a new feature that doesn't break anything. There's no ordering dependencies or anything like that. And once you kind of get all of a particular API to use that new feature, you get to restrict it a little bit and kind of start leveraging the new semantics. And the important thing is this is incremental. There's one big bang thing, but that one doesn't do anything exciting. It's designed to be boring. And then all of the exciting pieces are small incremental changes that you can kind of do independently, API by API, almost line by line, and get to the point where you're trying to get there. And this pattern, by the way, is going to repeat.
Yeah. No, I love that, that you're thinking about what does that migration path look like. And it is the type of thing you do anytime you're navigating legacy code, right? You're like, okay, let me get a nice clear boundary around this. Let me, you know, move it into the new place without any functional changes and then start incrementally bringing things up to stop. Great analogy, right? Like I love actually talking about legacy code maintenance because that's really what inspires a lot of this. So how many times do you like go look at legacy code? What's the first thing you do? Like seriously, what's the very first thing you do? Like some really gnarly code you find? Is this tested? That's my first question. Okay, start right and test. What's the second thing you do?
The second thing... The first modification to the code you do. The first modification I would do is try to build an API boundary around it. No, before that. You reformat it. Ah, yeah. OK. Fair enough. Fair enough. Yep. Everyone goes and reformats it. They're like, oh, I'll run my format tool with this, right? Yeah. No, that's a good point. Yep. That's how easy we want it to be to start adopting carbon. Instead of running your format tool, oh, this is old C++ code. I'm going to carbonify it. Now I've got it in carbon. It's not beautiful code yet, right? But just like the formatter tool, at least put it into the pattern I'm used to. It gave me kind of the flavor I expect. Same thing. Now, OK, so this is just crafty carbon code now. All right. And I have all the tools I need to start making it less crafty. Love it. OK. So generic types, parameterized types, all these things. That's a big.
thing what else what else makes carbon distinct what are the modern language features you're bringing into it that you didn't have to bring from c++ but you want so what are some big fun things outside of genetics honestly i think in terms of big things if you look at this from the lens of c++ right what feels new coming from c++ i think generics and the safety things are going to far and away be the biggest new things i don't know how many new things we don't have any plans for other new things because fundamentally the motivating thing for all of this is really memory safety because that's the proximate problem bearing down on us Generics are only even in there because we think they are a critical technical dependency of the only way we really know how to address memory safety at the highest performance level. Beyond that, we're not trying to innovate. So in some ways, this is a weird thing for a program language. We don't have a goal to be new in that way. Instead, what we really want to do is systematically make the existing features of C++ better.
So let's look at inheritance. I want to go all the way back to inheritance. I know maybe it's old school and all of that, but C++ inheritance is kind of a nightmare, right? Like you have inheritance, you have virtual inheritance, you have multiple inheritance, and you have distinct multiple inheritance without virtual inheritance and multiple inheritance with virtual inheritance. I don't know if you've ever played with those parts of C++. Like there are dark, bizarre corners here and people use these things, right? They use them heavily and they really rely on them, but the tools are not good. The use cases are, it's the tools that we need to make better. And so we want to try and look at these use cases and just come in with a better version of the same tools. I don't think this is novel.
but I do think that's going to make a much better experience. So we have single inheritance in Cardam, right? Because that's the one that you can do kind of dynamic dispatch over in a way that's really easy and straightforward. But all of the uses of multiple inheritance, they are real uses. And so we want to try and recast the same core ideas, just typically kind of designed by composition. Like, well, I want this type to have these four facilities. So I have this space class that I'll just like inherit from, and it'll give me some methods and fields that provide those facilities. It's compositional design. There's a good way to do that in modern programming languages. They're called mix-ins.
I mean, you can say that we're adding mix-ins, but we have mix-ins in C++. That's what multiple inheritance gives you, our mix-ins. It's just really, really painful. So what we're going to do is we're going to have mix-ins. We're going to target exactly the use cases we see on C++, make sure that they work easy. They're easy now. They're clean. They're unsurprising. Everything is just like, oh, yeah, of course, that works wonderfully, right? And that's going to repeat. Coroutines is another place where I think we have just so many opportunities to make the experience smoother, cleaner, more enjoyable for users. Error handling. I think we can do error handling so much better. Here's a place where we may actually remove some things. I'm not a big fan of exceptions. I am a big fan of performance.
Maybe we can come up with an error handling system that gets the best of both worlds, right? That gives you kind of the best ergonomics we can manage, but also has the best performance. And that might actually be taking a little bit of some things and exceptions. Might be taking other things from kind of Rust style result types and kind of the monadic transformation that they do. There are a whole bunch of tools we can try and bring together. I don't think of these as bringing something like really new to the language. Everyone can already do error handling in C++. It's just a pain. We're going to try and make it easy.
super, super friendly to users, really easy to kind of compose and use all over the place. And that's kind of outside of memory safety and type check generics, that's really the focus that we have is just take what's already there, but let's make it principled, let's make it understandable, let's make it really easy and fun to use. Yeah, well, and I think it makes sense, right? Still, there are so many hundreds of thousands of people writing C++ code because it fills a niche, despite how painful it is, despite how old and crufty the language is, despite how they have to grapple with multi-minute compile times. If you can capture all those benefits without the costs and bring the development experience up to the modern world, there's a huge opportunity there.
Maybe there's, let's dive a little deeper. So like coroutines and I don't know, virtual inherit, all these are kind of like big features. I think maybe where there's more interesting things that even seem like that we're adding something is if you go, if you zoom way in to the minutiae. Because when you're talking about like, what are the use cases we support? And to your point, do we reach for C++ despite it's paying for it? It's for incredible high performance that is often a problem solved in the minutiae, in the details. That's a place we can actually start innovating some. So here's something that seems like this should be a simple thing.
and the smallest thing in the world in C++. How do you pass an input parameter to a function, right? In every programming language other than C++, there is one obvious answer, and it is the way you pass input parameters to the function. On day one of learning it, the language, like the first function you write, you use the correct way to pass input parameters to the function, every programming language, but not C++. So in C++, we have const references.
which seemed like a really good way to pass things as inputs right it says hey don't mutate this but you get like reference semantics you don't have to dereference it everywhere you can even pass temporaries like you can compute a new value in the argument and that's fine it'll pass as a constant problem But there is a problem. Constreference under the hood is a pointer. And this is very fundamental in C++. You cannot implement C++ with a pointer for a constreference parameter. You can take the address of a constreference parameter inside the function. You can return that address to the caller. It's required to match, right? So it's like, you don't have any flexibility about this. It has to be a pointer under the hood. Pointers have cost. That means every time you access a constreference parameter in C++, you're indirecting through a pointer. Now, some of the time, this is exactly what you want. You had an enormous class, some data structure that you were passing in. You don't want to make a copy of it.
You, of course, want to just give a pointer to the giant data structure you allocated somewhere and then access it. This works great. But what about integers or, you know, something that comes up every now and then in really high performance settings like floating point numbers or SIMD vectors? You don't want a pointer to like a SIMD vector that you're like measuring the exact cycle count of your CPU processing the data to hit a frame rate budget in a video game. That is not OK. It's not acceptable. Right. And so you have to you don't have a single way to pass an input parameter in C++. You have to think about the type of the parameter. Well, hold on. Is this like a small parameter that I don't want to have a pointer to or is it like a big parameter?
And that tells you whether you pass by value or you pass by constant reference. And if that's not bad enough, I mean, I'm already horrified because you've just told every programmer that for like the simplest thing to do in a language, pass an argument to a function. The simplest thing, you have to think carefully and make a decision. I don't know about you, but like decisions are expensive. Like writing code is not that expensive. Making decisions is really expensive. And we have to do it every function signature. But it's worse. Like it's not even that bad. It's much worse than that because of generic programming. I may not know the type of that parameter.
How do I know? Yep, yep. How do I know which one to do? And in fact, there isn't a correct answer in C++. And I mean, so here's something very fundamental. And this is something we definitely can solve. So we're going to have a way of passing inputs, parameters, and carbon. There's one way. It's also, by chance, the shortest way of passing a parameter instead of one of the longer ways with a const reference, right? And so it's going to be convenient, easy. It seems like such a small thing, but every one of these adds up in performance cost. And so one of the interesting things is, I think when people start migrating from C++ to carbon and start using carbon, we're actually going to be able to deliver performance as well as safety.
It's not going to be just one or the other. And the performance isn't going to be because a magical new compiler optimization is unlocked. I mean, I would love it if we did that, but I don't have any magical optimizations left on the table. They're all out there doing stuff already on C++. But we do have our little things. And these little things, I think, really add up. And little things like getting your input parameters right. I don't know if you've got... See, I gave a talk about std unique pointer in C++, which is one of the most basic types. I allocated some memory on the heap, but I own it. And when I'm done with it, it has to be free. Simplest type in the world. It already is a pointer to memory on the heap. But if you pass a unique pointer as a parameter...
You don't get a pointer parameter. You actually get a pointer to a pointer. And again, like, could we fix this? Possibly. But fixing this is a backwards incompatible change. The Standards Committee and C++ are just not in a good position to do, right? And I don't want to say that they're kind of wrong to not make these changes. They just have a different set of priorities. There probably is backwards compatibility, right? Absolutely. I mean, we see this all over the place in software, right? You see this in the new JavaScript runtimes, right? If you can ditch some backwards compatibility, you can build something that's way faster. And I mean, actually, as you were talking about just one way to do it and how that enables performance, it had me thinking about Golang, right? Like, Go does this very well.
Super simple, constrained language, very easy to write performant code. Yeah. You don't have to like think about, oh, have I made the garbage collector's job hard? It's like, no, no, no. It's made sure that the normal thing you do works well, like works well with garbage. It's a beautiful language that way. Well, and in the kind of world we're in now, where more and more of the actual code is being written by coding assistants, and we're the ones making the decisions and then telling it to do it, having one way to do the thing you want to do is also an incredible unlock in terms of productivity. Absolutely. Absolutely. So let's maybe talk about a slightly different thing about this. So this is an early stage project. As I understand, it's an open source project.
And I saw the governance structure. And I thought that might be interesting to talk about briefly, especially because I saw you have two big roles. I saw leads and a painter. And I hadn't seen the painter before. So I kind of wanted to get your take on how is this being governed? And what is that painter role? Sure. So the first thing, just to back up a little bit of context about the governance, I think it's important to really understand what we're trying to set up to do here, right? So a critical thing for a lot of users of C++ is that it has a real governance model. It's not owned by one company.
It's something that they can rely on and that they can participate in that governance, they can contribute to. Like there are a lot of users of C++ who want their voice to be heard and be able to have a say in where the language goes. And so we needed, when working on Carbon, we really needed to make sure we were setting ourselves up for a success path there. I've been in a lot of open source projects and every one of them, when they didn't start off with a governance model and they tried to add it later on, it was chaos and tragedy and pain and suffering all around. Introducing governance late, which is of course when you finally need it, is almost always a painful process.
We wanted to try and address that. And so we decided to front load having a governance process, a governance system, even though Carbon is a tiny little experimental project, it probably doesn't need half the governance infrastructure we've put in place. But now is when it's easy for us to put it in place. And so we've done that. And the whole thing is we're really aiming for the long term here. We want to be set up in a good place. And we are really aiming to be open source in a very fundamental way. We want this governance to be one that can evolve, that can be increasingly community driven and not driven by any one company. And we want to have a clear cut and explicit path to get there rather than trying to do it after the fact or worse, not doing it because we didn't plan for it. So that's kind of what led us to the governance structure.
The flip side is we do need the governance structure to move fast. It is still an early stages project. We don't have the luxury of having a very slow moving, deliberative kind of governance model. The balance we struck here was to basically have three leads. Don't want to have a benevolent dictator for life model. Setting aside other problems with it, it creates a single point of failure. You know, if someone's out sick, how do you make progress, right? We really don't want to get stuck there. And so we're like, what is the least amount of overhead we can have while not having kind of this critical failure mode? We tried actually in the earliest days of the project, tried setting up kind of a more committee structure.
with like eight people and there were votes and rules about how we make progress and it was slow and burdensome and like it didn't work even at the tiny scale it didn't work so we kind of distilled it down like no there are three leads that's enough to kind of rapidly get to consensus right it's enough for us all to develop a really strong rapport with each other so that we can iterate rapidly we should have incredible trust usually one lead is enough to make a decision the other leads are available they'll push back if it's the wrong decision but we don't even have to necessarily synchronize if we're like no this is an uncontroversial thing or in an area we've talked about and that makes it super rapid it even makes it better because now you know if one person's making decisions Then you go on vacation, decisions keep happening, right? It ends up working out really well. Now to make it last long-term, one of the tricky things is you can't just have the same people be leads forever. But again, in early stages of a project, you can't just like rotate leadership and expect to ever get to a good result. So what we've basically done and we've said in our leadership, in our kind of governance model, when the project reaches a level of maturity, we're going to institute term limits and we're going to basically start rotating through the leadership role. And we said that that can't arrive after a particular milestone. So we don't really care when it starts, but we have a bound, an upper bound on how long before we start rotating.
And then we'll probably do kind of nice overlapping terms so that we're not churning all of the leads all at the same time, rotating through them. We'll end up building up an emeritus group of leads so that if someone has a family emergency or a change of job or something, we can just rapidly get an emeritus lead to step back in. We're going to allow people to come back after they leave. So it's also the stakes are lower, right? And people feel comfortable stepping down because, hey, they're going to get to go and recharge for a while and then come back in if they're still super motivated here. Because that's kind of how the structure evolved and how it tends to work. All the decisions we make are public. We always also have to switch hats. So the leads are often technical experts in the community.
but they can't be technical experts while they're making a decision. If they have an opinion about the right technical direction, they have to go and state that publicly as part of the discussion about that decision first. And then we can kind of consider that statement as leads and maybe make a decision that reflects it. And that kind of forces us to be open to engagement with the broader community. And it defends a little bit of the small size of leads because there's not, honestly, there's not a lot we can do as leads. Mostly we just have to participate as technical experts. And then like when there's a question and all of the positions have been aired, they're all written down, everyone understands them. We have to make a call. That's actually the only thing the leads really do.
Even that's a little bit too much. There are a bunch of calls where it doesn't matter. And this always bothers people in programming languages because people get really attached and everything matters. The comic introducer character matters to some people. I get it. It's near and dear to your heart. You see it every day, all day as an engineer. I understand that. But realistically, we're not going to have weighty decisions every time. That's where the painter kicks in. At any point, the leads can simply say, we have a set of options for which there are no technical reasons to choose between.
Maybe we've discarded a bunch of other options for technical reasons as leads. Fine. And it's not one. There's multiple options left, and there's no technical reason to pick one or the other. When that's the case, they can ask the painter, and the painter is basically just a tiebreaker there.
all right, go left, paint the bike shed blue, right? You've gotten rid of all the paints that are going to run, that are going to like not weather well, the paints that cost too much, right? You've gotten rid of all of those, but you still have three different colors. The painter's there to be like blue or whatever color is appropriate, right? For purely aesthetic things, we do have to make decisions still. That's where the painter role kicks in. I really like that because it eliminates one of the most common failure modes I've seen in these sort of consensus-based decision-making structures is when you get to the point where there really isn't a best answer. Yes. And you're just like, well, how do we decide? This person has one opinion, that person has another opinion, but it's nothing but an opinion.
And here's the funny thing. The painter doesn't make any decisions. I was stunned by this. I mean, I put myself as the painter. I freely admit I expected to get to make a bunch of purely aesthetic decisions here, right? Almost none. Like so close to zero, it staggers me. That's not the actual effect it has in practice. In practice, what this does is it gets everyone to stop arguing the aesthetics and actually state the underlying technical reason why one option is preferable to another.
And it does so in a way that's so much less combative. Because if you try and tell people, that's an aesthetic argument. Stop making it. That doesn't work. No, it isn't. It matters to me. I really like blue. It doesn't work. But if instead you say, well, if that's an aesthetic argument, then we have a process we're going to use over here. All of a sudden, now they're motivated to figure out why they actually prefer one based on technical rationale. And the amazing thing is we usually find technical rationale. We almost always find a technical reason why choice A is actually the best choice. It's not aesthetics. It's not zero, but it's really close to zero. How many times it's like, yeah, either spelling is fine.
So that was actually a really interesting thing to me. I think that the paint role is effective even when it is never used. Yeah. It creates a different set of structural incentives. Totally different set of structural incentives and ones that feel much more friendly. That's delightful. Like you can be happy about being forced to find the technical underpinning because it's not like someone's devaluing your judgment. Yeah.
That's great. So let's talk a little bit about language status. I saw that a goal for last year, 2024, was having a working toolchain up through the C++ interop that we talked about today. Yes. Did it happen? No. I mean, you're asking, did a software project hit all of this? The answer is, of course, no. No, it didn't. As per usual, our ambitions exceeded our capabilities. Everything is harder than it looks when you start. We did get a working toolchain. We have a remarkable change in toolchain. At the start of 2024, the toolchain was as nascent as you can imagine. We've done most of our work actually prototyping in kind of an interpreter demo space instead of in the toolchain.
And so the toolchain was just almost nonexistent. At the end of the year, one of the kind of main developers on the toolchain actually got through, I think, 13 days of advent of code in Carbon. Now, most of them included patches to the compiler, which I just said is not really the ideal way to do advent of code, but didn't make it through. Technically, there was someone who did one advent of code challenge on the old interpreter demo in Compiler Explorer on the website. Like writing TypeScript code to upload the additive code problem data and extracts the result. I don't know how they did this. That was amazing. But we got 13 additive code days done on the toolchain with a very minimal number of compiler patches. It's actually a very functional toolchain from a toolchain internals perspective yet. But we didn't get to the point where it's starting to be more functional for kind of users of the language or people evaluating the language, largely because we still need to interrupt. We got interrupt started, but we didn't make much progress on interrupt last year. And by started, I mean we taught the toolchain to have Clang alongside it. Yeah.
as we got into, right? There's a lot of detail and nuance that goes into that. So what are things looking like for this year? I saw the next target, big target beyond that was 0.1. Or is 0.1 when you can do that? What does the next three, six months look like? And if somebody's excited about carbon, when can they start digging in? It's important to understand the sheer time scales here. There's no way that 0.1 happens this year. I wish it could. There's just way too much to do before we can really call it 0.1. If you look at our 0.1 definition, it's actually very ambitious. We want 0.1 to be kind of close to production quality for the purpose of evaluating carbon within a real C++ environment.
I have a real C++ code base and a real use case, and I want to try it out and see how it works in practice. There's tons that we need to do to get there. So this year, our goals are twofold. One, we're going to try and get C++ Interop from the nascent state, where we can load C++ and build that ASD, all the way to actually doing Interop. Specifically, we'd love to do Interop without templates. So no template instantiation, but that fancy virtual dispatch stuff, moving objects back and forth across that boundary, that's our real goal for Interop for this year, because that's going to get the foundations of Interop in place.
And this includes incredibly hard stuff, right? Think about types with operator, not just function overloading, operator overloading. One thing we want is to actually map your operator plus overload in C++. Let's write A plus B on your special vector type. We want you to be able to write A plus B with that special vector type in Carbon. And that Carbon plus maps all the way back through to find your C++. So this is actually still pretty ambitious. And then the second thing is we've gotten feedback already that we really need to accelerate kind of telling a concrete story about how memory safety fits into this picture. So far, it's been fairly aspirational and there's a lot of hand waving. We've got to make it very concrete, very specific. We probably won't get past kind of slideware describing.
the design for memory safety, how it works, how you can migrate towards it. But we at least need to get to that and a very concrete version of that by the end of the year. The team's also grown a little bit. And so I think we actually have the ability to kind of pursue both of these over the course of this year. Awesome. Well, we're pretty close to the end of our time here. Is there anything we haven't talked about that you want to make sure folks are left with? We've talked about all of the amazing and good parts of Carbon, but what about the bad parts? A lot of people I think are a little nervous, like raising bad parts, but I actually, like, I think these are good to talk about too. I can tell you the bad parts I'm hearing, but like any bad parts I think would be great to talk about. Yeah, dive in. What are you hearing about? One that I hear all the time is,
why on earth did you change the syntax so much? What is this like FN keyword nonsense? Why are there colons everywhere? People are really frustrated by that. And a couple of things.
First off, you're not alone. I'm actually really frustrated by a couple of the syntax choices myself. This isn't exactly how I had hoped Carbon would end up looking. I think people are really frustrated because it seems unmotivated. It's not that the syntax choices are necessarily bad, but it seems unmotivated. I think that's actually an important thing to address. So first off, there are two parts in your motivation. You've got cost and benefit. The first thing I think people mistake is the cost. Syntax is relatively cheap. Now, I don't mean to say it's free. Some people are like, oh, it's just like the compiler handles that syntax is free. No, humans also have to read code. Asking humans to see different keywords is a cost.
But mapping from one set of keywords to another in fairly similar positions or adding keywords to a structure that is already relatively similar is something that humans can do it fairly easily. If you look at kind of programming languages that have done that, that it didn't cause massive problems, right? The complaints about Python 2 to 3 were not like new keywords in existing structures. It was that you needed to change the structure in some way, right? So while I understand that there's kind of an emotional immediate reaction when you see this, we don't have any evidence that the cost of this is going to be especially high for the humans. But what's the benefit? The benefit is, I think, really surprising.
We keep finding places where having the simplified syntax, the simplified grammar actually helps make our compile times faster. A lot of people are like, parsing is a solved problem. None of the compile time is spent there. And like, yes, a little bit, but also no, these aren't as separable of problems as they seem on the surface. We find that the grammar structure of the language, we end up using it inside the semantic analysis that's doing type checking. It's the expensive part of the compiler.
When we have the wrong structure, we have to waste time and waste resources actually doing that checking. And so I think it's a little bit more important than people see. And so the big thing I would love to say is just like, we do hear you. We are aware of the cost here. It's just that when we really evaluate it and we play out for the long term, the changes do seem to make sense. And we're constantly evaluating that tradeoff. We may even have the wrong tradeoff. But fun thing, we used to actually have a different grammar in an important way. We used to actually have in variable decorations, you do like variable type colon name equals and your initializer, which is a little bit closer to C++ is type space name equals initializer.
But when we put the colon in, and that was the first thing we did, that was to make the compile times faster. It actually significantly improves how easily this parse is having that colon in there. But when we did, it started to look like decorations in TypeScript and in Rust and in Swift and like in all of these other languages. But every single one of them, the type and the variable name are in the op store. The variable name comes first, then a colon, then the type. Lots of good reasons why they all evolved that way. I was very reluctant to make this change, but we finally decided having a colon, but being different from every language with a colon, was even worse for programmers than having the order the same way around. And it was a hard trade-off that we made. And every time we're going to keep making those trade-offs, we are going to think about it as hard as we can, and we may even change our minds. If carbon 0.1 comes out, and everyone's like, this language is great, but you all have to get rid of this fn keyword.
we're going to get rid of that trail. We are going to respond to this, but we have to be careful. We can't just kind of arbitrarily copy syntax from C++. We have to think about each and every one of these decisions. Well, it sounds like, if I'm not mistaken, like those arguments are happening in public. People can go and see the ways that you're deciding those trade-offs and kind of the justification of, hey, this is aligning with all these other languages that have this type of syntax. Or, hey, this is improving our performance on the parsing step by this much, which has these impacts. There's a public issue on GitHub from when we switched the order of type and variable name, where this is specifically called out as what motivated us to make that change.
I harp on this a lot, but we are in a new era when it comes to code generation tools. And the more it's going to be similar to what other languages expect. The more your generation tools are just going to work, and it's going to be easier to adopt, not only for programmers coming from non-C++ backgrounds, but also for programmers adopting tools trained on a wide range of languages, all of which behave one way. And if yours is the odd one out, it's going to be awful, right? Lots of other complaints, but actually, we actually touched on most of the other complaints. I think a lot of people are worried, this is vaporware, is this ever going to show up? We talked about the timelines there. A lot of concerns around this interrupt thing, it can't work. You can't actually make this work. That's actually why interrupt is such an urgent goal for us. That's why we're prioritizing as highly as we are. We think that...
Really, we have to show our work here. We have to basically show a working version of this for it to be compelling and believable. And we understand that we're going to actually come there with proof in the pudding. I think memory safety, why are you not thinking about memory safety? I think maybe one interesting thing is a lot of people don't understand why we started with the memory unsafe version of Carbon. It's a weird choice in this day and age to start there. And I actually agree, it is weird. The key realization for me was that all of the C++ code we need to interrupt with is also unsafe. It's not that we have the flexibility of choosing here. We have to start off with the kind of primary reason we exist, which is interrupt with C++. We have to make sure that that works.
We still have to make sure we can add memory safety to this. Like if we can't have memory safety at all, none of this is going to work. All of our programming languages are going to end up having to have some kind of memory safety. And so it is absolutely like a necessary goal for us to get to. But if that were our only constraint or our primary constraint, right? That's why people are using Rust. Rust is a great option already. That's why people are using other languages. They start with that constraint. The whole idea of Carbon is what if we start with the constraint of building off of C++? And that means fundamentally building off of unsafe code, right? And unsafe code patterns. So we have to support those as well as we can and then layer memory safety on top. I mean, we still have to prove that one out. And that's one of the things we're working on.
But that's kind of the underlying motivation. It wasn't like, oh, we don't care about this memory safety thing. It's overblown. Totally the opposite. It's that we care about how we get that memory safety on top of existing C++ code. That sounds like a great final cut. So let us hit stop there.