205: People Don't Use the Weird Parts
18 Jan 2017A surprisingly deep dive into Swift, now that one of us is finally using it.
Episode Description:
- Follow up: MacRumors talks with Lattner
- LLVM
- Clang
- OpenGL
- Swift
- ARC
- Swift Open Source
- Casey's love letter to Swift
enum
s - Swift Evolution "Commonly Rejected Changes" list
- asm.js, WebAssembly & TypeScript
- RxSwift
- Garbage collection vs. ARC
- Ending theme by Jonathan Mann
- Post-show Neutral
Sponsored by:
- Audible: With Audible, you’ll find what you’re looking for. Get a free 30-day trial.
- Eero: Finally, Wi-Fi, that works. Use code ATP for free expedited shipping.
- Squarespace: Build it beautiful. Use code ATP for 10% off your first order.
Chapters
- Intro
- LLVM and Bitcode
- Sponsor: Squarespace (code ATP)
- Management
- Origin of Swift
- Launch
- Swift use by Apple
- Transitional feelings
- Sponsor: Eero (code ATP)
- Open-sourcing
- Server-side Swift
- Low to high, easy to hard
- Sponsor: Audible
- Influences
- Why adopt now?
- Style and idioms
- Rust-style memory model?
- Swift in the browser
- ABI stability
- Leaving it in good hands
- The shoemaker’s language
- Dynamic features
- Community influence
- RxSwift
- GC vs. ARC
- Ending theme
- Post-show: Making splinters
- Post-show: Neutral
Intro
⏹️ ▶️ Casey So let’s start with some follow-up. Why did Chris Latner decide to leave Apple?
⏹️ ▶️ John Last week we talked about this and we tried to list all the reasons we could think of why he might be leaving
⏹️ ▶️ John and I think we covered most of the major threads of speculation and we didn’t really get a lot of listener feedback about
⏹️ ▶️ John it. Anybody who did reply was mostly voting for one of the things we talked about. But here’s the thing on this topic.
⏹️ ▶️ John Unless there’s some kind of like secret doomsday thing about Apple that only Chris knows, it’s
⏹️ ▶️ John not actually that important that we figure out why he left Apple or what was in his heart of hearts,
⏹️ ▶️ John aside from just us being busybodies and just wanting to know, like gossip type stuff. And
⏹️ ▶️ John second, pragmatically speaking, this is just not the type of thing that people who leave Apple talk
⏹️ ▶️ John about. Or if they do talk about it, it’s like years and years later after, no one cares anymore, or
⏹️ ▶️ John it’s not a big deal. So even if there was some deep, dark reason, it’s not like we would know about it
⏹️ ▶️ John until years from now. Honestly, the straightforward, boring explanation is probably the right one anyway.
⏹️ ▶️ John So, you know, I don’t know. What do you think, Chris? That sounds about right to me, John.
LLVM and Bitcode
⏹️ ▶️ Marco Would you ever buy an electric car in white? You
⏹️ ▶️ Casey such a jerk. Why are you so mean to me, Marco?
⏹️ ▶️ Chris Lattner No, no, no. I’m a fan of red cars.
⏹️ ▶️ Chris Lattner, Casey There you go. Yellow, if I could get them.
⏹️ ▶️ Casey Yellow, that’s bold. My
⏹️ ▶️ Casey, Chris Lattner goodness.
⏹️ ▶️ Casey All right. We obviously need to talk about what’s happening right now. So ATP is not
⏹️ ▶️ Casey an interview show, but in extraordinary circumstances, weird things
⏹️ ▶️ Casey can happen. And so in today’s episode, we have an extraordinary circumstance.
⏹️ ▶️ Casey Former Apple employee Chris Ladner was nice enough to join us on the show. And so
⏹️ ▶️ Casey this is going to be three people interviewing one person, which is, to say the least, a bit peculiar.
⏹️ ▶️ Casey And it’s something that we’ve never really done before. So this could be a little bit of a rough ride, but
⏹️ ▶️ Casey we’re going to try to make our best of it. And I’ll just say right up front, thank you so much, Chris, for coming
⏹️ ▶️ Casey on the show. And we definitely appreciate it. To kind of kick all this off, would you mind giving
⏹️ ▶️ Casey us a nickel tour of who is Chris Lattner?
⏹️ ▶️ Chris Lattner Okay. Well, I can try. I’m a programmer. I love coding. I have for
⏹️ ▶️ Chris Lattner a long time. I’m most widely known for starting LLVM
⏹️ ▶️ Chris Lattner and getting it off the ground and handing it off to other smarter people. I started Clang, which is
⏹️ ▶️ Chris Lattner a C++ Objective-C compiler, and likewise got it to the point where it was
⏹️ ▶️ Chris Lattner thriving and then let other smarter people run it, and then started Swift and got
⏹️ ▶️ Chris Lattner Swift going, and it recently got past 3.0, and it has an amazing community,
⏹️ ▶️ Chris Lattner and it has a great team of people running it, and now I’m ready to jump to the next thing. And so
⏹️ ▶️ Chris Lattner I guess the short version of what I’d like to do is tackle really hard problems
⏹️ ▶️ Chris Lattner and do things that most people think are impossible.
⏹️ ▶️ John So we’re gonna go back in time a little bit, and I hope that you could tell us
⏹️ ▶️ John how you ended up coming to Apple, like if you can remember back that far. Like, you, you know, LLVM you started
⏹️ ▶️ John before you were at Apple, right? So how did you end up at Apple? Yeah,
⏹️ ▶️ Chris Lattner that’s a great question. So I started working at LLVM at the University of Illinois. It was a
⏹️ ▶️ Chris Lattner research project, and the, it really was
⏹️ ▶️ Chris Lattner kind of hoped for and designed to be fully general and production quality and all those great
⏹️ ▶️ Chris Lattner things that you’d want as a graduate student for people to use your code, but it also
⏹️ ▶️ Chris Lattner wasn’t. It had a lot of the great architectural ideas maybe, but
⏹️ ▶️ Chris Lattner it wasn’t fully baked. It wouldn’t solve all the world’s problems.
⏹️ ▶️ Chris Lattner And by the time I got to graduate, the question was, what do I do next? And of course my dream
⏹️ ▶️ Chris Lattner was to continue pushing it forward and build it out to be something real. And to do that, I would have to
⏹️ ▶️ Chris Lattner go to a place that would allow me to work on it. and I was really fortunate to have built some relationships with
⏹️ ▶️ Chris Lattner folks at Apple, and they took a chance on me, and I jumped to Apple and started building out
⏹️ ▶️ Chris Lattner LLVM as my job. It was totally a dream of mine. So that’s
⏹️ ▶️ Chris Lattner, John how I got to Apple. Did you
⏹️ ▶️ John graduate? Did you get your degree and then go to Apple?
⏹️ ▶️ Chris Lattner Yeah, yeah.
⏹️ ▶️ John Well, that was nice.
⏹️ ▶️ John, Chris Lattner Otherwise, how would you ever
⏹️ ▶️ John job? Yeah, you can’t get a job without a degree. We all know that.
⏹️ ▶️ John, Casey Yeah, clearly. So
⏹️ ▶️ John how would you explain LLVM to somebody who doesn’t know stuff about compilers? Because we
⏹️ ▶️ John all just rattle off LLVM, compiler building toolkit, or whatever. But how would you explain
⏹️ ▶️ John that to someone, because not all of our listeners are programmers, who isn’t intimately familiar with how a compiler works?
⏹️ ▶️ Chris Lattner Sure. So first, we start with what is a compiler? A compiler is the thing
⏹️ ▶️ Chris Lattner that takes the code that a programmer writes and turns it into something the machine can understand.
⏹️ ▶️ Chris Lattner And so there’s lots of different kinds of computers with lots of different kinds of processors. Most programmers
⏹️ ▶️ Chris Lattner don’t want to have to think about that know about that and they want to program and think at a much higher
⏹️ ▶️ Chris Lattner level than what the actual processor can do. And so the compiler’s job is to transform
⏹️ ▶️ Chris Lattner what the human wrote and to something the machine can understand. Then LLVM
⏹️ ▶️ Chris Lattner is a modular system for building different kinds of compilers because
⏹️ ▶️ Chris Lattner there’s lots of different reasons people would want to use compiler technology. And I think LLVM was most
⏹️ ▶️ Chris Lattner successful over the years because it was built as reusable components,
⏹️ ▶️ Chris Lattner kind of like a framework. And then the framework can be used to solve lots of different problems.
⏹️ ▶️ Chris Lattner And one of the fun things about LLVM is that it was eventually over the years used to solve problems that
⏹️ ▶️ Chris Lattner we had never even imagined, which is really exciting.
⏹️ ▶️ John So one example of the type of problem is I remember from past WWDCs,
⏹️ ▶️ John the idea that the Xcode IDE, the GUI that programmers use to make their applications,
⏹️ ▶️ John that very often in that GUI, you need to do things that have an understanding of the code.
⏹️ ▶️ John But when the compiler is this big monolithic thing, the best you can kind of do is compile everything in the background and
⏹️ ▶️ John spit out some stuff. But when it’s a modular toolkit, you can take those pieces and
⏹️ ▶️ John just use the part that understands like the syntax tree or whatever and iterate them. Was that the first
⏹️ ▶️ John use of LLVM as something other than like a straight up
⏹️ ▶️ John compiler that you just point to your code and produces output? like, in other words, integrating it into
⏹️ ▶️ John applications? Or was there some use before that?
⏹️ ▶️ Chris Lattner Well, I think the first use in production was in the OpenGL stack, which ended
⏹️ ▶️ Chris Lattner up shipping in a late software update for Tiger, as well as in Leopard,
⏹️ ▶️ Chris Lattner which is 10.4 and 10.5. There it was used in
⏹️ ▶️ Chris Lattner a completely invisible way to basically repack data and upload it to
⏹️ ▶️ Chris Lattner the GPU. And so when you’re making OpenGL calls to, say,
⏹️ ▶️ Chris Lattner GL vertex 3F or whatever the low-level GL call is, those
⏹️ ▶️ Chris Lattner vertices need to be transformed into a very specific data format the GPU can understand. And you
⏹️ ▶️ Chris Lattner have a whole bunch of different kinds of calls that can be used to produce vertex or other geometry data.
⏹️ ▶️ Chris Lattner But you also have a matrix of different kinds of GPUs you need to support. And they all have different formats
⏹️ ▶️ Chris Lattner and different capabilities and requirements. And so LLVM was used to generate very small chunks of code to do that.
⏹️ ▶️ Chris Lattner And it was part of the 64-bit bring up in the Leopard time frame. And so that was probably the first
⏹️ ▶️ Chris Lattner completely invisible use of it that used and proved a lot of the code
⏹️ ▶️ Chris Lattner generation technologies.
⏹️ ▶️ John So forgive me, one more LLVM related thing is we’re going to go from what is a compiler all the way down to nitty gritty
⏹️ ▶️ John stuff here. My vague recollection of what you just described, the whole video driver thing, was that
⏹️ ▶️ John there were files on disk in the shipping OS that were basically LLVM byte code, like these little
⏹️ ▶️ John BC files, and they would get slurped up and converted to
⏹️ ▶️ John machine code appropriate for the GPU. Am I right about that?
⏹️ ▶️ Chris Lattner Yeah, you’re absolutely right. And so basically, the way to look at it is the
⏹️ ▶️ Chris Lattner bit code files, the LLVM that shipped with the OS, were little snippets of code
⏹️ ▶️ Chris Lattner that then at runtime were recombined and optimized across. And so that was kind of the library
⏹️ ▶️ Chris Lattner of primitives that the OpenGL runtime used to assemble what it was trying to
⏹️ ▶️ John do. All right, so my question about this, and maybe you kind of alluded to it with either a slip of the tongue or a revealing understanding is,
⏹️ ▶️ John what is the difference between LLVM bytecode and what Apple currently brands as bitcode?
⏹️ ▶️ Chris Lattner Oh, well, are you asking for a historical question? Is this a historical question
⏹️ ▶️ Chris Lattner, John or do you? It’s
⏹️ ▶️ John a technical and historical because I’m confused by the branding and I’m also confused by the tech.
⏹️ ▶️ Chris Lattner So LLVM prior to LLVM 2.0, and these version numbers
⏹️ ▶️ Chris Lattner are the open source version numbers not related to the Apple version numbers, and they’re confusingly different for
⏹️ ▶️ Chris Lattner not very interesting reasons. But before 2.0, it used a really horrible
⏹️ ▶️ Chris Lattner encoding in binary that was branded bytecode because that’s what Java
⏹️ ▶️ Chris Lattner used. It had a whole bunch of problems in that it wasn’t extensible, it was fragile,
⏹️ ▶️ Chris Lattner the LLVM was changing, it didn’t have compatibility. And so
⏹️ ▶️ Chris Lattner in the LLVM 2.0 timeframe, which gosh, it’s probably, I don’t know,
⏹️ ▶️ Chris Lattner 10 years ago or more, it’s been a long time ago now, I
⏹️ ▶️ Chris Lattner redesigned the whole thing and it now uses this quote unquote bitcode format and use bitcode
⏹️ ▶️ Chris Lattner as a term for two reasons. One of which was it was different than bytecode. And so the two could live side by side
⏹️ ▶️ Chris Lattner in the directory tree for a while. And the second reason is that the encoding is a bitstream format instead
⏹️ ▶️ Chris Lattner of a byte stream. But that’s the origin of the term bitcode. You can find
⏹️ ▶️ Chris Lattner documentation on this file format. It’s actually a very general encoding format you can use for
⏹️ ▶️ Chris Lattner XML type purposes. It’s a self-describing file format. And multiple
⏹️ ▶️ Chris Lattner different things can be encoded in bitcode.
⏹️ ▶️ John Yeah, there was definitely some confusion about that, because when Apple presented it, when they presented it as the requirement was the watch apps
⏹️ ▶️ John have to be in bitcode. Marco, you would know this.
⏹️ ▶️ Marco Watch is required. iOS is still optional.
⏹️ ▶️ John Yep, and then TV is required. And they would have you put your stuff in bitcode. And there was a lot
⏹️ ▶️ John of speculation early on about what that meant, like in terms of,
⏹️ ▶️ John does that mean that what you’re uploading is not a finished binary? And therefore, it’s like this
⏹️ ▶️ John machine-agnostic thing could be targeted at any CPU. And the more prosaic version,
⏹️ ▶️ John like it doesn’t mean it’s CPU-agnostic. All it means is that Apple has slightly more freedom
⏹️ ▶️ John to change instructions on the CPUs that they do target. How would
⏹️ ▶️ John you characterize the, what advantage are there of
⏹️ ▶️ John compiling something to bit code and then uploading it somewhere versus sending someone a binary? Sure,
⏹️ ▶️ Chris Lattner there’s a couple of different advantages for that. One of which is that the compiler keeps getting
⏹️ ▶️ Chris Lattner better. And so if the compiler learns a new optimization, it can be applied to existing applications without
⏹️ ▶️ Chris Lattner app developers having to re-upload their app. So that’s one small thing.
⏹️ ▶️ Chris Lattner Other things are that Apple does periodically add new instructions to its CPUs.
⏹️ ▶️ Chris Lattner One example of this historically was the hilariously
⏹️ ▶️ Chris Lattner named Swift chip that it launched, which was the first designed in-house 32-bit
⏹️ ▶️ Chris Lattner ARM chip. This was the iPhone 5, if I recall.
⏹️ ▶️ Chris Lattner, Marco That’s right.
⏹️ ▶️ Chris Lattner So in this chip, they added an integer divide instruction. And all the chips before that didn’t have the ability
⏹️ ▶️ Chris Lattner to do an integer divide in hardware, you had to actually open code it, and there’s a library function to do
⏹️ ▶️ Chris Lattner that. And so that and a few other instructions they added were a
⏹️ ▶️ Chris Lattner pretty big deal and used pervasively, and the only way to tackle that and handle that
⏹️ ▶️ Chris Lattner and use it effectively was to introduce an entire new slice. And so if you’re an app developer back then,
⏹️ ▶️ Chris Lattner you had the V7 slice, which was all the older chips, and then you had a V7S
⏹️ ▶️ Chris Lattner slice, S for Swift, which was the slice
⏹️ ▶️ Chris Lattner that included the integer divide. Now this is a pain for app developers, it’s a pain for Apple.
⏹️ ▶️ Chris Lattner Everybody has to convince all the developers to take it seriously, and if app developers don’t support it
⏹️ ▶️ Chris Lattner then the new hardware doesn’t benefit from it. And so Bitcode allows that kind of thing to go
⏹️ ▶️ Chris Lattner completely away. So with Bitcode, Apple can just recompile the applications in the store and say,
⏹️ ▶️ Chris Lattner ha ha, this device has an integer divide instruction, and it works perfectly with
⏹️ ▶️ Chris Lattner the thinning kind of architecture they have for deploying resources to specific device types,
⏹️ ▶️ Chris Lattner and it all kind of plugs together. Bitcode is not a magic
⏹️ ▶️ Chris Lattner solution, though. It doesn’t, you can’t take a 32-bit app, for example, and run it on
⏹️ ▶️ Chris Lattner a 64-bit device. That kind of portability isn’t something that Bitcode can give you, notably because
⏹️ ▶️ Chris Lattner that is something that’s visible in C. And so, as you’re writing C code, you can write if
⏹️ ▶️ Chris Lattner def, you know, pointer size equals 32, And that’s something that Bitcode can’t abstract
⏹️ ▶️ Chris Lattner over. And so it’s useful for very specific low level kinds of
⏹️ ▶️ Chris Lattner enhancements, but it isn’t a panacea that makes everything magically portable.
⏹️ ▶️ John The same thing I would assume for like architecture changes, especially if there was an Indian difference, because Indianness is visible from the sea
⏹️ ▶️ John world. So you can’t target different Indianness.
⏹️ ▶️ Chris Lattner, John yeah.
⏹️ ▶️ Chris Lattner So it’s not something that magically solves all portability problems, but it is very useful for specific problems
⏹️ ▶️ Chris Lattner that Apple’s faced in the past.
⏹️ ▶️ John And going back to the slice thing, that’s like terminology, the Mako format, where you get to put
⏹️ ▶️ John different architectures worth of executables? Or is that a different?
⏹️ ▶️ Chris Lattner Yeah, I think that’s technology that goes all the way back to Next, when Next supported really heterogeneous
⏹️ ▶️ Chris Lattner different architectures like PA-Risk and Spark and PowerPC and Intel,
⏹️ ▶️ Chris Lattner all back in the Next days. And it allows you to compile your application with
⏹️ ▶️ Chris Lattner multiple slices, they call them. And then there’s a tool called LiPo, which sticks them together.
⏹️ ▶️ Chris Lattner And at runtime, the OS picks the slice that best matches your
⏹️ ▶️ Chris Lattner CPU in practice. And so an app developer can support many different kinds of architectures, and then
⏹️ ▶️ Chris Lattner the OS just does the right thing. And so in today’s world, it’s very common to build
⏹️ ▶️ Chris Lattner an iOS app, for example, for both ARM64 and ARM32. And the way that works
⏹️ ▶️ Chris Lattner in the native, in the simplest cases, is just two different binaries that are stuck
⏹️ ▶️ Chris Lattner together, and then the OS picks the right one to run.
⏹️ ▶️ John All right, I could go on for this forever, but I don’t want to get too far down this rat hole. It’s just there’s some
⏹️ ▶️ John pent up questions about bitcode and bytecode, but now I feel satisfied and we can move on to broader topics.
⏹️ ▶️ Marco You’re sponsored tonight by Squarespace.
Sponsor: Squarespace (code ATP)
⏹️ ▶️ Marco Go to squarespace.com and use code ATP to get 10% off your first purchase. It’s the
⏹️ ▶️ Marco new year. You might have a new project, you might have a new goal you want to reach, and that might involve making
⏹️ ▶️ Marco a website. Make your next move with a beautiful website from Squarespace.
⏹️ ▶️ Marco Squarespace sites are so incredibly easy to make, and they’re incredibly beautiful,
⏹️ ▶️ Marco and the tools are very powerful. This is a great combination that I personally have never seen before
⏹️ ▶️ Marco in the web building space until Squarespace. The amount of power you get with these tools is just incredible.
⏹️ ▶️ Marco You can make so many different kinds of sites with so little effort. Nothing else comes
⏹️ ▶️ Marco close. Your sites look professionally designed regardless of your skill level with no coding
⏹️ ▶️ Marco required, although if you want to jump in and alter some of the code you actually can. But you don’t have to and it
⏹️ ▶️ Marco probably isn’t a good use of your time because Squarespace is such a great platform right out of the
⏹️ ▶️ Marco box. Whether you’re making a website for you or for somebody else. If you make it for somebody else,
⏹️ ▶️ Marco Squarespace is the place you want to do that because you show them how to use Squarespace and then you’re
⏹️ ▶️ Marco done. They’re not coming to you anymore. Squarespace will support it if they need help and they’ll be able to figure things out on their own
⏹️ ▶️ Marco because it’s just so much easier to use than whatever CMS you were going to install on their server. So check it out today. Go
⏹️ ▶️ Marco to squarespace.com, use code ATP to get 10% off your first purchase when you
⏹️ ▶️ Marco decide to sign up.
Management
⏹️ ▶️ Marco Whether you’re making a site for you or somebody else, make your next move with Squarespace.
⏹️ ▶️ Casey So, Chris, how was your transition from coding to being a manager? Because from an outsider’s
⏹️ ▶️ Casey point of view, it looked like you had arrived at Apple, you were working heavily on LLVM, like you had said
⏹️ ▶️ Casey earlier. But over time, I mean, even just looking at the resume on your website, it seems pretty clear that you were doing
⏹️ ▶️ Casey a lot more managing lately than perhaps coding. Or maybe you just worked
⏹️ ▶️ Casey around the clock, that wouldn’t surprise me either. How did you feel about your transition from
⏹️ ▶️ Casey being just a code monkey to being a manager? And I ask in part because at my phase of my career,
⏹️ ▶️ Casey I am still a code monkey, but I think it’s not too far away that I might become a manager. And so I’m curious
⏹️ ▶️ Casey to hear, you know, from one code monkey to another, how did that transition go and what did you
⏹️ ▶️ Chris Lattner Yeah, that’s kind of interesting. So I don’t think it is a hard transition. I’m still
⏹️ ▶️ Chris Lattner writing code. I still love writing code. That’s something that I think is a key part of my
⏹️ ▶️ Chris Lattner identity. In a lot of ways. But on the other hand, it is very strange. So I
⏹️ ▶️ Chris Lattner started managing people at Apple really pretty early on, maybe a year
⏹️ ▶️ Chris Lattner or so after I joined. I started managing two or three people because I
⏹️ ▶️ Chris Lattner was kind of the best person to manage the nascent LLVM effort at the time.
⏹️ ▶️ Chris Lattner And initially it was mostly just being a tech lead. And so if
⏹️ ▶️ Chris Lattner you’ve ever driven a project where you have coworkers that don’t report to you,
⏹️ ▶️ Chris Lattner but you’re kind of guiding them and helping make technical decisions, that’s where it started. Over
⏹️ ▶️ Chris Lattner time, my team grew and eventually ended up picking up
⏹️ ▶️ Chris Lattner and running kind of a second level manager role where you’re managing other managers And
⏹️ ▶️ Chris Lattner each step along the way, it introduces new challenges. And along the way, I told myself that
⏹️ ▶️ Chris Lattner managing is something that I had to do because I was the best qualified to do
⏹️ ▶️ Chris Lattner it, and I didn’t want anybody else to. And that coding was my real joy and passion.
⏹️ ▶️ Chris Lattner And I think that coding really is my joy and passion. But along the way, looking back, I
⏹️ ▶️ Chris Lattner realized that I am actually pretty good at managing. And I really do like building
⏹️ ▶️ Chris Lattner teams. I like working with people. And I’ve never considered myself to be a people person, which is,
⏹️ ▶️ Chris Lattner you know, it’s just very, very odd for me to even think about that. But I actually do understand
⏹️ ▶️ Chris Lattner how people work and can really care about getting the most out of people
⏹️ ▶️ Chris Lattner and working with them to make them successful. And so it’s been kind of a
⏹️ ▶️ Chris Lattner transition over time, but I’ve always hung on to coding. And even though I have a full-time management
⏹️ ▶️ Chris Lattner job, I code like crazy on nights and weekends. And I’m not the kind of guy that likes
⏹️ ▶️ Chris Lattner to sit around idle, and so I’ve always just been busy.
Origin of Swift
⏹️ ▶️ John So, I mean, you can get into as much of this history as you want to, Chris, but how did you get
⏹️ ▶️ John Swift to happen inside Apple? Because from the outside, it’s mysterious to us
⏹️ ▶️ John how big important projects come to be. Like, you
⏹️ ▶️ John know, you name the headlining things that have come out of Apple, we hear that Apple does a lot of things
⏹️ ▶️ John that don’t see the light of day. How did you get probably one of the biggest things ever to come out
⏹️ ▶️ John of Apple, an entirely new language, created in-house? How did you get that to happen and not just be
⏹️ ▶️ John some little thing that was off to the side that fizzled off and disappeared?
⏹️ ▶️ Chris Lattner Sure. Well, so I can tell you about Swift, but I don’t think you should project this onto every other
⏹️ ▶️ Chris Lattner project at Apple because I’m sure they’re all different. So I can just talk about my experiences.
⏹️ ▶️ Chris Lattner So Swift started in 2010. You know, it’s
⏹️ ▶️ Chris Lattner kind of the timing is suspicious because it’s right after a blogger wrote something
⏹️ ▶️ Chris Lattner about how Apple needed a new programming language. I’m not a blogger.
⏹️ ▶️ Chris Lattner Oh, okay. Ars Technica wasn’t a thing?
⏹️ ▶️ John That’s not a blog. That was a prestigious website. It still is.
⏹️ ▶️ Chris Lattner Okay, okay. I stand corrected. So
⏹️ ▶️ Chris Lattner, John I don’t remember
⏹️ ▶️ Chris Lattner if I read it exactly then and that was a causal link to starting working on Swift or
⏹️ ▶️ Chris Lattner if it was just because I had just finished up Clang C++ support and we launched
⏹️ ▶️ Chris Lattner Clang C++. And of course, if you write C++ code, you know how ugly and
⏹️ ▶️ Chris Lattner horrible it is. But if you implement C++, it’s a whole other level
⏹️ ▶️ Chris Lattner, Casey of challenge.
⏹️ ▶️ Chris Lattner And so getting that first release out was a major accomplishment for the entire team. And it
⏹️ ▶️ Chris Lattner was a major, major effort for a ton of people involved. And
⏹️ ▶️ Chris Lattner as is typical, you get something over the finish line. And of course, it wasn’t fully finished. It’s a lot of long ways to go. But a lot
⏹️ ▶️ Chris Lattner of the intellectually interesting, to me at least, pieces were done.
⏹️ ▶️ Chris Lattner That’s when I started thinking about, okay, well what comes next? And then implementing other people’s
⏹️ ▶️ Chris Lattner stuff, like for example, the C, the C++, the Objective-C, standards and
⏹️ ▶️ Chris Lattner languages. But there were things that we weren’t happy with
⏹️ ▶️ Chris Lattner and things I wasn’t happy with. And so SWF started out as just a, let’s
⏹️ ▶️ Chris Lattner see what could be done, right? Let’s see what a much simpler language that doesn’t need a preprocessor,
⏹️ ▶️ Chris Lattner doesn’t need trigraphs, doesn’t need all the weird things that have accumulated into
⏹️ ▶️ Chris Lattner C and C++ over the years. Let’s see what we can do and just try
⏹️ ▶️ Chris Lattner to build something nicer. Initially, it was really just me messing
⏹️ ▶️ Chris Lattner around and nobody knew about it because it wasn’t anything to know about.
⏹️ ▶️ Chris Lattner But eventually, it got a little bit more serious and said, hey, well, after playing around
⏹️ ▶️ Chris Lattner a little bit, I think that this actually could make sense. And so I started talking to my management,
⏹️ ▶️ Chris Lattner started talking to some of the engineers that were working on Clang, and they seemed excited about it. We
⏹️ ▶️ Chris Lattner got a couple people working on it part-time, and I convinced my manager that it was interesting
⏹️ ▶️ Chris Lattner enough that we could have a couple of people work on it. Now, this wasn’t
⏹️ ▶️ Chris Lattner a major commitment. This was a, okay, well, let’s see what there is here.
⏹️ ▶️ Chris Lattner And that started a kind of internal demo schedule and other things, or we set milestones
⏹️ ▶️ Chris Lattner in place and tried to justify the investment that was being put into it.
⏹️ ▶️ Chris Lattner Eventually, it got to the point where it was far enough along that it
⏹️ ▶️ Chris Lattner was posing strategic questions. So the strategic questions were of the form, OK,
⏹️ ▶️ Chris Lattner we have Objective-C. Objective-C is a great language. It is probably
⏹️ ▶️ Chris Lattner directly responsible for the iPhone being successful because
⏹️ ▶️ Chris Lattner it’s really high performance. It allows you to get your job done. It supports high level
⏹️ ▶️ Chris Lattner frameworks in a beautiful way. There’s a ton of stuff to love about Objective-C. And while there are
⏹️ ▶️ Chris Lattner a few things that are ugly about it, some at signs and semicolons and other stuff like that, you know, we can make Objective-C
⏹️ ▶️ Chris Lattner better. And so the question was always, why not just make Objective-C better,
⏹️ ▶️ Chris Lattner right? Why don’t we just keep evolving Objective-C and why do we want to face potential disruption
⏹️ ▶️ Chris Lattner in terms of moving the entire development community to something new. And we kicked
⏹️ ▶️ Chris Lattner that around for a long time. We talked about both sides. And we came to realize that, yes, we can and
⏹️ ▶️ Chris Lattner should make Objective-C better. And we continue to invest in Objective-C. We did things
⏹️ ▶️ Chris Lattner like Arc, for example, which is a major effort. But we got dots.
⏹️ ▶️ Chris Lattner Oh, well, so dot syntax predated this.
⏹️ ▶️ Chris Lattner, Marco Aw.
⏹️ ▶️ Chris Lattner Yeah, dot syntax. So the Objective-C 2 features and the block syntax were all
⏹️ ▶️ Chris Lattner kind of prior to this. I worked on blocks, but it wasn’t in this
⏹️ ▶️ Chris Lattner timeframe. And so we were talking about, okay, well, can we just make Objective-C better? And can we
⏹️ ▶️ Chris Lattner feature creep it to the language that we want for the fullness of time? Because if we can, that’d be much less disruptive
⏹️ ▶️ Chris Lattner to the community. And we decided that, yeah, we can move Objective-C a lot closer to
⏹️ ▶️ Chris Lattner what we want. So we can get automatic memory management with ARC, for example, but we can’t ever take
⏹️ ▶️ Chris Lattner away the problems that lead to Objective-C being unsafe. And
⏹️ ▶️ Chris Lattner the fundamental problem was Objective-C was built on top of C. And C inherently has
⏹️ ▶️ Chris Lattner pointers, it has uninitialized variables, it has array overflows, it has all these problems
⏹️ ▶️ Chris Lattner that even if you have full control of your compiler and tool stack, you just can’t fix.
⏹️ ▶️ Chris Lattner Right, to fix dangling pointers, you would have to fix lifetime issues and C doesn’t have
⏹️ ▶️ Chris Lattner any framework to reason about that. And retrofitting that into a compatible way into the system just wouldn’t
⏹️ ▶️ Chris Lattner really work. If you took away C for Objective-C, you couldn’t use C arrays on the stack,
⏹️ ▶️ Chris Lattner for example. And if you couldn’t do that, there’s entire classes of applications where the
⏹️ ▶️ Chris Lattner performance just wouldn’t be acceptable. And so we went around, around, around. We said, okay,
⏹️ ▶️ Chris Lattner the only way that this can make sense in terms of the cost of the disruption
⏹️ ▶️ Chris Lattner to the community is if we make it a safe programming language, which means
⏹️ ▶️ Chris Lattner not safe as in you can have no bugs, but safe in terms of memory safety, while
⏹️ ▶️ Chris Lattner also providing high performance and moving the programming model forward. And so that was
⏹️ ▶️ Chris Lattner really kind of the ideas that came together to make Swift being worth
⏹️ ▶️ Chris Lattner the investment and being worth being disruptive to the community. So a lot of these
⏹️ ▶️ Chris Lattner kinds of pitches and ideas were being held in very small,
⏹️ ▶️ Chris Lattner small, small meetings. small meetings. And coming
⏹️ ▶️ Chris Lattner out of W3C 2013 is when we and the executive team decided, okay, let’s really
⏹️ ▶️ Chris Lattner commit to this. And that’s coming out of W3C 2013 is when the developer tools team
⏹️ ▶️ Chris Lattner came to know about it and really started working hard on it. And Swift is a
⏹️ ▶️ Chris Lattner huge, huge effort by hundreds of people. And that’s when all the work
⏹️ ▶️ Chris Lattner on bring up the debugger and the IDE support and playgrounds and all the other things that
⏹️ ▶️ Chris Lattner the charge into Swift 1.0 really started coming together and make happen.
⏹️ ▶️ Chris Lattner So that’s kind of how Swift came to be. It was again one step after another building small
⏹️ ▶️ Chris Lattner things, explaining to people why it made sense, why it was worth it. And then also
⏹️ ▶️ Chris Lattner I think that a major important aspect of Swift being I
⏹️ ▶️ Chris Lattner guess worth taking a risk on was that we we told people that we would
⏹️ ▶️ Chris Lattner not guarantee source compatibility in 1.0. And that was really
⏹️ ▶️ Chris Lattner interesting because that actually was a big relief for people because internally
⏹️ ▶️ Chris Lattner that meant that it didn’t have to be perfect when it launched. It meant that we could learn,
⏹️ ▶️ Chris Lattner we could adapt. And that as long as we were clear with the community about that, that that would allow
⏹️ ▶️ Chris Lattner us to get to ultimate greatness and learn from actual usage and practice.
⏹️ ▶️ Chris Lattner And I think that was a really key piece to Swift coming and actually making it to the market.
⏹️ ▶️ John So strategically speaking, when you were doing the work to improve Objective
⏹️ ▶️ John C, did you have in mind the ability to potentially leverage
⏹️ ▶️ John some of that work for Swift? I’m trying to think of the strategy of how you get it done. Part of it is personal
⏹️ ▶️ John relationships and knowing the right people. Part of it is persuasion. You have to persuade them with your technical
⏹️ ▶️ John arguments and your business arguments and stuff like that. And then part of it was part of it also
⏹️ ▶️ John laying the groundwork with efforts and technologies that have multiple uses.
⏹️ ▶️ Chris Lattner Yeah, absolutely. So one great example of that is Arc. It was really clear to me that
⏹️ ▶️ Chris Lattner if we were to get to memory safety, we had to have automatic memory management. And I don’t know if you want
⏹️ ▶️ Chris Lattner to go down the GC versus Arc rabbit hole or not, but Arc seemed like obviously the right
⏹️ ▶️ Chris Lattner model to me and to some other people. And so we
⏹️ ▶️ Chris Lattner said, OK, we need to get to an automatic memory management model. Objective-C isn’t, because
⏹️ ▶️ Chris Lattner Objective-C at the time had the Obj-C garbage collector, which had numerous problems.
⏹️ ▶️ Chris Lattner And so we had to get Objective-C to be memory managed. And so that’s why ARC
⏹️ ▶️ Chris Lattner became a thing. It became a really high priority. And I think that it’s a great example of
⏹️ ▶️ Chris Lattner something that by itself had a huge amount of value to the Objective-C community. And then after that,
⏹️ ▶️ Chris Lattner we had similar other efforts, like modules, for example. That was a huge thing that both
⏹️ ▶️ Chris Lattner improved build time, but was also absolutely essential to enabling Swift code
⏹️ ▶️ Chris Lattner to eventually just say import UI kit and get everything. And so there’s a number of things that rolled
⏹️ ▶️ Chris Lattner out over the years. And it was really funny at the time, because the Objective-C developers
⏹️ ▶️ Chris Lattner externally, and even internally to Apple, always accused the compiler and languages team of taking Objective-C
⏹️ ▶️ Chris Lattner on this random walk. and they didn’t know how it all fit together. And where is the strategy, and
⏹️ ▶️ Chris Lattner why are you guys working on this, and why aren’t you working on some other syntactic sugar for the thing I want? And
⏹️ ▶️ Chris Lattner of course, we could never tell them, but there was a good reason. And so another example
⏹️ ▶️ Chris Lattner of that is the Object to See Literals feature. I think we introduced that in 2013, Firecall, for array
⏹️ ▶️ Chris Lattner literals and other things like that. That
⏹️ ▶️ Chris Lattner was an interesting feature in that it was a relatively small amount
⏹️ ▶️ Chris Lattner of engineering work that brought the Objective-C language much closer
⏹️ ▶️ Chris Lattner to Swift in terms of having arrays and dictionary literals as part of the language.
⏹️ ▶️ Chris Lattner But the real reason for doing it is that it was a small amount of work that moved Objective-C forward which allowed
⏹️ ▶️ Chris Lattner the compiler and language team to focus on Swift.
⏹️ ▶️ Chris Lattner, Casey because
⏹️ ▶️ Chris Lattner Swift was a very large amount of work and that was appeasing
⏹️ ▶️ Chris Lattner the community and solving real problems, but buying time
⏹️ ▶️ Chris Lattner to actually pour into the multi-year project of making the Swift language happen.
⏹️ ▶️ John That’s when you pull out the syntactic sugar. The
⏹️ ▶️ John, Chris Lattner programmers love
⏹️ ▶️ John, Casey it. It takes 10 minutes
⏹️ ▶️ John, Casey Here you go.
⏹️ ▶️ John Everyone applauds when they see the slide. Yay. I mean, in all
⏹️ ▶️ Marco fairness, that was a really big deal.
Launch
⏹️ ▶️ Marco Anyway, so kind of building on the Apple internal reaction thing,
⏹️ ▶️ Marco you know, this language in its development and then its public release
⏹️ ▶️ Marco is probably a fairly unique language in the context in which it was released. You have this
⏹️ ▶️ Marco massive company. I mean, nobody probably had more Objective-C programmers than Apple does.
⏹️ ▶️ Marco And so you have this massive company with tons of internal programmers and a massive internal code base
⏹️ ▶️ Marco that is using this other language. You have this entire community of iOS
⏹️ ▶️ Marco and Mac developers, and then you have the entire world watching every move
⏹️ ▶️ Marco Apple makes and putting it under very, very heavy scrutiny. So the release of this language in
⏹️ ▶️ Marco this context is probably not only very high pressure, but also unique in that
⏹️ ▶️ Marco you knew that you were going to face a lot of people up front. Most languages probably start out with
⏹️ ▶️ Marco a few people using them in some random corner of internet and eventually maybe it slowly takes off.
⏹️ ▶️ Marco This was not that way. And so what considerations I guess went into that and also
⏹️ ▶️ Marco how were you able to convince people even inside of Apple to
⏹️ ▶️ Marco use Swift and how was that going?
⏹️ ▶️ Chris Lattner So I guess there’s different answers to that for different phases.
⏹️ ▶️ Chris Lattner We had no idea that the reaction would be as strong and
⏹️ ▶️ Chris Lattner as positive as it was, and so I think we were blown away and caught unaware
⏹️ ▶️ Chris Lattner in some ways. But in other ways I think we did the right thing. So for example,
⏹️ ▶️ Chris Lattner if you look at Swift over time, Swift 1 and Swift 2 are as similar to Objective-C
⏹️ ▶️ Chris Lattner as we can make them. So if you look at the way that selectors are named, for example,
⏹️ ▶️ Chris Lattner it was very… a very direct correlation. If you look at the way Objective-C
⏹️ ▶️ Chris Lattner or Swift 1 was explained to people, it was explained to people as
⏹️ ▶️ Chris Lattner it’s just like Objective-C. You can use all your same patterns, you can use all the same frameworks, you can continue doing
⏹️ ▶️ Chris Lattner object-oriented programming, you can do all these things. But it also has some cool new things like
⏹️ ▶️ Chris Lattner enums and pattern matching and these other things. And so it’s great because
⏹️ ▶️ Chris Lattner it’s just cleaned up syntax for what you already know, plus it has some new cool stuff that you can play with. Right?
⏹️ ▶️ Chris Lattner And then you fast forward a year or two and the Swift community was really taking off.
⏹️ ▶️ Chris Lattner It was, people were understanding what Swift was about. Swift open source also enabled
⏹️ ▶️ Chris Lattner this. And Swift 3 is really about Swift becoming its own language that was really true
⏹️ ▶️ Chris Lattner to itself and standing, you know, stands by itself. And that’s where you see
⏹️ ▶️ Chris Lattner the method call syntax, for example, being radically changed. a lot of things just
⏹️ ▶️ Chris Lattner kind of coming together and really focusing and polishing the language.
⏹️ ▶️ Chris Lattner In terms of the rise of the community, the external community and people using it,
⏹️ ▶️ Chris Lattner that was really, really hard for us because, so my experience had been
⏹️ ▶️ Chris Lattner with LLVM and with Clang. Clang as a C and C++ compiler and Objective-C
⏹️ ▶️ Chris Lattner was completely different than Swift because when we open sourced
⏹️ ▶️ Chris Lattner and launched Clang, which was at Apple, everybody yawned.
⏹️ ▶️ Chris Lattner, Casey We open
⏹️ ▶️ Chris Lattner sourced it very early on and people said, okay, you’re nuts. Nobody can build a C++ compiler. That’s not a thing.
⏹️ ▶️ Chris Lattner Why are you even messing around with this? And we got one contributor to the project
⏹️ ▶️ Chris Lattner and we had no users. And then we got, a month later, we might get another contributor,
⏹️ ▶️ Chris Lattner another person part-time sending in patches. And it was a very slow growth that
⏹️ ▶️ Chris Lattner was ultimately really great because it was relatively low pressure. With Swift
⏹️ ▶️ Chris Lattner and with the way it was launched, it was completely different because it went from
⏹️ ▶️ Chris Lattner nobody knowing about it to everybody knowing about it overnight, literally, and there
⏹️ ▶️ Chris Lattner being so much excitement, so many people that were nervous and had bad reactions, other people
⏹️ ▶️ Chris Lattner that were super excited, but a lot of people that were suddenly hitting bugs and having challenges and problems,
⏹️ ▶️ Chris Lattner and why did you do this, and why didn’t you do that? And some of that was misguided
⏹️ ▶️ Chris Lattner just because they didn’t know Swift yet, but other aspects were really spot on, and
⏹️ ▶️ Chris Lattner that was when we really started learning about how people were using and started iterating and moving Swift. And
⏹️ ▶️ Chris Lattner Swift between the WWDC launch and Swift 1.0 release changed dramatically.
⏹️ ▶️ Chris Lattner And that was a really, really hard time for the entire team because we really wanted to get
⏹️ ▶️ Chris Lattner it as close as we could to what we wanted, but we had a very short amount of time to do so. And
⏹️ ▶️ Chris Lattner I think that’s been true for SWF2 and SWF3 as well, where we have really high goals
⏹️ ▶️ Chris Lattner for the team and really high goals for what we wanna get done, and that makes it
⏹️ ▶️ Chris Lattner a lot of pressure and a lot of stress. But it’s, I think, worth it to
⏹️ ▶️ Chris Lattner serve and see the community around SWF grow and see people use it
⏹️ ▶️ Chris Lattner and see people learn it and it’s been a lot of fun.
Swift use by Apple
⏹️ ▶️ Marco So I’m curious, I know when Swift first came out, it was hard to get a lot of adoption
⏹️ ▶️ Marco inside of Apple for various tooling reasons, among maybe whatever else was
⏹️ ▶️ Marco going on. How is internal adoption going today? Are we seeing meaningful adoption
⏹️ ▶️ Marco now, or is it mostly iOS programmers who are using it and not anybody inside? The
⏹️ ▶️ Chris Lattner Swift team itself has specific goals they need to achieve before there can be truly,
⏹️ ▶️ Chris Lattner across the board adoption at Apple. ABI stability is the number one thing
⏹️ ▶️ Chris Lattner that prevents framework developers, for example, from adopting Swift. So that’s a really
⏹️ ▶️ Chris Lattner important thing, and that’s one of the reasons it’s always a really high priority. But Swift has been adopted
⏹️ ▶️ Chris Lattner by application developers and other things. The Doc is public, Swift Playgrounds app
⏹️ ▶️ Chris Lattner is public, the music app in iOS is publicly known. So there are definitely some big
⏹️ ▶️ Chris Lattner adopters. More broadly, though, the big problem is is that I think,
⏹️ ▶️ Chris Lattner I won’t speak for everybody, but many, many people doing object to see development
⏹️ ▶️ Chris Lattner at Apple are chomping at the bit. They want to be using Swift, and so it’s really a matter of just getting the technology
⏹️ ▶️ Chris Lattner problem solved and checking off the things that are holding people back. It’s not about
⏹️ ▶️ Chris Lattner people dragging their feet and not wanting to use it. Makes sense.
⏹️ ▶️ Casey Yeah, that’s really awesome. From the outside, it’s so hard to figure out, is Apple
⏹️ ▶️ Casey internally like, ugh, really? Or is Apple internally, like you said, really excited? And I’m
⏹️ ▶️ Casey sure that there’s some of both, but that’s really good to hear.
⏹️ ▶️ Chris Lattner Yeah, and I think it’s also changed over time. When Swift first came out, of course, it was a huge surprise
⏹️ ▶️ Chris Lattner for most of the software team. And so, you know, many people went
⏹️ ▶️ Chris Lattner through the usual phases of, I already know Objective-C, why would I learn this new thing? Objective-C
⏹️ ▶️ Chris Lattner is great, and Objective-C is great. So that’s an objective statement, right?
⏹️ ▶️ Chris Lattner But I think things have shifted over time, and as Swift has matured, it’s definitely become a
⏹️ ▶️ Chris Lattner lot more appealing. One other technology problem that is hilarious, but
⏹️ ▶️ Chris Lattner also really important is the Apple Framework stack has to support 32-bit
⏹️ ▶️ Chris Lattner Mac apps. And 32-bit Mac apps have this interesting challenge of, they have what’s called
⏹️ ▶️ Chris Lattner the classic Objective-C runtime, which doesn’t support things like non-fragile instance
⏹️ ▶️ Chris Lattner variables and things like that. And so at some point in time, the Swift team will need to make the
⏹️ ▶️ Chris Lattner Swift runtime work in that mode or figure out some other solution to adapt it
⏹️ ▶️ Chris Lattner because until that happens, it won’t be possible to use Swift in AppKit, for example.
⏹️ ▶️ Casey Huh, that’s fascinating. So kind of taking a more broad
Transitional feelings
⏹️ ▶️ Casey Do you, could you name either your most proud accomplishment during your time at Apple that
⏹️ ▶️ Casey you can discuss publicly anyway? Or if not your most proud, just one, the first one that jumps to mind?
⏹️ ▶️ Chris Lattner I don’t know, I’ve been really fortunate to work on so many really important projects.
⏹️ ▶️ Chris Lattner And I mean, I think that between LLVM and Swift, for
⏹️ ▶️ Chris Lattner example, it’s really a hard call. Swift, I think,
⏹️ ▶️ Chris Lattner impacts more people in terms of the number of people that actually know they’re using it
⏹️ ▶️ Chris Lattner and wanna learn it and things like that. But I think the LLVM has been picked up and used so far
⏹️ ▶️ Chris Lattner across industry and it’s kind of standardizing the world’s compilers. I think that that’s probably
⏹️ ▶️ Chris Lattner more profound at this point. So it’s really, it’s a hard call. I
⏹️ ▶️ Chris Lattner mean, there are a ton of really, really
⏹️ ▶️ Chris Lattner great opportunities that I’ve had and it’s been a lot of fun over many years now. Also, outside the open source
⏹️ ▶️ Chris Lattner pieces, working with the Xcode team and working with the other teams and developer tools has been really
⏹️ ▶️ Chris Lattner phenomenal. I mean, there’s so many great people at Apple and in developer tools, it’s just been a joy.
⏹️ ▶️ John So what do you expect to miss most about being at Apple? And I’m gonna let you
⏹️ ▶️ John expound on this, but I’m gonna take it off the table and say you have to pick your second choice. You’re gonna say you miss the people because of course
⏹️ ▶️ John you do, right? Yes,
⏹️ ▶️ John, Chris Lattner that is actually what I would say.
⏹️ ▶️ John Right, but you know, so go ahead and tell us about all the great people you work with at Apple, But besides that, what do you expect
⏹️ ▶️ John to miss most about Apple, the company?
⏹️ ▶️ Chris Lattner Well, so the great thing about Apple and the thing that I don’t think that many people
⏹️ ▶️ Chris Lattner really get about Apple is that it is really one of the few best
⏹️ ▶️ Chris Lattner places in the world where you can work hard, but also work on products that ship
⏹️ ▶️ Chris Lattner and that ship to millions of people so that your hard work ends up mattering.
⏹️ ▶️ Chris Lattner Right? There are a lot of places you can work hard. There’s a lot of places that you can
⏹️ ▶️ Chris Lattner work on interesting things, but there’s also a lot of places that end up not shipping a lot.
⏹️ ▶️ Chris Lattner Or if they ship it, very few people actually use it. And so Apple’s really, really magical
⏹️ ▶️ Chris Lattner in that it combines being able to work hard and do great things
⏹️ ▶️ Chris Lattner with it actually mattering. And to me, that’s the thing that is just so phenomenal
⏹️ ▶️ Chris Lattner about Apple.
⏹️ ▶️ Marco So moving on to your new role at Tesla, do you think that Swift
⏹️ ▶️ Marco will still be a major part of your work life in some way? Or will it basically
⏹️ ▶️ Marco be something you do in the evenings and weekends? Because we all know that Silicon Valley tech startups don’t
⏹️ ▶️ Marco usually work people too hard, so you’re going to have tons of free time, right?
⏹️ ▶️ Chris Lattner Yeah, so this jump I’m making is definitely do a cushy,
⏹️ ▶️ Chris Lattner, Marco easy job with no stress.
⏹️ ▶️ Chris Lattner, Casey That’s
⏹️ ▶️ Chris Lattner That’s what I’m looking for here. So
⏹️ ▶️ Chris Lattner I don’t know. We’ll have to see. I haven’t started yet and I think it’s going to be a very challenging job.
⏹️ ▶️ Chris Lattner And one of the reasons I’m excited about it is because I really want to throw myself into another hard technology problem.
⏹️ ▶️ Chris Lattner And so I’m really excited about that. I do expect to be involved with the design of Swift and
⏹️ ▶️ Chris Lattner helping with the core team and helping Swift evolution process and helping in a lot
⏹️ ▶️ Chris Lattner of that kind of respect. But one of the things to keep in mind is that Swift is actually a really
⏹️ ▶️ Chris Lattner tiny slice of my job at Apple. And so, you know, I had
⏹️ ▶️ Chris Lattner a very full schedule dealing with lots of other stuff and it was already kind of a nights and weekends
⏹️ ▶️ Chris Lattner project that I was coding on it and contributing at the level that I was. So I’m hoping
⏹️ ▶️ Chris Lattner that there won’t be a big change, but honestly, I’ll have to see. I care a lot
⏹️ ▶️ Chris Lattner about Swift and I really want it to get to its goal of world domination. So…
⏹️ ▶️ Marco We’re sponsored tonight by Eero.
Sponsor: Eero (code ATP)
⏹️ ▶️ Marco go to Eero.com, that’s E-E-R-O.com, and use code ATP when you order for free
⏹️ ▶️ Marco extra shipping. Wi-Fi is broken. You probably have one Wi-Fi router with,
⏹️ ▶️ Marco if you’re lucky, a bunch of antennas on it that look hideous, and you’re trying to cover your whole house with Wi-Fi,
⏹️ ▶️ Marco but it just doesn’t reach every room. It just doesn’t reach everywhere because Wi-Fi is hard when you’re just covering
⏹️ ▶️ Marco it from one point. Eero solves this problem by having a router system where they will,
⏹️ ▶️ Marco they have this little Eero unit. It’s nice, it’s attractive, it’s It’s tastefully designed. There’s not a bunch of antenna sticking out of it.
⏹️ ▶️ Marco And you can buy one of them, or you can buy 10 of them, or any number in between. And you put
⏹️ ▶️ Marco them around your house, and each one covers the area in Wi-Fi, and they all talk to each
⏹️ ▶️ Marco other wirelessly. So you don’t have to run wires all over your house. You can have your entire house blanketed
⏹️ ▶️ Marco in Wi-Fi with Eero. And they talk to each other over this mesh network, so it’s even faster than previous,
⏹️ ▶️ Marco if you ever use like an extender, or anything else, extenders are very slow. It’s even faster than that by a lot. An Eero
⏹️ ▶️ Marco is true enterprise grade quality and performance. They have everything you need from encryption features
⏹️ ▶️ Marco to things like parental controls. And they’re actually updating it over time. They’ve done over 12 updates since launch
⏹️ ▶️ Marco with more to come to add features. They have an app for very easy setup and they have incredible
⏹️ ▶️ Marco customer support if you need it. They recommend one Eero per 1,000 square feet. So the typical home will have
⏹️ ▶️ Marco two or three of them. They got a three pack as a pretty reasonable starting point for almost everybody. There’s a 30 day
⏹️ ▶️ Marco money back guarantee if you don’t like it or if you just buy too many, you wanna return a couple of them if you end up not needing
⏹️ ▶️ Marco as many as you bought, check it out. The reviews are stellar. They back this up. Go to
⏹️ ▶️ Marco Eero.com, that’s E-E-R-O.com, and use code ATP when you order for
⏹️ ▶️ Marco free extradited shipping.
Open-sourcing
⏹️ ▶️ Marco Thank you very much to Eero for sponsoring our show.
⏹️ ▶️ Casey You know, obviously Swift is open source. I don’t know if you’re aware of that, Chris, but
⏹️ ▶️ Casey how do you feel like it’s been going so far and I’m assuming similar to John, you know, I’m going to take away
⏹️ ▶️ Casey the obvious answer of it’s going well, but maybe to kind of cue conversation,
⏹️ ▶️ Casey what’s been really surprising about going open source? you can get as specific or as
⏹️ ▶️ Casey broad as you’d like to be. But I got to imagine that you guys had a bunch of expectations
⏹️ ▶️ Casey about what going open source would be like. And I would imagine some of them were accurate and some of them weren’t. So how do you feel like the Swift
⏹️ ▶️ Casey open source project has been going?
⏹️ ▶️ Chris Lattner Yeah, so I think that to summarize, it’s not just going well, it’s going
⏹️ ▶️ Chris Lattner far better than we ever anticipated. And that caused problems.
⏹️ ▶️ Chris Lattner So for context, I and many of the other people in the team and many of the other people on the
⏹️ ▶️ Chris Lattner team had quite a bit of open source experience. So LLVM and Clang, for example, were open source.
⏹️ ▶️ Chris Lattner They were, they are vibrant and amazing communities with
⏹️ ▶️ Chris Lattner hundreds of contributors and dozens of companies all collaborating in public and doing really amazing stuff.
⏹️ ▶️ Chris Lattner Even some of the most staunch competitors, you know, AMD and
⏹️ ▶️ Chris Lattner Intel and AMD and Nvidia, or, you know, these kinds of companies that really
⏹️ ▶️ Chris Lattner don’t get along on the business side of things, but the engineers were great at working engineer
⏹️ ▶️ Chris Lattner to engineer and solving problems and staying focused on making things better.
⏹️ ▶️ Chris Lattner So with Swift, we assumed that it would be very similar to that. But what
⏹️ ▶️ Chris Lattner we found is that there was a major difference between launching Swift and launching something like Clang, for
⏹️ ▶️ Chris Lattner example, which is that when Swift launches open source, which was December 3rd, just
⏹️ ▶️ Chris Lattner over a year ago, it already had, I don’t know, a million users.
⏹️ ▶️ Chris Lattner And where Clang started and everybody yawned and didn’t
⏹️ ▶️ Chris Lattner really care and grew slowly, Swift open source started and was amazingly
⏹️ ▶️ Chris Lattner fast moving, changing, tons of people, hundreds of patches on the first day. It was
⏹️ ▶️ Chris Lattner totally crazy and we didn’t really know what to do. And so, I mean, I
⏹️ ▶️ Chris Lattner am like super impressed with the Swift open source community and all the people involved and the energy. And
⏹️ ▶️ Chris Lattner just, I mean, it’s just, it’s hard, it’s hard to believe how great everything is.
⏹️ ▶️ Chris Lattner But it really did create problems because we had to figure out things like how are we gonna stay up on, in terms of
⏹️ ▶️ Chris Lattner the patch volume? Okay, we’re getting hundreds and hundreds of emails a day to the Swift Evolution mailing list.
⏹️ ▶️ Chris Lattner What are we going to do about that? How do we balance Apple’s goals
⏹️ ▶️ Chris Lattner for pushing Swift forward with the goals of the community, which are somewhat more chaotic and less
⏹️ ▶️ Chris Lattner directed. And I think that over the last year, we’ve learned a lot and you can see that reflect
⏹️ ▶️ Chris Lattner in terms of how the project’s being managed and how things are being done.
⏹️ ▶️ Chris Lattner But it’s always been super important to be not just open source, but
⏹️ ▶️ Chris Lattner I guess if you look at an open source project, there’s three kind of easy levels to look at it.
⏹️ ▶️ Chris Lattner The first basic requirement that you have to satisfy to be open source is to make your code available,
⏹️ ▶️ Chris Lattner right? And so you can produce tarballs periodically, and that’s technically open source.
⏹️ ▶️ Chris Lattner, Casey You can
⏹️ ▶️ Chris Lattner allow contributions, and if you do that through pull requests or patches or whatever, then
⏹️ ▶️ Chris Lattner people can engage with it and make the code better. There’s open community, so not
⏹️ ▶️ Chris Lattner only do you accept a patch, but you actually discuss things and talk about things
⏹️ ▶️ Chris Lattner in public. And then there’s open design. And with Swift, we went all the way, And I think it was totally
⏹️ ▶️ Chris Lattner the right thing to do because we really wanted to benefit from all the smart people in the world. And
⏹️ ▶️ Chris Lattner it was, and still is amazing, but it’s also very challenging.
⏹️ ▶️ Casey Yeah, I can imagine. So building upon the open sourcing of Swift,
⏹️ ▶️ Casey it was very surprising to me, and I think a lot of the community, that Apple chose to upload the
⏹️ ▶️ Casey entire commit history. It wasn’t just a, here’s day one, initial commit, and it’s 11 gazillion
⏹️ ▶️ Casey files and 80 gazillion lines of code. Was that planned from the start that you guys
⏹️ ▶️ Casey would upload the entire history?
⏹️ ▶️ Chris Lattner I wouldn’t say it was planned from the start that we’d upload the entire history, but it was kind of assumed from the start
⏹️ ▶️ Chris Lattner that it would be open source at some point. Interesting. And if you look at Apple’s history,
⏹️ ▶️ Chris Lattner I think that’s, in the tool space, I think that’s fairly
⏹️ ▶️ Chris Lattner straightforward. LLVM wasn’t started at Apple, but
⏹️ ▶️ Chris Lattner almost everything Apple does ends up going public in the LLVM space. Clang
⏹️ ▶️ Chris Lattner was started at Apple, and Clang was contributed by Apple to the LLVM project,
⏹️ ▶️ Chris Lattner and that included its full revision history. Other projects like LDB
⏹️ ▶️ Chris Lattner and libc++ and compiler RT and all these other smaller projects
⏹️ ▶️ Chris Lattner were started at Apple and contributed to the open source project. So with Swift, it was kind of assumed that that would
⏹️ ▶️ Chris Lattner happen at some point. The real question was, when is the right time for
⏹️ ▶️ Chris Lattner that to happen? And if you remember the days of SWIFT 1.0, SWIFT 1.0
⏹️ ▶️ Chris Lattner to 2.0 in particular was a super chaotic, super learning as we went
⏹️ ▶️ Chris Lattner and trying to keep up with the community and trying to keep up with the pace and the challenges that people were facing and
⏹️ ▶️ Chris Lattner trying to get key pieces like the air handling model and protocol extensions and all that kind of stuff that had always been planned, but
⏹️ ▶️ Chris Lattner didn’t make it into SWIFT 1.0. And so really focusing on that was the priority. And so
⏹️ ▶️ Chris Lattner we decided that open sourcing Swift at 1.0, for example, would be really actually
⏹️ ▶️ Chris Lattner bad for the Swift community because there are major pieces of language that weren’t there.
⏹️ ▶️ Chris Lattner We would have to spend a lot of time community building and trying to explain to people the difference between what
⏹️ ▶️ Chris Lattner was not there but should be there and what is there and known broken. And
⏹️ ▶️ Chris Lattner we had to do a lot of that when Swift was eventually open sourced in last year
⏹️ ▶️ Chris Lattner right after Swift 2.0, but it was a much better place. and the team could actually handle the load of doing
⏹️ ▶️ Chris Lattner the community. And we didn’t expect the kind of response that we got, but we knew that building a vibrant
⏹️ ▶️ Chris Lattner open source community is a lot of work, and it’s not something to be underestimated. And we wanted to make sure
⏹️ ▶️ Chris Lattner that Swift 2 was out the door, and it wasn’t kind of a resource contention between
⏹️ ▶️ Chris Lattner do we finish Swift 2, or do we start open source? And that’s why it was announced
⏹️ ▶️ Chris Lattner to be open source by the end of the year, because that meant that we could start working on the open source infrastructure
⏹️ ▶️ Chris Lattner project, bringing up all the other stuff that it takes to make something open source after Swift 2 is complete.
⏹️ ▶️ John So my recollection of the Swift 3 in the planning stages was that ABI compatibility
⏹️ ▶️ John was somewhere in the list of, I don’t know if you want to call them goals, but
⏹️ ▶️ John somewhere in the list of items that were in contention for Swift 3. And at some point along the development
⏹️ ▶️ John process of Swift 3, ABI compatibility got postponed. And
⏹️ ▶️ John given what you just said about the importance of ABI compatibility for the framework people inside Apple or whatever,
⏹️ ▶️ John what can you say about that? Did you learn lessons from
⏹️ ▶️ John ABI compatibility being planned for Swift 3? Or do you think like it was never really a hard and fast
⏹️ ▶️ John goal and you totally made the right call to delay it or are you disappointed that it didn’t make it?
⏹️ ▶️ Chris Lattner Well, I think many of those things. I mean, we’re disappointed that it got delayed, but it was totally the right thing.
⏹️ ▶️ Chris Lattner I think that there’s a couple of things to learn from that. one of which is software schedule planning is hard.
⏹️ ▶️ Chris Lattner, Casey Breaking
⏹️ ▶️ Chris Lattner, Marco news.
⏹️ ▶️ Chris Lattner Yeah, so that’s definitely still a thing. There’s also that we didn’t anticipate
⏹️ ▶️ Chris Lattner the, so the original plan that you’re referring to was announced before Swift was open source,
⏹️ ▶️ Chris Lattner or sorry, it was announced the same time Swift was open source. And so we had no idea that
⏹️ ▶️ Chris Lattner the community would descend on Swift and suddenly have all these new demands and consume
⏹️ ▶️ Chris Lattner so much time and energy that kind of took away from programming to do
⏹️ ▶️ Chris Lattner the community building piece. So that was part of it. Another part of it is that ABI
⏹️ ▶️ Chris Lattner stability is super important, but it’s not as important as people think it is for application
⏹️ ▶️ Chris Lattner developers. It’s really important to Apple. But what we realized
⏹️ ▶️ Chris Lattner in the Swift 3 timeframe is that the thing app developers would benefit from the most was
⏹️ ▶️ Chris Lattner actually source stability. So who actually wants their application to be broken
⏹️ ▶️ Chris Lattner when they get a new version of Xcode? Well, really nobody, right?
⏹️ ▶️ Chris Lattner And so kind of halfway through the release, we pivoted and source stability became the goal.
⏹️ ▶️ Chris Lattner And so I’m really excited that when Swift 3.1 or Swift 4 comes out, that
⏹️ ▶️ Chris Lattner it’s still gonna be able to build Swift 3 code. And even if there are minor changes
⏹️ ▶️ Chris Lattner that need to be made for one reason or another, that you can upgrade and you have
⏹️ ▶️ Chris Lattner great compatibility with your old code and you don’t have to start the migrator before you can do anything. So
⏹️ ▶️ Chris Lattner it’s going to be a great improvement for people’s lives.
Server-side Swift
⏹️ ▶️ Marco Alright, so moving on a little bit to this branch topic here of
⏹️ ▶️ Marco server-side Swift, Swift on Linux, things like this. Is
⏹️ ▶️ Marco Swift on the server something that… I know it’s possible and there’s
⏹️ ▶️ Marco seemingly some early efforts now to get that going. Do you see this as a major
⏹️ ▶️ Marco goal for Swift as the language? And not in any kind of official capacity, but just you as a person
⏹️ ▶️ Marco who likes and uses Swift and has a strong role in the community,
⏹️ ▶️ Marco is server-side Swift a thing that you want to be a major thing
⏹️ ▶️ Marco to compete with things like Python and Rails and stuff on the server? Or is it
⏹️ ▶️ Marco intended more to be a specialized thing that is probably not going to be in widespread use by
⏹️ ▶️ Marco web and backend programmers?
⏹️ ▶️ Chris Lattner So I think that everybody involved with the project wants it to be the way
⏹️ ▶️ Chris Lattner to do server development.
⏹️ ▶️ Chris Lattner, Casey And
⏹️ ▶️ Chris Lattner I think that to understand that, you have to understand we’re just kind
⏹️ ▶️ Chris Lattner of entering phase two of Swift’s world domination plan.
⏹️ ▶️ Chris Lattner So this will probably sound insane, but maybe in a few years it will sound less
⏹️ ▶️ Chris Lattner insane. But the way I look at it, and the way that many other
⏹️ ▶️ Chris Lattner people at Apple look at it, is that we want Swift to be the next big thing, right?
⏹️ ▶️ Chris Lattner We want it to be more popular than Java was or is. We want it to be more popular than Python. We want it to be
⏹️ ▶️ Chris Lattner maybe even more popular than C someday. That would be a stretch, but that
⏹️ ▶️ Chris Lattner would be great, right? And so if that’s the problem to solve, how do you solve that problem? Well,
⏹️ ▶️ Chris Lattner open source is a huge piece of that, right? Without open source, it’s not going to be available on other people’s platforms. It’s
⏹️ ▶️ Chris Lattner not gonna be used in education and teaching. that’s just not gonna happen. And so open source is
⏹️ ▶️ Chris Lattner a major piece of that. If you go back farther, before that, Swift
⏹️ ▶️ Chris Lattner world domination doesn’t happen unless Swift gains relevance, right? And
⏹️ ▶️ Chris Lattner I think Swift has nailed the relevance side of things with the iOS and Apple platform
⏹️ ▶️ Chris Lattner development side of the story where, you know, maybe not Marco,
⏹️ ▶️ Chris Lattner, Casey most
⏹️ ▶️ Chris Lattner, Marco other people are switching to
⏹️ ▶️ Chris Lattner Swift very quickly and seem very happy using it.
⏹️ ▶️ Marco Actually, I started using it today. Okay, good call. I switched
⏹️ ▶️ Marco, Chris Lattner today in
⏹️ ▶️ Marco honor of this interview. I wrote my first Swift today, and an entire extension
⏹️ ▶️ Marco in Overcast 3.0 is written in Swift.
⏹️ ▶️ Casey Wow! See, fantastic. Look at you go, I’m proud of you.
⏹️ ▶️ Chris Lattner It is a good day. Yeah,
⏹️ ▶️ Chris Lattner, Marco and
⏹️ ▶️ Marco more will be coming. Although, there’s a lot of Objective-C there, so I’m probably a long way away
⏹️ ▶️ Marco from it being all Swift. Yeah, well,
⏹️ ▶️ Chris Lattner that’s okay. Swift loves Objective-C. Exactly. So the way I look at it is that the
⏹️ ▶️ Chris Lattner first step of Swift world domination is getting to relevance. And for a language to
⏹️ ▶️ Chris Lattner get to relevance, it needs a killer app, right? It needs a reason why people would want to use it. And
⏹️ ▶️ Chris Lattner for Swift, that’s clearly iOS and Mac and other Apple platform development.
⏹️ ▶️ Chris Lattner Second, it needs to be open source. Third, it needs to go beyond,
⏹️ ▶️ Chris Lattner right? And the next step, the frontier of where it makes sense to expand out to, or if you’re,
⏹️ ▶️ Chris Lattner you know, real-time strategy, game player, the natural expansion is a place
⏹️ ▶️ Chris Lattner where the language is, where the language
⏹️ ▶️ Chris Lattner actually only needs a few things added to it to be good. And so I think server development
⏹️ ▶️ Chris Lattner is really that next step because server development is very similar to app development in terms of the kinds of code that
⏹️ ▶️ Chris Lattner you need to write. It’s very similar in terms of many of the frameworks. The major missing piece
⏹️ ▶️ Chris Lattner is that it needs to run on Linux and other pertinent server development platforms,
⏹️ ▶️ Chris Lattner and there’s then the whole library ecosystem that needs to be built out. And so I
⏹️ ▶️ Chris Lattner think that what we’re in right now is we’re in a really exciting phase where those platforms are being
⏹️ ▶️ Chris Lattner built, those frameworks and different pieces of infrastructure are coming together, and
⏹️ ▶️ Chris Lattner that’s really the idea behind the Swift server working group that’s an official part of Swift.org is
⏹️ ▶️ Chris Lattner getting all the people working in the space to talk to each other, and I’m very excited about that.
⏹️ ▶️ Chris Lattner Going beyond that though, with the goal of being more relevant than Java, for
⏹️ ▶️ Chris Lattner example, if we’re gonna pick on Java, the dream of Swift
⏹️ ▶️ Chris Lattner is to scale all the way from scripting language all the way down to low-level systems
⏹️ ▶️ Chris Lattner programming, like you could write a kernel in it, or you write some firmware in it. And I think the
⏹️ ▶️ Chris Lattner scripting side of it is maybe more straightforward when the
⏹️ ▶️ Chris Lattner Swift community and the core team have time to deal with it, because there you’re talking about
⏹️ ▶️ Chris Lattner integrating regular expressions, integrating multi-line string literals, and integrating other features
⏹️ ▶️ Chris Lattner like that that people love from scripting languages. And those are big projects,
⏹️ ▶️ Chris Lattner but those are kind of well-known, I
⏹️ ▶️ Chris Lattner, Marco guess,
⏹️ ▶️ Chris Lattner and they will fit and drop right into the existing system
⏹️ ▶️ Chris Lattner that Swift provides. Systems programming is, I think, the big
⏹️ ▶️ Chris Lattner next frontier. And I think that’s where Swift can really distinguish itself from Java or
⏹️ ▶️ Chris Lattner other competitive languages because among other widely used languages
⏹️ ▶️ Chris Lattner out there, there’s really nothing that can unseat C or C++. There’s Rust,
⏹️ ▶️ Chris Lattner for example, is an interesting language, but it hasn’t gotten a lot of adoption yet. And I think that
⏹️ ▶️ Chris Lattner Swift is more interesting than Rust in some of the higher level application domains.
⏹️ ▶️ Chris Lattner But we’ll see, Rust is a great language as well. And so I’m really interested to see
⏹️ ▶️ Chris Lattner the Swift for systems programming work get going. And I think that’ll
⏹️ ▶️ Chris Lattner be a couple of years out before it really comes together. But once it does, I think that Swift
⏹️ ▶️ Chris Lattner can be, really be the next big thing. And I’m excited about that.
⏹️ ▶️ Marco So just stepping back a second to the server role of it possibly taking over there. Because
⏹️ ▶️ Marco I would love, here I am using PHP and Objective-C, these two languages that are fairly
⏹️ ▶️ Marco old. And, I mean, PHP is way more hated than Objective-C. But these
⏹️ ▶️ Marco are the two languages I use for various historical and practical reasons.
⏹️ ▶️ Marco On the server, a lot of what makes a language succeed or fail
⏹️ ▶️ Marco on servers and in web development is not necessarily how good of a language it is,
⏹️ ▶️ Marco but how healthy and universal and developed the frameworks
⏹️ ▶️ Marco around it are for things like web development, how practical and easy it is to deploy
⏹️ ▶️ Marco and run on servers. So, you know, Swift being its
⏹️ ▶️ Marco own good language, that alone I don’t think is enough to get it to get
⏹️ ▶️ Marco traction on the server. Like, do you think, is it necessary for
⏹️ ▶️ Marco the Swift team, like the core group who’s running Swift, whether that’s
⏹️ ▶️ Marco Apple or the community of contributors with Apple or whatever else, is it important for them
⏹️ ▶️ Marco to develop and kind of make an official set of server
⏹️ ▶️ Marco and web frameworks and libraries and tools? Or do you think it’s sufficient
⏹️ ▶️ Marco to kind of take the risk to let the community do that, but at the risk of fragmentation and maybe nothing ever
⏹️ ▶️ Chris Lattner Well, so that’s an interesting question. And keep in mind that I don’t have a lot of practical experience building
⏹️ ▶️ Chris Lattner server apps. So this is… You’re not missing much. My opinion
⏹️ ▶️ Chris Lattner based on talking to other smart people. So the approach the Swift project is taking
⏹️ ▶️ Chris Lattner is it’s looking to standardize what’s colloquially but not correctly known
⏹️ ▶️ Chris Lattner as server foundation kind of technologies. So it will not be named server foundation, but
⏹️ ▶️ Chris Lattner that kind of an idea. And so take the encryption, the network transport, the HTTP kinds
⏹️ ▶️ Chris Lattner of things that everybody needs for server technologies and standardize that as part
⏹️ ▶️ Chris Lattner of the Swift project, but at least in the short term, not look to standardize a specific web framework.
⏹️ ▶️ Chris Lattner Because there are half a dozen different, completely different approaches that are interesting in different
⏹️ ▶️ Chris Lattner kind of demands. And I don’t think there’s a clear winner yet. It’s possible
⏹️ ▶️ Chris Lattner that after the first few rounds shake out, then there will be an equivalent Ruby
⏹️ ▶️ Chris Lattner on Rails kind of dominant pattern and framework that emerges.
⏹️ ▶️ Chris Lattner And if so, then maybe that would make sense. But I don’t think Swift needs for there to be
⏹️ ▶️ Chris Lattner a winner at the high level. As far as what can the Swift core
⏹️ ▶️ Chris Lattner language and language and compiler folks do about this, I think there’s really two
⏹️ ▶️ Chris Lattner things. One of which is the Swift Package Manager. I think the Package Manager is really key to
⏹️ ▶️ Chris Lattner scaling out the ecosystem and getting people to work together
⏹️ ▶️ Chris Lattner with the common ecosystem. It’s also the best and I think only way to build Swift code on Linux
⏹️ ▶️ Chris Lattner and other platforms. I don’t mean to single out Linux, it’s just the biggest
⏹️ ▶️ Chris Lattner server development one. So I think that’s a big piece. I think the other piece that will be
⏹️ ▶️ Chris Lattner really amazing is when the concurrency model comes up because I think that’s one of the reasons that makes
⏹️ ▶️ Chris Lattner Go particularly compelling for server development is it has a really well-developed story there along
⏹️ ▶️ Chris Lattner with all the libraries that go together for server and cloud development. And so when the pieces
⏹️ ▶️ Chris Lattner of the concurrency model start coming up, which will probably, the first pieces will ship in Swift 5 is my guess,
⏹️ ▶️ Chris Lattner that will make Swift an even more compelling kind of answer for that kind of space.
⏹️ ▶️ Chris Lattner But I don’t think we need a server language feature if that’s what you’re asking.
Low to high, easy to hard
⏹️ ▶️ John So going to the other extreme from the server side and scripting to getting back to
⏹️ ▶️ John systems programming one thing I’ve seen Related to this and and I think this
⏹️ ▶️ John all stems from like this quote from the original Apple Swift book that Swift was
⏹️ ▶️ John designed to scale from hello world to an entire operating system like that that it’s the world domination Plan was there
⏹️ ▶️ John from the beginning, right? Yep.
⏹️ ▶️ John, Chris Lattner Yeah, absolutely
⏹️ ▶️ John in the first paragraph of the thing When I talk to people now about
⏹️ ▶️ John about Swift as a systems language. Often what I hear is
⏹️ ▶️ John people relating the ways that it is not ready to be a systems language yet, which is,
⏹️ ▶️ John you know, what you just talked about, but then deciding based on that, that because it’s not ready
⏹️ ▶️ John to be a systems language now, it never will, and then they dismiss it. Like, in other words, like,
⏹️ ▶️ John that may have been the plan, but clearly, for reasons X, Y, and Z,
⏹️ ▶️ John you still have to use C for this, this. Therefore, Swift is just a way to write apps for iOS and Mac
⏹️ ▶️ John OS. And how I mean, I’m not quite sure what you can do with that. But do you think
⏹️ ▶️ John about how how to change perception as the language
⏹️ ▶️ John gets older and it’s old age now it’s up to 3.0 like that it starts to you know that that nobody puts
⏹️ ▶️ John Swift in a corner like that that people think they know people think they know what Swift is and they say oh it’s this
⏹️ ▶️ John language that does this thing and that your plans for world domination may be thwarted by the idea that
⏹️ ▶️ John people are pigeonholing language because it’s been around for a few years and I think they know it.
⏹️ ▶️ Chris Lattner I think that you’re onto something. I think that’s a real problem. I don’t think systems programming is the place where that’s a problem yet though,
⏹️ ▶️ Chris Lattner because I don’t think it’s reasonable for me as a crazy man going
⏹️ ▶️ Chris Lattner around saying, Swift will someday do systems programming really well. You should remember that.
⏹️ ▶️ Chris Lattner I don’t think that’s a good way to spend time at the moment. When it does that, Then
⏹️ ▶️ Chris Lattner the question becomes how do you make that, make people aware of that and how
⏹️ ▶️ Chris Lattner do you get people to change their prior misconception. But at that point in time you can have a very
⏹️ ▶️ Chris Lattner practical, look, you can do this and this is so great. And now you get all the advantages of C but
⏹️ ▶️ Chris Lattner it’s safe and you can point to specific reasons why it’s better.
⏹️ ▶️ Chris Lattner So I’m not too worried about it in the space of systems programming but I think there is a practical problem
⏹️ ▶️ Chris Lattner today which is Swift is open source. The
⏹️ ▶️ Chris Lattner Apple development community knows Swift very well, but pretty much everybody else doesn’t,
⏹️ ▶️ Chris Lattner right? And if you go to a random, say, Linux
⏹️ ▶️ Chris Lattner developer, just to continue talking about Linux, they all perceive Swift as
⏹️ ▶️ Chris Lattner being an Apple thing and only relevant to Apple platforms, and they don’t even learn about it,
⏹️ ▶️ Chris Lattner right? And so I think that there is an interesting challenge there and probably
⏹️ ▶️ Chris Lattner the best way to do that is for the existing communities
⏹️ ▶️ Chris Lattner to keep just growing. And as the Swift on Server community grows
⏹️ ▶️ Chris Lattner and more and more people are successful building and deploying server apps in Swift, I hope that
⏹️ ▶️ Chris Lattner naturally more and more people will become aware of that effort, will then find
⏹️ ▶️ Chris Lattner out about Swift, maybe try it out, find out that it’s actually really great. And if it’s not
⏹️ ▶️ Chris Lattner really great, let us know so that people can fix whatever the problems are and then just kind
⏹️ ▶️ Chris Lattner of grow out. But I’m actually perfectly OK with it growing a little bit slower than it has been.
⏹️ ▶️ Marco So John asked about the span between basically low-level systems programming and high-level applications
⏹️ ▶️ Marco programming. I’m also curious that it seems like the Swift team slash Apple have
⏹️ ▶️ Marco presented Swift as not only spanning that wide range, which seems impossible,
⏹️ ▶️ Marco but also spanning a wide range of skill levels of programmers. So there’s the Swift Playgrounds
⏹️ ▶️ Marco app on iPad where you have total novices writing Swift as their first language, all the way up
⏹️ ▶️ Marco to people writing systems-level things and complicated apps who
⏹️ ▶️ Marco are very experienced programmers. Do you think—is it possible for a
⏹️ ▶️ Marco language to do all of these things well? And if so, do you think Swift has achieved
⏹️ ▶️ Chris Lattner So I do think it’s possible. I think it has achieved it for the things that it’s
⏹️ ▶️ Chris Lattner doing so far. And I think the challenge is that as new capabilities get added, that it doesn’t jeopardize
⏹️ ▶️ Chris Lattner that. But knowing the folks involved and the source compatibility
⏹️ ▶️ Chris Lattner guarantees and everything else like that, I’m pretty sure that won’t be a problem going forward. Here’s the way I look at
⏹️ ▶️ Chris Lattner it. Swift, you will never, or you’re unlikely to run to anybody that says that Swift
⏹️ ▶️ Chris Lattner is a simple language. Right? Swift is a complicated language. It’s not simple
⏹️ ▶️ Chris Lattner in the sense that Scheme is simple, for example. It’s also not simple in terms of
⏹️ ▶️ Chris Lattner when you talk to an Objective-C developer, they’ll often claim that Objective-C is simple, ignoring all the C
⏹️ ▶️ Chris Lattner parts. I would never claim that, for the record. So C itself is
⏹️ ▶️ Chris Lattner a very complicated, weird language. It’s just that people don’t typically use the weird parts,
⏹️ ▶️ Chris Lattner right? And so they perceive C as being very simple. So the way
⏹️ ▶️ Chris Lattner I project this onto Swift is that the secret to Swift in being easy to learn,
⏹️ ▶️ Chris Lattner easy to use as a teaching vehicle, but also powerful enough to
⏹️ ▶️ Chris Lattner solve the problems that need to be solved is that the complexity inherent in the language needs to be progressively
⏹️ ▶️ Chris Lattner disclosed. So imagine if someday Swift had inline assembly support, for example.
⏹️ ▶️ Chris Lattner Only really low-level systems people or really bit twiddling assembly programmers would use this feature,
⏹️ ▶️ Chris Lattner everybody else would ignore it, and it would not increase the apparent complexity of the language to people
⏹️ ▶️ Chris Lattner who didn’t know what it was. For a feature like that, the most important thing is to make the syntax clear so that
⏹️ ▶️ Chris Lattner when you run up into it, you discover somebody else’s code, you know that you don’t know what it does.
⏹️ ▶️ Chris Lattner Right? And so you say, ah, that’s interesting, I don’t know what that is, and then you can do
⏹️ ▶️ Chris Lattner a search and find out, find the Stack Overflow article, whatever it is, to say, explain what this is to me. And
⏹️ ▶️ Chris Lattner then you can say, oh, OK, I get it. And I either care or I don’t. But at that point in time, you can then dive in
⏹️ ▶️ Chris Lattner and learn more information. Assembly is never something that a Swift Playgrounds
⏹️ ▶️ Chris Lattner person working through Learn to Code 3 would ever want to know about. And I
⏹️ ▶️ Chris Lattner think that is really one of the secrets to Swift’s success in terms of getting people
⏹️ ▶️ Chris Lattner on board and being really approachable for people at all levels is that
⏹️ ▶️ Chris Lattner just like in Python, you can start with just print hello world, you could do the exact same thing in Swift. And
⏹️ ▶️ Chris Lattner with Swift, you don’t need the slash end on your string. It’s really just print hello world.
⏹️ ▶️ Chris Lattner And from there, you can then introduce new concepts. You can grow it out over time. And this really allows
⏹️ ▶️ Chris Lattner people to understand either the syntax of language or the conceptual
⏹️ ▶️ Chris Lattner programming things that they’re learning as they go. And the design of Swift is
⏹️ ▶️ Chris Lattner really geared around that. And so what that means if you project on a system’s programming features, comparing
⏹️ ▶️ Chris Lattner Swift to Rust, for example, I think it’s very likely that Swift will get features
⏹️ ▶️ Chris Lattner for memory ownership control, which will allow really, really high performance. It’ll
⏹️ ▶️ Chris Lattner allow solving performance problems with Arc, for example. But unlike Rust, we can’t
⏹️ ▶️ Chris Lattner make that be a core part of the type system that everybody has to use. It has to be something
⏹️ ▶️ Chris Lattner that sufficiently smart programmers, when they’re solving a specific performance problem,
⏹️ ▶️ Chris Lattner end up using or an embedded kernel programmer might want to use, but an application
⏹️ ▶️ Chris Lattner developer can completely ignore. And so that’s really the challenge is it’s a deploying
⏹️ ▶️ Chris Lattner similar type system mechanics and other low level language geekery to the problem,
⏹️ ▶️ Chris Lattner but do so in a way that is tasteful and allows most normal people to just completely ignore it.
⏹️ ▶️ John Everything you just said kind of reminds me of a saying I once heard that you’re free to adopt for Swift if you
⏹️ ▶️ John would like, which is make easy things easy and make hard things possible.
⏹️ ▶️ Marco We’re sponsored tonight by audible.
Sponsor: Audible
⏹️ ▶️ Marco With an unmatched selection of audiobooks, original audio shows, news, comedy, and more,
⏹️ ▶️ Marco get a free 30-day trial at audible.com. If you want to listen
⏹️ ▶️ Marco to what Audible has at you can listen to audiobooks from virtually every genre anytime, anywhere. You can
⏹️ ▶️ Marco play Audible’s audiobooks on phones, tablets, computers, even Kindles and iPods if you still
⏹️ ▶️ Marco have them. Audiobooks are great for flights, long road trips, or even your daily commute.
⏹️ ▶️ Marco You might think you don’t have time to read books, but you’d be surprised how many audiobooks you can hear each year, even only
⏹️ ▶️ Marco listening to and from work every day. That time really adds up. Audiobooks bring books to life.
⏹️ ▶️ Marco Many of them are read by authors themselves, which adds an extra dimension to the text. And with Audible, you
⏹️ ▶️ Marco can take risks and try new authors without regret, because Audible offers their great listen
⏹️ ▶️ Marco guarantee. If you start an audiobook and don’t like it, you can exchange it for another one for free.
⏹️ ▶️ Marco So check it out for yourself. You can see and listen. When you begin your free 30-day trial, you get your
⏹️ ▶️ Marco first audiobook for free. There’s no stress and no obligation because you can cancel your Audible membership at
⏹️ ▶️ Marco any time. So with audiobooks and spoken word audio products, you will find what you’re looking for.
⏹️ ▶️ Marco Get a free 30-day trial by signing up at audible.com slash ATP.
⏹️ ▶️ Marco That’s audible.com slash ATP.
Influences
⏹️ ▶️ Marco Thanks to Audible for sponsoring our show.
⏹️ ▶️ Casey So, Chris, you brought up just a second ago how simple Python’s hello world is.
⏹️ ▶️ Casey And one of the things I’ve wondered about Swift is it seems to some degree
⏹️ ▶️ Casey like it’s kind of the, what do you call it, the Rorschach test of languages in that I came to Swift
⏹️ ▶️ Casey a sort of, kind of via Objective-C, but my day job was as a C-sharp guy.
⏹️ ▶️ Casey I see, to my eyes anyway, and I hope you don’t find this insulting, but I see a lot of C sharp.
⏹️ ▶️ Casey I see a lot of C sharp in Swift. And I’ve heard JavaScript people, again, I hope that’s not insulting, say, oh, I see some JavaScript in
⏹️ ▶️ Casey here. And I presume that John could say that he sees Perl in it. I presume Marco could say that he sees PHP
⏹️ ▶️ Casey hopefully that’s not insulting.
⏹️ ▶️ Casey, Marco I see Go in it. I don’t see any
⏹️ ▶️ Marco, Casey in it. Okay, fair enough.
⏹️ ▶️ Casey You get what I’m driving at, though. And so I guess what I’m asking, Chris, is obviously there
⏹️ ▶️ Casey was a huge Objective-C influence in Swift. But was there any one or maybe just a couple of other
⏹️ ▶️ Casey languages that you feel really, really inspired Swift? Or do you really think it’s the melting pot
⏹️ ▶️ Casey language that one would always hope to create?
⏹️ ▶️ Chris Lattner I think it really is a melting pot because we weren’t… So the goal of Swift isn’t to ape some
⏹️ ▶️ Chris Lattner other language. The goal of Swift is to
⏹️ ▶️ Chris Lattner, Casey just be great,
⏹️ ▶️ Chris Lattner right? And so you can take… I think that Swift looks,
⏹️ ▶️ Chris Lattner or I and the other people on the core team and the other people working on Swift have looked at
⏹️ ▶️ Chris Lattner many, many other languages. If you’re a Haskell nerd, there’s tons of Haskell concepts
⏹️ ▶️ Chris Lattner built in. Protocols really are just like a very similar Haskell construct,
⏹️ ▶️ Chris Lattner for example. And so it’s really about taking the best ideas from where
⏹️ ▶️ Chris Lattner we can get and assembling them together. And one of the major goals of Swift is for it to be familiar
⏹️ ▶️ Chris Lattner feeling, right? Because if it’s
⏹️ ▶️ Chris Lattner, John familiar
⏹️ ▶️ Chris Lattner feeling, that makes it easier for people to pick up and they’re They’re not fighting
⏹️ ▶️ Chris Lattner unnecessary barriers to just get in the way of adoption. And so it being
⏹️ ▶️ Chris Lattner familiar is actually success in that way.
⏹️ ▶️ Chris Lattner it’s not a result of Swift trying to be Go or C Sharp
⏹️ ▶️ Chris Lattner or whatever, it’s about taking the best ideas from them and assembling them together. And I think
⏹️ ▶️ Chris Lattner that you could probably pick a language and there’s some good idea that came from them, including
⏹️ ▶️ Chris Lattner D or Dart or Go or whatever. I mean, Swift does
⏹️ ▶️ Chris Lattner really draw from many, many different sources and it’s really hard to
⏹️ ▶️ Chris Lattner really tease them all out.
Why adopt now?
⏹️ ▶️ Marco So the question that Casey wrote for me to ask you right now
⏹️ ▶️ Marco how do you know that was me? That’s definitely you is Why should I give a shit about Swift
⏹️ ▶️ Marco right now? And I think I’m gonna modify this a little
⏹️ ▶️ Casey That was written that was written for you my friend,
⏹️ ▶️ Casey, Marco but yes, I figure that’s not quite John style
⏹️ ▶️ Marco No, but but I you know as as somebody who is just dipping a toe
⏹️ ▶️ Marco in Swift, you know as of 12 hours ago ago, and has waited this long.
⏹️ ▶️ Marco Objective-C faithful, slash holdout, slash lazy people who don’t like learning new things very quickly.
⏹️ ▶️ Marco What’s the sales pitch for adopting Swift now?
⏹️ ▶️ Chris Lattner I guess two different answers. One of which is, you don’t have to adopt Swift. I don’t think Objective-C
⏹️ ▶️ Chris Lattner is gonna go away anytime soon. Apple still supports C and C++, and it doesn’t
⏹️ ▶️ Chris Lattner have any specific, there’s no obvious benefit of dropping Objective-C,
⏹️ ▶️ Chris Lattner as well as obviously they have a ton of Objective-C code themselves. So I don’t think that there’s any reason
⏹️ ▶️ Chris Lattner you have to adopt Swift. Swift just tries to be a better answer so that
⏹️ ▶️ Chris Lattner you’ll want to adopt it. And in terms of why, Swift
⏹️ ▶️ Chris Lattner in its name kind of is connotes a whole bunch of different things, including performance. But
⏹️ ▶️ Chris Lattner really to me, the most important aspect of it is programmer productivity, right? The idea that Swift is
⏹️ ▶️ Chris Lattner really optimizing for is not letting you pound out the code as fast as possible. It really
⏹️ ▶️ Chris Lattner is designed and optimized for, as a programmer, you can spend the least amount of time to get to
⏹️ ▶️ Chris Lattner a working program as fast as possible. And so getting to a working program
⏹️ ▶️ Chris Lattner includes the time it takes to debug something, includes the time it takes to iterate and develop and
⏹️ ▶️ Chris Lattner fight the type system and all the other things that you have to do. But that time
⏹️ ▶️ Chris Lattner you spend having to fight the type system or figure out optionals or things like that pays itself
⏹️ ▶️ Chris Lattner back because your program works more often. And so you’re actually not spending time chasing down
⏹️ ▶️ Chris Lattner dangling pointer bugs, or in the case of Objective-C,
⏹️ ▶️ Chris Lattner you get an unrecognized selector error, you know, whatever those kinds of bugs are.
⏹️ ▶️ Chris Lattner And Swift tries to help you by the language guiding you and helping design things. Swift
⏹️ ▶️ Chris Lattner also has a lot of things that just make common things easier. So you can switch on a string, for example,
⏹️ ▶️ Chris Lattner and then match the different cases. You can use enums, which are a super,
⏹️ ▶️ Chris Lattner enums are just from the language geekery world of just algebraic data types. They’re in tons
⏹️ ▶️ Chris Lattner of different functional languages. They’re not novel by any means, but they’re so useful,
⏹️ ▶️ Chris Lattner and they solve so many problems just out of the box. And just having them at your fingertips is great.
⏹️ ▶️ Chris Lattner So there’s a lot of things about Swift, and it probably depends on who you are, what your experiences are.
⏹️ ▶️ Chris Lattner One of the problems I’ve seen with people moving from Objective-C to Swift initially is that they tend to write Swift code
⏹️ ▶️ Chris Lattner just like they wrote Objective-C. And while that’s a really good way to maybe migrate an application
⏹️ ▶️ Chris Lattner over or to get familiar with Swift, it really means that you’re missing a lot of the value in Swift.
⏹️ ▶️ Chris Lattner And I think that that’s okay. It’s just, it means that, you know, an Objective-C programmer
⏹️ ▶️ Chris Lattner going to Swift first starts out by saying, I don’t see what the big deal is. And only after they
⏹️ ▶️ Chris Lattner spend some time in it do they start to realize they are more productive, they do feel better,
⏹️ ▶️ Chris Lattner they reach for things that they otherwise wouldn’t have. And I think it’s really interesting
⏹️ ▶️ Chris Lattner to talk to people that have done, for example, a year of Swift programming, but then have to go back to Objective-C.
⏹️ ▶️ Chris Lattner And to me, that’s the really interesting thing. So what was your experience?
⏹️ ▶️ Casey It felt absolutely archaic. And granted, I like to think of myself as a nice guy,
⏹️ ▶️ Casey and so I’d probably say something like that even if it wasn’t true. But the reality of the situation is, it felt just
⏹️ ▶️ Casey so old. It just felt old. And I don’t know, I wish I could quantify
⏹️ ▶️ Casey that better, but it just felt like I was back in time in a way that didn’t
⏹️ ▶️ Casey feel good. And in some ways, it was kind of nice. So I do
⏹️ ▶️ Casey like optionals. I understand why they’re a thing. I am all in on it.
⏹️ ▶️ Casey But at the same time, there are times when I have to do a guard let or whatever the case may be that I really would just like to
⏹️ ▶️ Casey move on with my life. And so not having to worry, being able to be a little more
⏹️ ▶️ Casey cavalier was kind of nice. But the reality of the situation is, as you’ve said earlier,
⏹️ ▶️ Casey is that that’s a potential hazard down the road. And that’s why I like the way that you
⏹️ ▶️ Casey and the team have set up the type system in Swift. But gosh, going back to Objective-C
⏹️ ▶️ Casey is so frustrating for me because it just feels like I’m going back in time, like I’m going backwards.
⏹️ ▶️ Chris Lattner, Casey Yeah,
⏹️ ▶️ Chris Lattner and I think that the challenge that Swift faces is because this focus is on building, you know,
⏹️ ▶️ Chris Lattner programs that work and that can be maintained and all the other things that we care about for large
⏹️ ▶️ Chris Lattner scale software. It’s maybe not the best solution for
⏹️ ▶️ Chris Lattner I want to pound out a quick script, use it once and then throw it away, right? Because
⏹️ ▶️ Chris Lattner in that case, you don’t care about maintenance. You can fit all the code in your head. you don’t care about
⏹️ ▶️ Chris Lattner good documentation or the other things that Swift encourages. And that’s a case where having a dynamic
⏹️ ▶️ Chris Lattner type system can be really liberating. And so,
⏹️ ▶️ Chris Lattner you know, maybe that’ll be a challenge for some people. But I think that as Swift gains ecosystem and gains
⏹️ ▶️ Chris Lattner libraries, its other advantages will be so great that hopefully it will be
⏹️ ▶️ Chris Lattner a good solution for those kinds of tools as well, those kinds of scripts as well.
Style and idioms
⏹️ ▶️ Marco So a minute ago you mentioned how Objective-C programmers, people like me who are new to Swift,
⏹️ ▶️ Marco tend to write Swift like Objective-C. And that’s a concern I’ve had, and it’s
⏹️ ▶️ Marco one of the reasons that I have procrastinated adopting Swift up till now, because
⏹️ ▶️ Marco I have a pretty good grasp on Objective-C now, and I write
⏹️ ▶️ Marco Objective-C code that I know is basically idiomatic and
⏹️ ▶️ Marco soundly designed. Like, I write code in the style of what I think Apple’s code would
⏹️ ▶️ Marco look like based on the little bit of, you know, headers and stuff that we see. I feel like I write good Objective-C code that is kind
⏹️ ▶️ Marco of correct and idiomatically sound. With Swift, you know, I assumed
⏹️ ▶️ Marco that the idioms would not yet be developed for a while and established for a
⏹️ ▶️ Marco while. And so I didn’t want to write a bunch of bad Swift code or
⏹️ ▶️ Marco like incorrect or weird Swift code, you know, investing heavily in it so early
⏹️ ▶️ Marco on. Do you think that it’s at a point now where the idioms are starting to get
⏹️ ▶️ Marco worked out enough that that’s less of a concern now?
⏹️ ▶️ Chris Lattner Yeah, I do. So I think it’s definitely fair to say that in the Swift 1, the Swift 2 timeframes,
⏹️ ▶️ Chris Lattner Swift as a language was changing really rapidly, and I could see why you’d feel like you’re on
⏹️ ▶️ Chris Lattner uneven footing and not really sure what the language is, much less what the idioms are. Swift 3
⏹️ ▶️ Chris Lattner really is quite well baked out, and so I expect that going forward the new things are going to be
⏹️ ▶️ Chris Lattner additive. They’re not going to be changing the existing patterns. And so I think the Swift community
⏹️ ▶️ Chris Lattner in general has gone through the same kind of thing that you’re feeling there where it’s not really
⏹️ ▶️ Chris Lattner clear the one right way to solve the problem. And maybe there are different good
⏹️ ▶️ Chris Lattner ways to do it with different trade-offs that weren’t clear to people. But I think people are starting to understand
⏹️ ▶️ Chris Lattner that now. There are a few style books that are being written by people that I’ve heard about. And so
⏹️ ▶️ Chris Lattner when those come out, those will hopefully be good and those will be a good resource.
⏹️ ▶️ Chris Lattner But another thing to keep in mind is that Swift is opinionated,
⏹️ ▶️ Chris Lattner I guess, is the
⏹️ ▶️ Chris Lattner, Casey way to say it.
⏹️ ▶️ Chris Lattner So it really does encourage you to do the right thing where it can. For example,
⏹️ ▶️ Chris Lattner if you use var for everything, the Swift compiler will say, hey, you
⏹️ ▶️ Chris Lattner mark this as a var, but it could be a let, and that’s just its subtle way of, and
⏹️ ▶️ Chris Lattner let me fix it for you. And that’s just a subtle way of encouraging you to use immutable values,
⏹️ ▶️ Chris Lattner which is a very small thing, but it’s just kind of pushing you in the way that
⏹️ ▶️ Chris Lattner it thinks leads to better code. And immutability for a local variable doesn’t matter that much,
⏹️ ▶️ Chris Lattner except that it communicates something more to the person who has to read and maintain your code. And
⏹️ ▶️ Chris Lattner so I think that Swift really does kind of encourage you down the right lines in some ways. But
⏹️ ▶️ Chris Lattner on the other hand, in other places where you’re saying, hey, should something be a class or should it be a struct, trade-offs are more nuanced
⏹️ ▶️ Chris Lattner and it’s a harder thing and the Swift compiler can’t just know what problem it is that you want to solve and so it
⏹️ ▶️ Chris Lattner can’t help you with that.
⏹️ ▶️ John So you mentioned Swift style guides before. As a creator of a language,
⏹️ ▶️ John how much influence do you feel like you want to have over things
⏹️ ▶️ John like style? Things that really are, you know, it’s not features, it’s not technical,
⏹️ ▶️ John it’s just like, like, uh, you know, we all know the different style things like, oh, you know, you should only
⏹️ ▶️ John have one exit at the bottom or you should exit early. Or I mean, like there are things you can do,
⏹️ ▶️ John uh, even things like spacing and brace style for crying out loud or, you know, or just the sort of idioms
⏹️ ▶️ John of like this little three line sequence is how you do this transformation on this data structure. Um,
⏹️ ▶️ John you mentioned, you know, language features can influence that. So obviously as language designer and participating in that process, you can
⏹️ ▶️ John effectively, uh, guide the community style-wise in one
⏹️ ▶️ John direction or another. But eventually you come to the stuff that’s just plain opinion and style.
⏹️ ▶️ John And several other languages have had fairly concrete styles
⏹️ ▶️ John set forth early on by the creators, you know, like K&RC style type things.
⏹️ ▶️ John How much do you care about being able to influence the, I guess the personal
⏹️ ▶️ John preference or the the aesthetic portions of style that are outside the things that
⏹️ ▶️ John you can influence as part of language design.
⏹️ ▶️ Chris Lattner So as with any programmer that has a pulse, I have my preferred
⏹️ ▶️ Chris Lattner style. And so clearly, that’s the right way. Naturally.
⏹️ ▶️ Chris Lattner Naturally. Well, so I guess more seriously, the language itself does influence some of
⏹️ ▶️ Chris Lattner the things you mentioned. So for example, it’s my personal opinion that the style
⏹️ ▶️ Chris Lattner where you have a single entry and a single exit from every function, I think that leads to really difficult to maintain and read code.
⏹️ ▶️ Chris Lattner And that’s one of the things that led to the guard statement existing. The guard really does encourage you
⏹️ ▶️ Chris Lattner to use early exits so you handle the exceptional cases and then you don’t have to worry about them. So
⏹️ ▶️ Chris Lattner that’s an example of where the language design is kind of encouraging you to, you
⏹️ ▶️ Chris Lattner know, have multiple returns from a function. Other more subjective things like the number of spaces.
⏹️ ▶️ Chris Lattner I personally am a fan of two-space indents. I know some people are staunchly four, other people are staunchly
⏹️ ▶️ Chris Lattner eight. Some people think 80 columns is the right answer. I mean, all these things are, there are actually
⏹️ ▶️ Chris Lattner really good arguments on all sides. Some people argue that you should use three-space indent because
⏹️ ▶️ Chris Lattner then you certainly can’t have tabs in your file. Wow. So this is
⏹️ ▶️ Chris Lattner where it comes down to you have to pick your battles, right? And
⏹️ ▶️ Chris Lattner people will disagree for a long time and you can make
⏹️ ▶️ Chris Lattner, Casey arguments on
⏹️ ▶️ Chris Lattner both sides, but where we’ve come down is that it’s just more
⏹️ ▶️ Chris Lattner practical to let people write code they like to look at, and that comes at a cost of if you switch between
⏹️ ▶️ Chris Lattner teams or you pick up somebody else’s package, then maybe it’s indented the wrong way. But I
⏹️ ▶️ Chris Lattner don’t think that really actually actively hurts the comprehensibility
⏹️ ▶️ Chris Lattner of the code. That’s merely annoying. And having something like
⏹️ ▶️ Chris Lattner GoFormat, which rigorously enforces the one true way, I think would have been nice. It just wasn’t
⏹️ ▶️ Chris Lattner a priority early on, and it also just wasn’t a battle that we were willing to tackle. And
⏹️ ▶️ Chris Lattner I don’t know, we’ll see. I think this is still also an open question in terms of what other tooling
⏹️ ▶️ Chris Lattner gets built and what other things come into the fray, because it would be
⏹️ ▶️ Chris Lattner great to have better tooling around this. It just hasn’t been built out yet, and it’s a great opportunity for open source as well.
⏹️ ▶️ John I was thinking about the sort of doomsday scenario where one of these Swift style guide books comes out
⏹️ ▶️ John and it makes some blanket recommendation that you should always
⏹️ ▶️ John use protocols for this and you should never use classes for that or whatever. And it becomes wildly popular
⏹️ ▶️ John and accepted as the Bible of how you write Swift programming and you’re just somewhere shaking your
⏹️ ▶️ John head and going, no, you got it all wrong. But I guess we’ll cross that bridge when we come to
⏹️ ▶️ John it. I mean, I think at this point, the language design itself and the community has had enough influence that that’s not likely
⏹️ ▶️ John to happen. But I mean, I guess what I was getting at is, do you feel like that you want to write a Swift-style guide? Like,
⏹️ ▶️ John if you had unlimited time?
⏹️ ▶️ Chris Lattner No, I don’t think that would be a good use of my time.
⏹️ ▶️ Chris Lattner, John But if I had unlimited time, maybe.
⏹️ ▶️ Chris Lattner, Casey I don’t
⏹️ ▶️ Chris Lattner know. It’s hard to answer that theoretical question. But also, to your concern
⏹️ ▶️ Chris Lattner about somebody came out with a style book that was so wrong that would cause me to be
⏹️ ▶️ Chris Lattner really unhappy, I actually have a ton of faith in the Swift community. Because if something came out that was so weird,
⏹️ ▶️ Chris Lattner I don’t think that the community overall would accept it. The community
⏹️ ▶️ Chris Lattner has, again, just kind of blown me away with how clueful they are and how
⏹️ ▶️ Chris Lattner many great people have gotten involved with Swift and the Swift evolution side of things. And it’s been
⏹️ ▶️ Chris Lattner really amazing to see these people, you know, they go through their own personal trajectory
⏹️ ▶️ Chris Lattner on the Swift mailing list where, you know, initially they’re saying, hi, I had this idea, what do you
⏹️ ▶️ Chris Lattner think? And the response is, no, that’s a terrible idea for this, this, this, this reason.
⏹️ ▶️ Chris Lattner But then they come back and they’re like, hey, how about this? Do you ever think about this? And it was like, oh, well, that’s interesting. That almost
⏹️ ▶️ Chris Lattner worked, but it didn’t work because of that. And then they come back and they say, hey, well, what about this? And we said, well, we actually
⏹️ ▶️ Chris Lattner tried that, and we had that for a while, and then had to back out and change it this other way, because we didn’t even think about this other thing.
⏹️ ▶️ Chris Lattner And then the next day, they’re the ones saying, this is the way it needs to go. And everybody says, you’re right.
⏹️ ▶️ Chris Lattner We should do that. And it’s really hard for people that haven’t been involved
⏹️ ▶️ Chris Lattner in the overall design of anything as complicated as Swift to be
⏹️ ▶️ Chris Lattner able to discern the difference between something that is the way it is out of an intentional
⏹️ ▶️ Chris Lattner decision process or the way it is as an accident of history.
⏹️ ▶️ Chris Lattner And so as now that the design process is public, I think that it becomes a lot easier for people
⏹️ ▶️ Chris Lattner to tell that and it’s very easy for people to kind of
⏹️ ▶️ Chris Lattner understand that difference. The one big debate that I haven’t actually seen is why is the funk keyword
⏹️ ▶️ Chris Lattner the funk keyword? And that’s one that luckily we’re now beyond the Swift 3
⏹️ ▶️ Chris Lattner source compatibility threshold, so we just can’t have that discussion anymore. I think that would be great.
⏹️ ▶️ John One of the best things of the Swift open source thing, the whole evolution process has is like
⏹️ ▶️ John the list of questions like the asked and answers questions like this is a commonly asked question and we’ve
⏹️ ▶️ John dealt with it before and you’re probably going to want to ask it too. So here’s here’s how it was asked before and here’s what the answer
⏹️ ▶️ John is. Not that everybody’s going to go and see that, but I love that that exists.
⏹️ ▶️ Chris Lattner Well, and it’s also hilarious that that started out as the commonly proposed list and then at some point it became
⏹️ ▶️ Chris Lattner the commonly rejected list. Yeah,
⏹️ ▶️ John right. Because if it’s commonly proposed, obviously it’s not getting through. And so you have to go to the rejected list.
⏹️ ▶️ John If you’re thinking about asking to change funk to FN you know.
Rust-style memory model?
⏹️ ▶️ John I know you talked about this before, but it is worth touching on again because many
⏹️ ▶️ John people have asked me to ask you this. A Swift and a
⏹️ ▶️ John Rust-style memory model, you phrased it before as an add-on feature
⏹️ ▶️ John for people who know that they need that type of thing, but that it would not, like that Swift
⏹️ ▶️ John wouldn’t become a language in which all memory is managed that way. Instead, this would be a special purpose feature
⏹️ ▶️ John for particular roles. roles do you think it’s suited
⏹️ ▶️ John for and why is it not the right memory model for all of Swift?
⏹️ ▶️ Chris Lattner Well, so here’s the way I look at Swift in terms of memory management today. So Swift is using ARC,
⏹️ ▶️ Chris Lattner it’s not using GC. If you want to talk about the tray out there, I’m happy to do that. That’s
⏹️ ▶️ Chris Lattner its own rat hole we can fall into. ARC, I think, is overall an amazing
⏹️ ▶️ Chris Lattner default for Swift because it gives you deterministic destruction, it gives you relatively
⏹️ ▶️ Chris Lattner predictable performance, and the Arc Optimizer’s able to eliminate most
⏹️ ▶️ Chris Lattner of the reference counting operations that happen. The problem that I see with Arc
⏹️ ▶️ Chris Lattner as of today, or say Swift 3, is that it
⏹️ ▶️ Chris Lattner is not a very controllable model. And so if, for example,
⏹️ ▶️ Chris Lattner you have an inner loop and it turns out the Arc Optimizer’s doing a bunch of retains and releases, and
⏹️ ▶️ Chris Lattner you know that they’re not necessary because you know the objects are alive, there’s nothing that
⏹️ ▶️ Chris Lattner you can really do to solve that problem unless you’re willing to drop down to something like
⏹️ ▶️ Chris Lattner the unsafe operations that Swift gives you for manipulating references to objects.
⏹️ ▶️ Chris Lattner And so it’s really kind of dissatisfying to me to have a really safe, great memory model
⏹️ ▶️ Chris Lattner that for performance reasons you have to drop down to unsafety. This is a huge cliff, and
⏹️ ▶️ Chris Lattner it’s also a huge complexity cliff that you have to drop into to solve that problem.
⏹️ ▶️ Chris Lattner And that’s not really great. So the promise, the dream, is to instead say,
⏹️ ▶️ Chris Lattner hey, well, if you are a sufficiently advanced programmer and you know how this stuff works, well,
⏹️ ▶️ Chris Lattner we can give you a new option. Instead of dropping down to unsafe constructs, you can actually just use more
⏹️ ▶️ Chris Lattner static type information in annotations in your code. And so you
⏹️ ▶️ Chris Lattner add a few annotations to say, hey compiler, this is OK. The compiler can then validate those type annotations
⏹️ ▶️ Chris Lattner and check to make sure they’re correct. So it’s still memory safe. It’s still guaranteed to be OK. But you’re paying
⏹️ ▶️ Chris Lattner for it in terms of more of this annotation in the code, and it’s more heavyweight
⏹️ ▶️ Chris Lattner in terms of coding. But what you get out of that is the guarantee that no arc operations are happening.
⏹️ ▶️ Chris Lattner Once you get to that model, then it becomes really interesting. Because you can say, hey, well, in this inner loop, I
⏹️ ▶️ Chris Lattner found in my profiler that it really does matter for performance and the arc optimizer’s doing the wrong thing, well,
⏹️ ▶️ Chris Lattner I can add a few local annotations and now the code is fast, it’s guaranteed to be fast, and
⏹️ ▶️ Chris Lattner the clients of my code don’t have to know about it. This is an implementation detail. And I think this will really bring
⏹️ ▶️ Chris Lattner us to the best of both worlds where you can have memory safety, you can have a
⏹️ ▶️ Chris Lattner progressively disclosed complexity system where most people don’t have to know about it or think about it,
⏹️ ▶️ Chris Lattner but you can get to really low level performance guarantees that otherwise aren’t possible. And
⏹️ ▶️ Chris Lattner once we do this, I have a feeling there’ll be certain communities of people that will only want to work in this model.
⏹️ ▶️ Chris Lattner And these are the communities that like Rust predominantly. So if you’re writing a kernel,
⏹️ ▶️ Chris Lattner for example, maybe you don’t want to have a reference count in your object at all. And maybe you just want to
⏹️ ▶️ Chris Lattner have, you know, you say I will always use these annotations in my code pervasively.
⏹️ ▶️ Chris Lattner And if that happens, then there’s a couple of options that we can investigate. We could say, hey, well, if you mark
⏹️ ▶️ Chris Lattner this class with some attribute then that prevents the compiler from ever doing
⏹️ ▶️ Chris Lattner reference counting. And if it would ever do that, it just raises an error. Or we could even theoretically have
⏹️ ▶️ Chris Lattner a language dialect mode that said, hey, produce an error anytime it did an arc operation.
⏹️ ▶️ Chris Lattner I don’t like language dialects, and so we’d have to find a way to handle that. Maybe it would be a warning,
⏹️ ▶️ Chris Lattner and then they would upgrade it to an error or something like that. But I can imagine doing something like that. And
⏹️ ▶️ Chris Lattner once we do that, then I think you get to a really interesting mode where those systems
⏹️ ▶️ Chris Lattner programming type people that otherwise would be using C or C++ can now use Swift.
⏹️ ▶️ Chris Lattner And that means they only have to learn one language. That means that they get to use the same tool set,
⏹️ ▶️ Chris Lattner that, you know, the ID and everything else that works great with Swift. It means
⏹️ ▶️ Chris Lattner that they can scale and use the same language for different layers of their
⏹️ ▶️ Chris Lattner stack because many applications have very low level pieces and very high level pieces. and having
⏹️ ▶️ Chris Lattner them written in different languages is really kind of gross. I mean, I think we’ve seen this in the Objective-C
⏹️ ▶️ Chris Lattner community where one of the best and most annoying things about Objective-C is that it has C in it,
⏹️ ▶️ Chris Lattner right? And so this has been hugely important for Objective-C in practice, because if you run into a performance
⏹️ ▶️ Chris Lattner problem with obviously message send, you can always rewrite that algorithm in C. And that’s really, really,
⏹️ ▶️ Chris Lattner really important for Objective-C being successful and then both in the days of Next
⏹️ ▶️ Chris Lattner on 16 MHz processors, but also today for the low-level code that people
⏹️ ▶️ Chris Lattner are writing. But it also means that that’s one of the problems that makes it so that Objective-C and
⏹️ ▶️ Chris Lattner C are so tightly intertwined. And so you can’t actually take the C part out of Objective-C without producing
⏹️ ▶️ Chris Lattner a different language.
Swift in the browser
⏹️ ▶️ John Or waiting for Swift in the web browser, because it’s your only escape. So we can have applications that have to have one language
⏹️ ▶️ John, Chris Lattner higher level and a different language at the lower one. That’s a tough one.
⏹️ ▶️ Chris Lattner Well, that I think is a frontier that is probably the biggest payoff,
⏹️ ▶️ Chris Lattner because replacing JavaScript would be such an amazing service to the world.
⏹️ ▶️ Chris Lattner You just mentioned Dart before. It’s been tried. Yeah, but
⏹️ ▶️ Chris Lattner it’s been tried. And that’s where I’m putting my hope on the Asm.js, the WebAssembly,
⏹️ ▶️ Chris Lattner those kinds of efforts where it’s enabling languages like Swift and
⏹️ ▶️ Chris Lattner Swift compiles through LLVM, WebAssembly and Asm.js both have LLVM backends
⏹️ ▶️ Chris Lattner and principles, so they could wire up Swift to one of those and go to town with it.
⏹️ ▶️ Chris Lattner If those end up winning and they become big, big things, then
⏹️ ▶️ Chris Lattner maybe that’ll be good enough. But I don’t really know. I don’t have… My crystal ball doesn’t go out to the point
⏹️ ▶️ Chris Lattner where JavaScript is not in web browsers.
⏹️ ▶️ John Yeah, that’s the difficult part It’s not that not the language mechanics. It’s the getting Getting something we can
⏹️ ▶️ John understand that in front of as many people as possible.
⏹️ ▶️ Chris Lattner It’s also very interesting to me So and again, I’m not a web developer and I’m not a I’m definitely not an
⏹️ ▶️ Chris Lattner expert in the space but to me it seems that the trajectory of JavaScript has
⏹️ ▶️ Chris Lattner Basically made it into an intermediate language It’s not something that developers are writing as much
⏹️ ▶️ Chris Lattner directly as they used to. And so I see TypeScript and a lot of other languages that now compile down to JavaScript
⏹️ ▶️ Chris Lattner and they’re really using JavaScript like a bit code representation, not
⏹️ ▶️ Chris Lattner a source language that people are thinking about as much anymore. And so I wonder if in five years,
⏹️ ▶️ Chris Lattner the natural conclusion of that is that JavaScript is just an Asm.js type of thing, or maybe
⏹️ ▶️ Chris Lattner WebAssembly does take over. But again, I’m not the expert. I don’t know where that
⏹️ ▶️ Chris Lattner direction will go. I know that some people love JavaScript. So we’ll see.
⏹️ ▶️ John On the topic of using languages other than JavaScript to write JavaScript, I have to say,
⏹️ ▶️ John having done that several times, that the tooling, boy, the tooling is not quite where you’d
⏹️ ▶️ John want it to be in terms of being able to write and debug and profile
⏹️ ▶️ John in the preferred language and not in the compiled down to JavaScript type language.
⏹️ ▶️ John But yeah, maybe that’ll be like stage 17 in the Swift world domination plan.
⏹️ ▶️ John, Chris Lattner Keep on the
⏹️ ▶️ Chris Lattner agenda. And I think that’s always been true for pre-processors. So, I mean, even in C, if you do crazy things with
⏹️ ▶️ Chris Lattner the macro pre-processor in C, you get debugging those things are so horrible.
⏹️ ▶️ Chris Lattner And that’s one of the reasons that we’ve been careful about not adding a macro system to Swift early.
⏹️ ▶️ Chris Lattner It just brings lots of interesting trade-offs in terms of the debugging, developing, designing experience.
ABI stability
⏹️ ▶️ John So one last thing on ABI compatibility. According to the timelines
⏹️ ▶️ John that I’ve heard sketched out, ABI stability could be
⏹️ ▶️ John a thing before async, you know, or concurrency stuff lands
⏹️ ▶️ John in Swift. Is there any dependencies or chicken-egg things involved
⏹️ ▶️ John in there? Like, in other words, in order to… Do you have to nail down some aspects
⏹️ ▶️ John of your concurrency model before you can commit to ABI stability, or are they totally orthogonal?
⏹️ ▶️ Chris Lattner I think they’re totally orthogonal. I think the memory ownership model has more of an impact on ABI
⏹️ ▶️ Chris Lattner stability, because there’s some very low-level things, like how the
⏹️ ▶️ Chris Lattner getters and setters are co-generated for a property, for example, that end up getting
⏹️ ▶️ Chris Lattner impacted by the ownership model. That’s one of the reasons that the
⏹️ ▶️ Chris Lattner Swift team is actually actively designing and working on a proposal for
⏹️ ▶️ Chris Lattner the memory ownership stuff right now. It’s not so that it can be a Swift 4 feature, it’s so
⏹️ ▶️ Chris Lattner that the ABI stability work can be done in light of the ultimate model for the
⏹️ ▶️ Chris Lattner memory ownership support. And I think concurrency is not
⏹️ ▶️ Chris Lattner going to be something that impacts ABI stability at all. But we’ll see, and if so,
⏹️ ▶️ Chris Lattner then the sufficiently smart programmers that work on Swift will figure it out, and I’m sure it
⏹️ ▶️ Chris Lattner will be great. I think it’s also an interesting question of whether ABI stability will be
⏹️ ▶️ Chris Lattner done for Swift 4 because it’s a huge amount of work.
⏹️ ▶️ Chris Lattner The work is well underway, of course, but it’s also not clear to me that’s really
⏹️ ▶️ Chris Lattner the right, or the most important thing for the Swift community. And one of the things that Ted
⏹️ ▶️ Chris Lattner has been a huge champion for and I think he’s right about is that the most important thing right
⏹️ ▶️ Chris Lattner now for the Swift community is making the compiler more reliable, making the error messages better,
⏹️ ▶️ Chris Lattner making compile times faster and making it scale better to
⏹️ ▶️ Chris Lattner large projects. And we’ll see how the rest of the Swift 4 schedule goes,
⏹️ ▶️ Chris Lattner but I wouldn’t be surprised if at some point they decide that focusing on that on that is more important
⏹️ ▶️ Chris Lattner than nailing ABI stability in Swift 4.
Leaving it in good hands
⏹️ ▶️ Marco So you just mentioned Ted, that’s Ted Kremenek, who is now the lead of the Swift project,
⏹️ ▶️ Chris Lattner, Marco Yeah,
⏹️ ▶️ Chris Lattner he’s the project lead. So Ted has been managing the Swift and Clang
⏹️ ▶️ Chris Lattner projects before that for a number of years. He’s been at Apple for 10 years now. He’s a
⏹️ ▶️ Chris Lattner Stanford PhD graduate. He built single, almost single-handedly,
⏹️ ▶️ Chris Lattner the first Clang stack analyzer. Yeah, that’s Ted.
⏹️ ▶️ Marco So as a, I love that I’m saying this now, as a Swift developer, should
⏹️ ▶️ Marco I be… As we saw when you announced that you were leaving Apple, we saw
⏹️ ▶️ Marco some of the people in the community asking like, should we be worried about Swift’s future? Is Swift in good hands now? I mean,
⏹️ ▶️ Marco it seems like most of us didn’t know Ted, or at least didn’t know his name or weren’t familiar with his contributions.
⏹️ ▶️ Marco It does seem like he’s been doing quite a bit there anyway. Should we be worried?
⏹️ ▶️ Chris Lattner I don’t think you should be worried at all. I think Swift is in amazing hands as is, I mean,
⏹️ ▶️ Chris Lattner all the things that I am leaving behind at Apple in quotes are in really good hands. And that’s
⏹️ ▶️ Chris Lattner one of the only reason I was comfortable in moving on. In the case of Ted,
⏹️ ▶️ Chris Lattner Ted is a rock star. He has been running the Swift team and managing them for,
⏹️ ▶️ Chris Lattner I mean, four or five years now. The roles
⏹️ ▶️ Chris Lattner that we had was that Ted owned and ran his team and then reported to me. And so
⏹️ ▶️ Chris Lattner I would mess around and cause trouble by trying to get people
⏹️ ▶️ Chris Lattner to do the exciting, important thing that I thought and maybe it didn’t align with the
⏹️ ▶️ Chris Lattner actually important thing. And therefore, I’d introduce chaos into the world.
⏹️ ▶️ Chris Lattner But Ted was always the stable rudder and the one that was really focused on getting the important things done.
⏹️ ▶️ Chris Lattner He has a number of really exceptional engineers on the team, people on the core team like Doug Greger, John McCall,
⏹️ ▶️ Chris Lattner Joe Groff, Dave Abrahams. These are all just amazingly brilliant people. And
⏹️ ▶️ Chris Lattner also the team includes a bunch of other engineers that are equally dedicated and also
⏹️ ▶️ Chris Lattner just totally amazing people to work with. So the SWIFT team is, I think, one of Apple’s biggest
⏹️ ▶️ Chris Lattner assets. It’s crazy how brilliant and dedicated they are to the project and
⏹️ ▶️ Chris Lattner how excited they are to get to world domination one step at a time.
The shoemaker’s language
⏹️ ▶️ Casey Coming back to kind of a more broad thing, let’s say that, and this is not meant to
⏹️ ▶️ Casey be a tongue-in-cheek reference to your next job. This is just in general. You’re at home, your
⏹️ ▶️ Casey kids are in bed, your wife is out or something like that, and you wanna just write some code. You can’t
⏹️ ▶️ Casey use Swift and you can’t use Objective-C. What are you writing code in? And I know that’s often dependent on
⏹️ ▶️ Casey what project you’re accomplishing, but what’s interesting to you these days that isn’t Swift and isn’t Objective-C?
⏹️ ▶️ Chris Lattner Oh, well, so I mean, I have a ton of different interests. I mean, I really love building ray tracers, for example,
⏹️ ▶️ Chris Lattner and I’ve done a bunch of stuff with that. And I guess if I couldn’t use Swift for that,
⏹️ ▶️ Chris Lattner then I would probably have to use C++.
⏹️ ▶️ John, Chris Lattner that,
⏹️ ▶️ John wanted to give you a chance to not
⏹️ ▶️ John, Marco say C++. This is
⏹️ ▶️ John I remind people when they
⏹️ ▶️ John You know what LLVM is written in, right?
⏹️ ▶️ John, Chris Lattner write that much
⏹️ ▶️ John C++ and not have your answer be C++.
⏹️ ▶️ Chris Lattner And do you know how much angst and personal suffering it causes to have to be writing C++ all day
⏹️ ▶️ Chris Lattner and building a beautiful world for other people? It’s just so unfair. Yeah.
⏹️ ▶️ John That’s where you toil, down in the
⏹️ ▶️ Chris Lattner mines. Yeah, yeah. It’s pain and suffering that’s worth it for the bigger victory. Well,
⏹️ ▶️ John that’s where Swift comes from. Years having to use C++. I could do the same stuff but not feel this much pain.
⏹️ ▶️ Chris Lattner exactly right. There’s a lot of suffering that led to Swift needing to happen
⏹️ ▶️ Chris Lattner So but but it also it really depends I mean, maybe if I was doing you know, if I was a crazy person I’d use pearl for something
⏹️ ▶️ Chris Lattner I don’t know if I’m that insane
⏹️ ▶️ Casey, Chris Lattner done
⏹️ ▶️ Casey well done you never go to read it though nobody could
⏹️ ▶️ Chris Lattner hey if it’s throwaway code then you never need to read it
⏹️ ▶️ Chris Lattner, Marco Poor John
⏹️ ▶️ John just wait for my Pearl Six Grammars to land gently in Swift.
⏹️ ▶️ John, Chris Lattner Yeah,
⏹️ ▶️ Chris Lattner I mean, that’s a great example of Pearl really has nailed the string processing
⏹️ ▶️ Chris Lattner thing, even in Pearl Five, and I think Pearl Six is even better. And Swift has a lot to learn from
⏹️ ▶️ Chris Lattner it, and that’s something where Swift 4 is really
⏹️ ▶️ Chris Lattner learning from Pearl. So I think that’s great.
⏹️ ▶️ Casey Please don’t give him any ammunition. This is terrible. I was enjoying this interview so much until this very moment.
⏹️ ▶️ Chris Lattner Look at it this way, once this happens, John will have no excuse.
⏹️ ▶️ Marco Oh, he will find one.
⏹️ ▶️ Casey Nothing is so perfect that it can’t be complained about. Oh my goodness.
Dynamic features
⏹️ ▶️ John This is a perennial topic on the Swift mailing list. It’s about
⏹️ ▶️ John dynamic features in Swift.
⏹️ ▶️ John are, quote unquote, more dynamic in Objective-C and less so in Swift.
⏹️ ▶️ John In the Swift community, there’s a lot of angst about when, if ever, will Swift allow
⏹️ ▶️ John me to, essentially, like what you said before, you can write Fortran in any language, you can write Objective-C
⏹️ ▶️ John in any language. People will try to write their code in Swift, but using
⏹️ ▶️ John models from Objective-C that require things like, you
⏹️ ▶️ John know, sending messages to objects that you know will receive them, but the compiler can’t guarantee, or, you know, having
⏹️ ▶️ John big heterogeneous collections where you’re just like, no, everything’s ID and it’ll be fine.
⏹️ ▶️ John I don’t even know how to frame this, but I think that the main question has been,
⏹️ ▶️ John are dynamic features possible in Swift? And are they coming in Swift? Or is there
⏹️ ▶️ John some kind of philosophical divide where the most dynamic stuff that people really want
⏹️ ▶️ John will never be forthcoming, not for technical reasons, but just for philosophical and safety reasons?
⏹️ ▶️ Chris Lattner Sure. So I’ve been pretty outspoken about this on the Swift Evolution list, so hopefully this isn’t a huge surprise. But
⏹️ ▶️ Chris Lattner I don’t think there’s any tension between dynamic features and Swift.
⏹️ ▶️ Chris Lattner A lot of people wanna make hay and argue about how it would be impossible to do
⏹️ ▶️ Chris Lattner responders or pick your feature in Swift.
⏹️ ▶️ Chris Lattner And the worst case scenario, frantic blog posts I’ve seen are things
⏹️ ▶️ Chris Lattner that are along lines of someday Apple will rewrite all of its frameworks in Swift
⏹️ ▶️ Chris Lattner and then it will be impossible to write responder chains and then bad things will happen and
⏹️ ▶️ Chris Lattner then we’ll be back in the days of MSC or some other bad thing, right?
⏹️ ▶️ Chris Lattner, Casey Oh God, don’t even bring
⏹️ ▶️ Casey, Chris Lattner that up.
⏹️ ▶️ Chris Lattner Exactly. And so this is this is kind of quite the slope that it’s the discussion ends up being.
⏹️ ▶️ Chris Lattner I think this blew up most recently right before WWDC this year. And
⏹️ ▶️ Chris Lattner it was really interesting to watch the blog posts that people are flinging around because
⏹️ ▶️ Chris Lattner everybody had a different idea of what dynamic meant.
⏹️ ▶️ Chris Lattner, Casey None of
⏹️ ▶️ Chris Lattner them really. So Apple is not going to counter or blog
⏹️ ▶️ Chris Lattner somebody and denounce a blog on somebody’s post.
⏹️ ▶️ Chris Lattner And it’s kind of bad form to do that. But I thought it was very interesting and odd that none of those people actually came to the
⏹️ ▶️ Chris Lattner Swift evolution list, which is the right place to do that, and asked about it. They all just wanted to make these
⏹️ ▶️ Chris Lattner inflamed blog posts for various kinds. So if you get to my opinion, my opinion is that
⏹️ ▶️ Chris Lattner none of those are in tension with Swift’s current design. It’s just a matter of prioritization.
⏹️ ▶️ Chris Lattner And the major problem that Swift has is, again, there’s so much work to
⏹️ ▶️ Chris Lattner do. There’s concurrency model, there’s actors, there’s systems programming, there’s scripting,
⏹️ ▶️ Chris Lattner there’s lots of little things that go in. There’s better things to support static
⏹️ ▶️ Chris Lattner analysis, introducing type state into language. There’s pre and post conditions.
⏹️ ▶️ Chris Lattner There’s so many things that will be bricks in the house of Swift
⏹️ ▶️ Chris Lattner that we want to build that need to happen, that it doesn’t really make sense
⏹️ ▶️ Chris Lattner to spend a lot of time building dynamic features so that Apple could theoretically someday
⏹️ ▶️ Chris Lattner do something. Right? The Swift team is much more focused on the practical necessities of solving
⏹️ ▶️ Chris Lattner the real world problems here and now in front of people. And dynamic features,
⏹️ ▶️ Chris Lattner like many other things, will just kind of flop in place when the team has time to design
⏹️ ▶️ Chris Lattner and roll them out. And so you will be able to someday, or I expect
⏹️ ▶️ Chris Lattner that you will be able to reflect over all the methods that a class has, for example.
⏹️ ▶️ Chris Lattner Today, even, the Swift compiler’s generating all the metadata so you can reflect over all the
⏹️ ▶️ Chris Lattner data members and your values. We just don’t have an API wrapped around that. But that metadata
⏹️ ▶️ Chris Lattner is what the Xcode memory heap viewer uses, for example. And so
⏹️ ▶️ Chris Lattner there’s a lot of that kind of stuff being put in place, but just hasn’t had time to fully bake out yet.
⏹️ ▶️ Chris Lattner And when it does come in, I think it’s gonna really exciting and will open more doors for new kinds of patterns
⏹️ ▶️ Chris Lattner that people can do and a lot of those will be familiar to Objective-C programmers, but they’ll also be super useful for
⏹️ ▶️ Chris Lattner things that people really haven’t done in Objective-C. So I don’t see a lot of tension
⏹️ ▶️ Chris Lattner there though. It’s just a prioritization question.
⏹️ ▶️ John I think where people are coming from is that in terms of prioritization, because if you’re used to doing things
⏹️ ▶️ John with certain sort of design patterns, broadly speaking, in Objective-C and you want to come and implement
⏹️ ▶️ John those same patterns in Swift and you find that you can’t because you’re lacking some feature, it
⏹️ ▶️ John feels like there’s a barrier up. And that’s getting back to writing your Swift in Objective-C style.
⏹️ ▶️ John And that’s more of a barrier. They retreat back to Objective-C because I can write it the way I wanted to write it, and it works in Objective-C.
⏹️ ▶️ John When I try to write it that way and Swift doesn’t work for me, your choice is to change the way you write it to be better fit for
⏹️ ▶️ John what Swift has or to go back to Objective-C. So…
⏹️ ▶️ Chris Lattner I don’t agree with that, though, because is Swift does support all the features
⏹️ ▶️ Chris Lattner for dynamic dispatch and method lookup and everything else that Objective-C does. It just requires
⏹️ ▶️ Chris Lattner you to use the Objective-C subset of the language because it exposes it through the runtime.
⏹️ ▶️ John Right, that’s the tension because they’re like, oh, I want to write it in pure Swift, like
⏹️ ▶️ John as if there’s something special and magical about not using Objective-C runtime, you
⏹️ ▶️ John know what I mean? You do get a medal for that.
⏹️ ▶️ Chris Lattner, John Yeah.
⏹️ ▶️ Chris Lattner I guess it makes some people feel good. I mean, there are, I can’t really
⏹️ ▶️ Chris Lattner counter that, but I just don’t think that it’s actually fair to say you have to fall back to writing
⏹️ ▶️ Chris Lattner Objective-C
⏹️ ▶️ Chris Lattner, John code. Yeah,
⏹️ ▶️ John no, no, I’m just, I’m
⏹️ ▶️ John, Chris Lattner trying
⏹️ ▶️ John to, I didn’t write one of these blog posts, so to be fair, I’m trying to express what I saw in there, because that was a lot of the concern
⏹️ ▶️ John was like, they wanna do it, they wanna do it like the new way and the right way, and
⏹️ ▶️ John part of doing that is not, you know, at Objective-Cing everything, and be like, oh, that feels like a compromise in the old way, so
⏹️ ▶️ John they are setting their own goalposts for themselves arbitrarily to try to enter
⏹️ ▶️ John into this new world. And they want to jump in with both feet or not
⏹️ ▶️ John at all. And some of them might end up bailing. But I think this,
⏹️ ▶️ Chris Lattner I mean, the way I look at that is, I look at that as an area where the language is not fully
⏹️ ▶️ Chris Lattner baked out. It’s not fully serving their needs. And I think that’s really unfortunate.
⏹️ ▶️ Chris Lattner And I’m not going to say that I think that’s not a good thing. I want there to be an awesome reflection model.
⏹️ ▶️ Chris Lattner I don’t want there to be awesome features for sending messages like they’re used to. I just want
⏹️ ▶️ Chris Lattner it to be developed and designed in the right way. And at the same time, they’re being annoyed
⏹️ ▶️ Chris Lattner that they can’t do those things. There are a lot of other people being annoyed about compile times, right?
⏹️ ▶️ Chris Lattner, Marco Yeah, I know.
⏹️ ▶️ Chris Lattner And what we have to do is balance between, you know, just picking
⏹️ ▶️ Chris Lattner two random things. Where does the engineering effort go? And
⏹️ ▶️ Chris Lattner that’s never a black and white thing. There’s never a right answer. It’s all based on gut and judgment
⏹️ ▶️ Chris Lattner and guesses, listening to the community, talking to people. And that’s one of the reasons why
⏹️ ▶️ Chris Lattner I think the Swift team is really phenomenal is that it really cares. It really cares about what people
⏹️ ▶️ Chris Lattner are doing. It reads, you know, the various people read the blog posts, there are people on Twitter, that like
⏹️ ▶️ Chris Lattner the engagement between the Swift team and the community is really high because people care.
⏹️ ▶️ Chris Lattner And there’s no management dictated apple that says that, you know, this engineer should be on Twitter all the
⏹️ ▶️ Chris Lattner time talking to people, that’s certainly not the case. That’s because of passion from the developer and it’s because
⏹️ ▶️ Chris Lattner they really care. And I think that’s the thing that is so amazing about the Swift team is
⏹️ ▶️ Chris Lattner just how important it is in terms of customer service and understanding
⏹️ ▶️ Chris Lattner what people are working through. And that insight is what guides the priority
⏹️ ▶️ Chris Lattner decisions and guides the trade-offs that have to be made all the time because nothing really is
⏹️ ▶️ Chris Lattner as clear as you’d like it to be.
Community influence
⏹️ ▶️ Casey So building on that, when all of us were going back and forth, and I was tangentially
⏹️ ▶️ Casey involved with this, we were going back and forth about, oh, Swift isn’t dynamic, it must be dynamic.
⏹️ ▶️ Casey Is it fair to say that that does eventually make its way inside of Apple? And just
⏹️ ▶️ Casey that you guys are aware of it, that that’s talked about in some way, shape, or form? Because
⏹️ ▶️ Casey it’s nice to know, and I suspect that it does, but it’s nice to know that when the community gets
⏹️ ▶️ Casey perturbed, whether or not that feeling is justified, that at least somebody
⏹️ ▶️ Casey inside Apple has heard it. Whether or not they can respond to it, at least they’ve heard it. So when we
⏹️ ▶️ Casey all get our pants all twisted up, does that make
⏹️ ▶️ Chris Lattner Jay Haynes Absolutely. I mean, there are a ton of people at Apple that care about
⏹️ ▶️ Chris Lattner what’s happening in the developer community and elsewhere, right? And that’s one of the
⏹️ ▶️ Chris Lattner things about Apple’s approach in terms of not commenting on things that can be frustrating because you don’t know.
⏹️ ▶️ Chris Lattner But again, there’s so many people at Apple that really do care and that saw
⏹️ ▶️ Chris Lattner it. And again, I wish those people that were
⏹️ ▶️ Chris Lattner really worried about it would come to Swift Evolution and ask because then we could have a discussion about it, but that
⏹️ ▶️ Chris Lattner wasn’t happening for some reason. But certainly there was a ton of people that saw the blogs. And
⏹️ ▶️ Chris Lattner I’m sure there are tons of engineers at Apple that feel the same way and wish the priorities were different And
⏹️ ▶️ Chris Lattner I think that the engineering community inside of Apple reflects quite closely to the engineering
⏹️ ▶️ Chris Lattner community outside of Apple as well. And I don’t think that that’s, I hope that’s
⏹️ ▶️ Chris Lattner not surprising,
⏹️ ▶️ Chris Lattner, John right?
⏹️ ▶️ Chris Lattner Apple has many different engineers with different feelings and different opinions. And I think that’s a
⏹️ ▶️ Chris Lattner really good thing. If it were a super monoculture or something like that, that would probably be very unhealthy.
RxSwift
⏹️ ▶️ Casey Taking a little bit of a turn, so I started writing Swift almost
⏹️ ▶️ Casey exactly a year ago now, and the project that I’m doing at work, we’re using RxSwift
⏹️ ▶️ Casey and quote-unquote reactive programming. And I’m curious, have you looked into that at all?
⏹️ ▶️ Casey And do you have any particular thoughts on it? Does it seem barbaric to you? Does it seem clever? Does it just seem like
⏹️ ▶️ Casey an odd choice? What is your take on this whole Rx thing?
⏹️ ▶️ Chris Lattner Yeah, so I’ve definitely seen it. I have no real world usage experience.
⏹️ ▶️ Chris Lattner So most of my opinion is based on reading blogs and reading people talking about how awesome
⏹️ ▶️ Chris Lattner it is while not
⏹️ ▶️ Chris Lattner, John talking about
⏹️ ▶️ Chris Lattner the problems. From what I gather, it seems like
⏹️ ▶️ Chris Lattner it is a way of letting you write a lot less code and code that often works
⏹️ ▶️ Chris Lattner better the first time. And I can see how that’s super appealing. It also seems like it’d be really challenging to debug it and
⏹️ ▶️ Chris Lattner maintain it. And so I don’t know between the two, between the pros and cons, how it balances
⏹️ ▶️ Chris Lattner out. If I were writing a lot of high-level apps, I would probably try it out on an app
⏹️ ▶️ Chris Lattner or two and see if I liked it, but aside from that, I don’t really
⏹️ ▶️ Chris Lattner have a good insight either way if it’s the right thing to do or not.
⏹️ ▶️ Casey Sure, sure, absolutely. You mentioned a second ago that you see some problems and you mentioned debugging.
⏹️ ▶️ Casey Is there anything else that jumps out at you as being a big concern, or is it just that it’s so different?
⏹️ ▶️ Chris Lattner I mean, I’m not afraid of different things. I think that it’s more of, I mean, the
⏹️ ▶️ Chris Lattner questions I’d raise, and this is out of ignorance, not out of fear, but what is
⏹️ ▶️ Chris Lattner the community doing? Is there a support line?
⏹️ ▶️ Chris Lattner Is it changing and evolving in a way that is good or bad? And these are just things I don’t know because
⏹️ ▶️ Chris Lattner I haven’t used it. But I have nothing against the Rx community at all, and I’ve seen a lot of really cool things
⏹️ ▶️ Chris Lattner they’ve done, and I’ve read many of the positive posts in Rx and
⏹️ ▶️ Chris Lattner React Native and many of the other things where people are using Reactive techniques. And Reactive Cocoa
⏹️ ▶️ Chris Lattner has also been around for quite a while. And I think that’s a really interesting application that
⏹️ ▶️ Chris Lattner maybe became a lot easier when Swift came out than doing it in Objective-C. Yeah,
⏹️ ▶️ Chris Lattner So I think that it’s great that Swift can support different kinds of programming models like that because
⏹️ ▶️ Chris Lattner if a awesome new right answer to some problem comes out, you’d hope
⏹️ ▶️ Chris Lattner that your system can support it and can make it really elegant and beautiful.
GC vs. ARC
⏹️ ▶️ John I feel kind of like this is fighting, you know, the last war instead of the current
⏹️ ▶️ John war, but you mentioned garbage collection versus ARK a bunch of times, and obviously that ship
⏹️ ▶️ John has sailed, but I would love for you to give a
⏹️ ▶️ John reasonable summary of what the trade-offs were there, because Objective-C had garbage collection,
⏹️ ▶️ John, Casey Well, sort of. Yeah, well, you know, it was there.
⏹️ ▶️ John And eventually Objective-C dropped the garbage collection and got ARC, and of course, Swift doesn’t have garbage
⏹️ ▶️ John collection at all. Can you talk about the tradeoffs there and why Swift is the way it is?
⏹️ ▶️ Chris Lattner Well, would you like a comparison of ARC against the garbage collection Objective-C
⏹️ ▶️ Chris Lattner had or garbage collection in theory?
⏹️ ▶️ John You could pick garbage collection in a language perhaps not as burdened as Objective-C with C backwards
⏹️ ▶️ John compatibility. But, you know, that’s worth mentioning as well, I think. I think
⏹️ ▶️ Chris Lattner that, so Objective-C had a system based on Libato, Libato had a bunch of implementation concerns and
⏹️ ▶️ Chris Lattner other things that I think don’t reflect, that don’t obviously reflect onto
⏹️ ▶️ Chris Lattner the ultimate garbage collector that you’d ever wanna have. And so I don’t think the comparing against that
⏹️ ▶️ Chris Lattner is interesting. But let me turn around. So why do you think garbage collection’s interesting? What is compelling
⏹️ ▶️ Chris Lattner about garbage collection beyond ARC?
⏹️ ▶️ John Well, the idea that memory management is completely out of the hands of the programmer and
⏹️ ▶️ John that some magical fairy behind the scenes will make it all good for you. And
⏹️ ▶️ John obviously, what you’re giving up is what you mentioned before, that even with ARC, you lack some amount of control
⏹️ ▶️ John that you’ll need to have a language that becomes a system programming language. Obviously, you give that up with garbage collection because you’re not going
⏹️ ▶️ John to be doing a system programming language with a garbage collector behind it. Although,
⏹️ ▶️ John I think Microsoft has some projects to do that, that Singularity project, where they were trying to build a whole OS off of garbage collection.
⏹️ ▶️ John I’m not quite sure how that’s going.
⏹️ ▶️ Chris Lattner Right, but even if you ignore the systems programming side of things, because I think it’s fair to say a lot of
⏹️ ▶️ Chris Lattner people don’t care about that. So garbage collection is proven
⏹️ ▶️ Chris Lattner in the application space for Java, for example, right? And Perl.
⏹️ ▶️ Chris Lattner, John Perl uses
⏹️ ▶️ John reference counting, come on.
⏹️ ▶️ Chris Lattner Oh, that’s right. It’s Python that uses reference counting plus cycle collector. So, but
⏹️ ▶️ Chris Lattner let me ask you again. So you said it means you don’t have to think about memory. Is that true?
⏹️ ▶️ John Well, that’s the pitch. The pitch is that the programmer doesn’t have to think about it. They have to think about it when the garbage
⏹️ ▶️ John, Chris Lattner collector starts.
⏹️ ▶️ John I understand the pitch. But is it true? When the garbage collector starts doing things you don’t want, then all of
⏹️ ▶️ John a sudden you do have to think about it. But then there’s almost nothing you can do about it. Yeah.
⏹️ ▶️ Chris Lattner So here’s the way I look at it. And as you said, the ship has somewhat sailed.
⏹️ ▶️ Chris Lattner I am totally convinced the Ark is the right way to go up front. It is better
⏹️ ▶️ Chris Lattner in a whole bunch of different ways. It gives you deterministic behavior. So you don’t get,
⏹️ ▶️ Chris Lattner you know, it doesn’t have the unpredictable stutter problem that people like to bash on GCs.
⏹️ ▶️ Chris Lattner The stutter problem to me isn’t really the issue, even though that’s what GC haters
⏹️ ▶️ Chris Lattner will bring up all the time. It’s more about being able to reason about when the memory goes away.
⏹️ ▶️ Chris Lattner And the most important aspect of that is that ARC gets rid of finalizers. So if
⏹️ ▶️ Chris Lattner you use a garbage collected language, you use finalizers. Finalizers are the thing that gets run when your
⏹️ ▶️ Chris Lattner object gets destroyed. Finalizers have so many problems, there’s
⏹️ ▶️ Chris Lattner entire bodies of work talking about how to work around problems with finalizers. For example, the finalizer gets run
⏹️ ▶️ Chris Lattner on the wrong thread, it has to get run multiple times, the object can get resurrected while the finalizer’s running.
⏹️ ▶️ Chris Lattner It happens non-deterministically later, you can’t count on it, and so you can’t use it for resource management
⏹️ ▶️ Chris Lattner for database handles and things like that, for example. There are so many problems
⏹️ ▶️ Chris Lattner with finalizers that ARC just defines away by having deterministic destruction.
⏹️ ▶️ Chris Lattner Beyond that, ARC, so the common,
⏹️ ▶️ Chris Lattner another common thing, there are two arguments that people make against ARC in
⏹️ ▶️ Chris Lattner favor of a trace and garbage collector. One of which is that ARC adds overhead because you have
⏹️ ▶️ Chris Lattner retainer release operations that run, and that is true. The other is that
⏹️ ▶️ Chris Lattner you have to think about cycles in ARC. because it
⏹️ ▶️ Chris Lattner doesn’t automatically collect cycles. And that is also true. And the rebuttal I’d
⏹️ ▶️ Chris Lattner give to people is that those problems are also true in garbage collection,
⏹️ ▶️ Chris Lattner just in different ways. So in a garbage collector, for example, people don’t think about it, but
⏹️ ▶️ Chris Lattner garbage collection injects additional code into your application, just like Arc does. And so,
⏹️ ▶️ Chris Lattner you know, there are many different garbage collection algorithms. Not all of them are the same, But
⏹️ ▶️ Chris Lattner the most modern garbage collectors that use a nursery for
⏹️ ▶️ Chris Lattner short lifetime objects and then promote them out that are generational use something called a write
⏹️ ▶️ Chris Lattner barrier. And a write barrier is every time you store to a
⏹️ ▶️ Chris Lattner property of an object, say, you have to run additional code. Garbage collectors also
⏹️ ▶️ Chris Lattner need the ability to stop all the threads, or at least to be able to stop threads at some point in time. and
⏹️ ▶️ Chris Lattner they need to be able to do so within a specific time bound because they don’t want the garbage collector to take forever.
⏹️ ▶️ Chris Lattner The artifact of that is that typical garbage collectors in Java, for example, will
⏹️ ▶️ Chris Lattner introduce what’s called a safe point into loops. And so now in your loops, extra
⏹️ ▶️ Chris Lattner code is being run because of the garbage collector. And on more aggressive garbage
⏹️ ▶️ Chris Lattner collection algorithms, for example, I was reading a blog post recently about Go’s tricolor
⏹️ ▶️ Chris Lattner algorithm. They’re touting the advantage of, you get really low latency,
⏹️ ▶️ Chris Lattner and you get the ability to guarantee response times in a more
⏹️ ▶️ Chris Lattner fine-grained level than most garbage collectors. But to do that, they use this tricolor algorithm, which
⏹️ ▶️ Chris Lattner dramatically lowers throughput. And it dramatically lowers throughput because they’re doing almost exactly
⏹️ ▶️ Chris Lattner the same kinds of operations that ARC is doing. The problem that it then introduces,
⏹️ ▶️ Chris Lattner though, is that these operations that the garbage collector’s introducing are sometimes, but not nearly
⏹️ ▶️ Chris Lattner as well optimizable as the ARC overhead that the ARC optimizer applies to.
⏹️ ▶️ Chris Lattner And furthermore, there’s no kind of out on it. So with ARC, I think and hope that the ownership model will
⏹️ ▶️ Chris Lattner give people the ability to take control of those overheads. And if it becomes a problem in practice, or
⏹️ ▶️ Chris Lattner if they’re just that kind of person, they can take full control over the lifetime of their objects and then know the ARC
⏹️ ▶️ Chris Lattner will never happen. In the garbage collector, you don’t have that. So the performance side of things, I think,
⏹️ ▶️ Chris Lattner is still up in the air because Arc certainly does introduce overhead.
⏹️ ▶️ Chris Lattner Some of that’s unavoidable, at least without lots of annotations in
⏹️ ▶️ Chris Lattner your code. But also I think that Arc is not done yet. A ton of energy has been
⏹️ ▶️ Chris Lattner poured into research for garbage collection, particularly since Java has come up. There have been hundreds
⏹️ ▶️ Chris Lattner of papers written in the academic circles, tons of work in Hotspot and
⏹️ ▶️ Chris Lattner other Java implementations to do different tweaks and different tunings and different
⏹️ ▶️ Chris Lattner new kinds of algorithms in garbage collection. And that work really hasn’t been done for Arc yet. And so
⏹️ ▶️ Chris Lattner I think that there’s still a big future ahead. On the programming side of things, the cycle side
⏹️ ▶️ Chris Lattner of things, I think it’s also a really interesting question of how much should people think about memory?
⏹️ ▶️ Chris Lattner When I was baiting you a little bit, you said that the great thing about garbage collection is that you
⏹️ ▶️ Chris Lattner don’t have to think about memory. But of course we know that’s not true, right? because if you have a
⏹️ ▶️ Chris Lattner reference to some big object graph that you didn’t mean to keep around, maybe it’s in your undo stack, then you will
⏹️ ▶️ Chris Lattner quote unquote leak that memory, right? And that’s true of a garbage
⏹️ ▶️ Chris Lattner collector, that’s true of ARC as well. It’s just any automatic memory management approach has
⏹️ ▶️ Chris Lattner that problem. And so that is a really
⏹️ ▶️ Chris Lattner interesting thing that there’s this question of, if you’re building a
⏹️ ▶️ Chris Lattner large scale system, Do you want people to quote unquote, never think about memory?
⏹️ ▶️ Chris Lattner Do you want them to think about memory all the time like they did in Objective-C classic retain
⏹️ ▶️ Chris Lattner and release, manual retain and release? Or do you want something in the middle? And I think the arc strikes a
⏹️ ▶️ Chris Lattner really interesting balance, either whether it’s in Objective-C or in Swift, where
⏹️ ▶️ Chris Lattner I look at manual retain and release as being a very imperative style of memory management
⏹️ ▶️ Chris Lattner or Malcon-free, all these things where you’re telling the code line by line, this is where you should do
⏹️ ▶️ Chris Lattner a reference count operation, this is where you should release the memory, this is what you should do at this point in time.
⏹️ ▶️ Chris Lattner Arc then takes that model and bubbles it up a big step, and it makes it be a very
⏹️ ▶️ Chris Lattner declarative model. So instead of telling the compiler that this is the place you
⏹️ ▶️ Chris Lattner should do a retain, you instead say, this is an owning relationship. And
⏹️ ▶️ Chris Lattner the cool thing about that to me is that not only does that get rid of the mechanics
⏹️ ▶️ Chris Lattner of maintaining reference counting and define away tons of bugs by doing that, it also means that it
⏹️ ▶️ Chris Lattner is now explicit in your code what your intention was. And that’s something that people who maintain your
⏹️ ▶️ Chris Lattner code benefit from. And so by saying that I have a weak pointer to the parent object
⏹️ ▶️ Chris Lattner of my thing, that’s a really important relationship to know about. And
⏹️ ▶️ Chris Lattner as you’re looking at the code, you’re maintaining the code, having that be explicit is very valuable because that talks about
⏹️ ▶️ Chris Lattner the relationship between values and to me, again, with the goal of
⏹️ ▶️ Chris Lattner being able to write large scale applications in Swift, I think that’s really useful. I also don’t think it’s hugely burdensome,
⏹️ ▶️ Chris Lattner though it is definitely part of the learning curve of learning how Swift works that, you
⏹️ ▶️ Chris Lattner know, has to be balanced in there as well. And so,
⏹️ ▶️ Chris Lattner, Casey I don’t know,
⏹️ ▶️ Chris Lattner I mean, I look at it as there, Arc has clear advantages
⏹️ ▶️ Chris Lattner in terms of allowing Swift to scale down to systems that can’t
⏹️ ▶️ Chris Lattner tolerate having a garbage collector, for example, if you want to write firmware in Swift. I
⏹️ ▶️ Chris Lattner think it does provide a better programming model where programmers think just a little bit about memory.
⏹️ ▶️ Chris Lattner And I think that going forward, it provides a really high performance
⏹️ ▶️ Chris Lattner model that you can get better than garbage collection in almost every way. So
⏹️ ▶️ Chris Lattner I think that in terms of trade-offs, it’s the right one to push forward. The other, I guess, third piece
⏹️ ▶️ Chris Lattner that garbage collection is really bad about is
⏹️ ▶️ Chris Lattner kind of a showstopper for Swift, which is interoperability with C code. So if you’ve
⏹️ ▶️ Chris Lattner ever worked with Java or with other similar garbage collected languages,
⏹️ ▶️ Chris Lattner one of the major advantages the garbage collectors give you is that they move objects and they need to do that so they can compact
⏹️ ▶️ Chris Lattner those objects so that they can then efficiently do allocations. But the
⏹️ ▶️ Chris Lattner problem is that once you start moving objects around if you’re interfacing with C code, you can’t have some
⏹️ ▶️ Chris Lattner random C code having a pointer to your object and have it move because then you get a dangling pointer.
⏹️ ▶️ Chris Lattner And so once you get down that line, you end up with things like JNI, the Java Native
⏹️ ▶️ Chris Lattner Interface, where you have to explicitly pin things, you have to maintain them, it’s
⏹️ ▶️ Chris Lattner very complicated, it’s really buggy, and Arc completely defines this away by
⏹️ ▶️ Chris Lattner just saying that, okay, something’s in memory, it has predictable lifetime, you can
⏹️ ▶️ Chris Lattner reason about it, Swift provides tools for dealing with unsafe pointers and things like that,
⏹️ ▶️ Chris Lattner and that makes the interoperability with existing C code, but also with Objective-C and maybe someday C++ code.
⏹️ ▶️ Chris Lattner Really simple, really natural, and really efficient. And I think that’s a huge advantage that Arc provides
⏹️ ▶️ Chris Lattner that really would be impossible to do with a garbage collector.
⏹️ ▶️ Chris Lattner So that’s my opinion. I mean, I think reasonable
⏹️ ▶️ Chris Lattner, Marco people
⏹️ ▶️ Chris Lattner disagree, obviously, but it’s something that does come up now and then.
⏹️ ▶️ John Or it used to come up anyway. I’m convinced. I think you should use Arc for Swift. Get on that. Yep, there we go.
⏹️ ▶️ Casey Chris, thank you. Thank you very, very, very much for coming on the show. Obviously we are
⏹️ ▶️ Casey not an interview show as listeners have discovered over the last hour or two, but to
⏹️ ▶️ Casey take your time on what is presumably a very busy time of your life and spend it with
⏹️ ▶️ Casey us three knuckleheads, I really appreciate it. And it was very kind of you to do and hopefully
⏹️ ▶️ Casey this won’t be the last time that we’ll hear you on a show or maybe even this show. We’ll see. So thank you, Chris. I
⏹️ ▶️ Casey really appreciate it. Chris Steininger Yeah. Well, thank you
⏹️ ▶️ Chris Lattner for having me. I’m terrified and probably made a fool out of myself.
⏹️ ▶️ Casey Not at all. Trust me, that’s normal. I’m still trying to get over that. Plus that’s our job.
⏹️ ▶️ Marco All right. All right. Thanks a lot to our three sponsors this week, Eero, Squarespace, and Audible. and we will see
Ending theme
⏹️ ▶️ Casey Now the show is over, they didn’t even mean to begin Cause
⏹️ ▶️ Casey it was accidental, oh it was accidental
⏹️ ▶️ Casey John didn’t do any research, Marco and Casey wouldn’t let him Cause
⏹️ ▶️ Casey it was accidental, oh it was accidental
⏹️ ▶️ Casey And you can find the show notes at atp.fm
⏹️ ▶️ John into Twitter, you can follow them at C-A-S-E-Y-L-I-S-S
⏹️ ▶️ Casey So that’s Casey Liss, M-A-R-C-O-A-R-M, and
⏹️ ▶️ Casey T. Marco Armin S-I-R-A-C-U-S-A Syracuse
⏹️ ▶️ Casey It’s accidental, they didn’t
⏹️ ▶️ John Accidental, check podcast so long
Post-show: Making splinters
⏹️ ▶️ John We didn’t talk about woodworking stuff.
⏹️ ▶️ Chris Lattner Yeah, making splinters is fun.
⏹️ ▶️ John What kind of wood was that table made out of?
⏹️ ▶️ Chris Lattner It’s walnut.
⏹️ ▶️ John That’s got to be tough. That’s a lot of cutting. That’s pretty hard wood, right?
⏹️ ▶️ Chris Lattner Yeah, I mean it takes time, but it’s fun. It’s one of these areas where you can learn a lot
⏹️ ▶️ Chris Lattner about it over time and keep going deeper and deeper in different spaces and you never
⏹️ ▶️ Chris Lattner know everything. So it’s a lot of fun to dive into woodworking. also very very different than sitting
⏹️ ▶️ Chris Lattner in front of a computer all day yeah you actually get to make something with your hands and you get a build much higher chance
⏹️ ▶️ Chris Lattner for dismemberment
⏹️ ▶️ Marco that is true that is true so like I think it’s interesting when programmers have like incredibly
⏹️ ▶️ Chris Lattner it’s also hilarious because the woodworking community is going through this whole CNC thing
⏹️ ▶️ Chris Lattner, John turning
⏹️ ▶️ Chris Lattner it into a very programmed thing and people always say well, why don’t you get into CNC and do blah,
⏹️ ▶️ Chris Lattner blah, blah? But that’s exactly what I’m escaping. I don’t want to have to program my.
⏹️ ▶️ Marco I love that you can’t even escape the community arguments over standards.
⏹️ ▶️ John So you just cut down a tree and you throw it into your workshop and then out comes a table.
⏹️ ▶️ Chris Lattner Yeah, well, so that’s the funny thing about people is that people are all the same. They just don’t want to notice
⏹️ ▶️ Chris Lattner and agree to that. Oh my goodness. You get to very different communities and they think they’re all different, but they’re actually
⏹️ ▶️ Chris Lattner the same at root.
Post-show: Neutral
⏹️ ▶️ Casey So Chris, you’re obviously changing careers, well not careers necessarily,
⏹️ ▶️ Casey but changing employers. Would you consider yourself a car person?
⏹️ ▶️ Chris Lattner Chris Steiner Well, that’s a funny question. I mean, I obviously need a car.
⏹️ ▶️ Chris Lattner Car is really important. But I’m what I consider to be an un-car person. I want
⏹️ ▶️ Chris Lattner to accelerate the path to cars being appliances that solve people’s problems.
⏹️ ▶️ Chris Lattner And I’m personally not the kind of guy who loves doing oil changes and fiddling around with
⏹️ ▶️ Chris Lattner them. I just want something that is reliable, that works, ideally drives me to where I want to go,
⏹️ ▶️ Chris Lattner and I don’t have to think about it. It’s just solving my problems. It’s not something I have to care
⏹️ ▶️ Chris Lattner for, feed, and maintain. So that’s kind of the way I look at cars. Can you drive
⏹️ ▶️ Chris Lattner a stick? I did drive a stick before I got my Tesla a few years ago.
⏹️ ▶️ Casey It all comes clear now.
⏹️ ▶️ Marco I mean, really, from the point of view, it kind of sounds like you want to make cars is boring
⏹️ ▶️ Marco in a good way, really. And that’s a notable goal, and I can see why you went
⏹️ ▶️ Marco to Tesla. However, it is kind of funny that Tesla is, in my opinion, clearly the
⏹️ ▶️ Marco most exciting car company that the world has known for quite some time. And so to go there
⏹️ ▶️ Marco while having such an almost nonchalant opinion about cars is
⏹️ ▶️ Marco interesting to me.
⏹️ ▶️ Chris Lattner Yeah, well, I admit that I never considered going to work at a car company before,
⏹️ ▶️ Chris Lattner but that’s because I always considered car companies to be, you know,
⏹️ ▶️ Chris Lattner not in need of the kinds of skills that I bring. But autopilot, I think, is a really exciting
⏹️ ▶️ Chris Lattner and really big problem, and it kind of fits with my desire to solve
⏹️ ▶️ Chris Lattner nearly impossible problems and take on new things. And so I’m really excited
⏹️ ▶️ Marco So I’m a little curious on that note. We’ve talked on the show before
⏹️ ▶️ Marco about whether we think that full self-driving cars,
⏹️ ▶️ Marco basically when and whether we think those will exist, like in what kind of time frame are we talking a decade, our lifetimes,
⏹️ ▶️ Marco ever? Because it’s one thing to make something that can work on clearly marked highways. It’s another
⏹️ ▶️ Marco thing that can make something work where John lives, where there’s ice all over the roads for most of the
⏹️ ▶️ Marco year. And so there’s no more lane markings, there’s barely any flat road surfaces, or
⏹️ ▶️ Marco you have all these different ambiguities that you have in real world roads.
⏹️ ▶️ Marco Do you think… Again, obviously, this is not in any kind of official capacity as an
⏹️ ▶️ Marco about-to-be Tesla employee. Do you think, big picture,
⏹️ ▶️ Marco that we will see completely self-driving cars capable of driving on effectively all roads
⏹️ ▶️ Marco within, say, the next decade? And if maybe within our lifetimes?
⏹️ ▶️ Chris Lattner Yeah, I think that it’s very possible within the next decade. And hopefully that’s a long, long,
⏹️ ▶️ Chris Lattner long view. But keep in mind, the goal is to drive
⏹️ ▶️ Chris Lattner better than a human, and significantly better than a human. And I think one of the things
⏹️ ▶️ Chris Lattner that gives me confidence in this is that it’s not an even playing field
⏹️ ▶️ Chris Lattner because the autonomous cars have more sensors than humans do. You
⏹️ ▶️ Chris Lattner know, they have a radar, for example. And that means that they’re capable of doing things that humans
⏹️ ▶️ Chris Lattner just physically can’t. And there’s a huge technology problem, there’s huge software
⏹️ ▶️ Chris Lattner problems. This is not a overnight kind of a thing that you wake up and solve immediately.
⏹️ ▶️ Chris Lattner But I have confidence it could be solved, certainly within a decade.
⏹️ ▶️ Casey Well, the good news is it’s not gonna take a lot to be better than your average driver from Massachusetts,
⏹️ ▶️ Casey because that’s a pretty low bar.
⏹️ ▶️ John No, because they know how to navigate these
⏹️ ▶️ John, Casey intersections that have like seven
⏹️ ▶️ John different exits, all at different angles, some of which are one way, none of which are marked. So the humans
⏹️ ▶️ John gonna be tough for the sensors.
⏹️ ▶️ Marco Tell you one thing, I will drive in Manhattan without any problems. I would never drive in Boston.
⏹️ ▶️ Casey Oh, amen, brother. I completely agree. All right, so to bring this back around, Chris, you made mention way early
⏹️ ▶️ Casey in the episode that you like yellow cars. What? Yeah, yeah.
⏹️ ▶️ Casey, Chris Lattner What is this
⏹️ ▶️ Chris Lattner some my my my one of my favorite cars was a yellow mini cooper with
⏹️ ▶️ Chris Lattner black hood stripes on it nice and Many Cooper convertible it was totally awesome
⏹️ ▶️ Chris Lattner that doesn’t get you in the carpool lane, but It was a beautiful car
⏹️ ▶️ Marco in his defense like yellow Like I’ve seen a like that kind of that kind of
⏹️ ▶️ Marco that category of color like yellow orange maybe teal or even like
⏹️ ▶️ Marco a pink, like they’re kind of like bright, almost neon-ish colors, can work really well. They
⏹️ ▶️ Marco often don’t, but when they work well, they look pretty good. I could totally see
⏹️ ▶️ Marco that. The only flaw I see in this plan is that Tesla does not currently offer either
⏹️ ▶️ Marco yellow paint as an option or custom paint colors as an option.
⏹️ ▶️ Chris Lattner Well, so now you’ve broken into the real secret. They want to hire a compiler guy. That’s why.
⏹️ ▶️ John Would you’ve gotten your Tesla in yellow if you could have?
⏹️ ▶️ John, Chris Lattner Yes, absolutely. It would look like a giant
⏹️ ▶️ John, Marco banana. What
⏹️ ▶️ John, Casey are you talking about? Yeah, I hadn’t really fully
⏹️ ▶️ Casey thought this through, John. I don’t know if that car can pull it. We’re talking about a Model S,
⏹️ ▶️ Chris Lattner, John Yeah. Yeah.
⏹️ ▶️ Chris Lattner No, I would. Yellow doesn’t seem right
⏹️ ▶️ John for that. We could do some Photoshop mockups. Let’s workshop it a little bit. We’ll see. Maybe if you’ve got black stripes down the middle. Yeah, I
⏹️ ▶️ John admit this is a case where details matter. So, yeah, I would. I would. I would. I would.
⏹️ ▶️ John, Casey I would. I would. I
⏹️ ▶️ John would. I would. I would. I would. I would.
⏹️ ▶️ Chris Lattner or so yeah no I mean
⏹️ ▶️ Marco that’s like if there’s any if there’s any way for you to get like a pet feature implemented in the model line
⏹️ ▶️ Marco that seems like a pretty good one to do at least and you know I would ask I’m
⏹️ ▶️ Marco sure I know you’re probably not gonna be working on the Bluetooth UI but I’m sure you could probably
⏹️ ▶️ Marco put in a word with the right people to please improve Bluetooth audio
⏹️ ▶️ Marco but otherwise if you can make a yellow one I think that would be you know in addition to potentially
⏹️ ▶️ Marco saving thousands of lives a year with autopilot software, getting improved Bluetooth and
⏹️ ▶️ Marco a yellow option would be pretty impressive.
⏹️ ▶️ John Well, yellow would make your car more visible to other drivers, other human drivers, who need bright colors to know
⏹️ ▶️ John that you’re there since you don’t have any engine sound.
⏹️ ▶️ Chris Lattner And I have to say, this is the most effort I’ve ever done to win over one Swift programmer. So
⏹️ ▶️ Chris Lattner I’m not sure if this is a scalable approach.
⏹️ ▶️ Chris Lattner, John that’s a bad strategy for swift adoption. You should
⏹️ ▶️ John seek other means instead of coming on everybody’s podcast and talking to them individually. Oh my God, that’s amazing.