ATP Interview: Holly Borla & Ben Cohen

Episode 61 • Released June 12, 2024 • Speakers detected

Episode 61 artwork
00:00:00 John: All right.
00:00:00 John: How are we starting this?
00:00:01 John: You're starting it.
00:00:02 John: I'm starting it.
00:00:02 John: Okay.
00:00:03 John: You're the host, man.
00:00:04 John: All right.
00:00:04 John: Well, here we go.
00:00:05 John: All right.
00:00:07 John: So, hey, everybody.
00:00:08 John: We're doing something extremely special today, and I am genuinely exceedingly excited about it.
00:00:13 John: And so I teased last episode that we would have a little surprise coming up and a little treat is, I think, what I called it.
00:00:19 John: And it's actually more than a little treat.
00:00:20 John: It's a big treat.
00:00:22 John: So today we have a special guest, but not one special guest.
00:00:26 John: We have two special guests.
00:00:27 John: So here we have today Ben Cohen, who is Senior Software Engineering Manager for the Swift team, and Holly Borla, the Swift Language Engineering Manager.
00:00:36 John: We are in the presence of greatness.
00:00:38 John: And I don't know how we ended up here, but I'm happy about it.
00:00:40 John: So thank you, Ben and Holly, for being here.
00:00:43 John: I know I speak for all three of us in saying we are extremely excited and lucky.
00:00:46 John: So thank you.
00:00:47 NEW_SPEAKER_SPEAKER_01: Thank you very much for having us on.
00:00:48 John: Of course.
00:00:49 NEW_SPEAKER_SPEAKER_01: I do interviewees very often, so...
00:00:51 John: Well, and actually just this morning I was watching your video, which was very good, and we'll talk about that.
00:00:55 John: But I guess, Holly, if you don't mind, if you wouldn't mind starting, would you give me the nickel tour of who you are and what you do?
00:01:01 John: I mean, I know, but not everyone knows.
00:01:03 John: So who are you and what do you do for Apple?
00:01:05 NEW_SPEAKER_SPEAKER_00: Sure, yeah.
00:01:06 NEW_SPEAKER_SPEAKER_00: My name's Holly.
00:01:07 NEW_SPEAKER_SPEAKER_00: I'm the engineering manager of the Swift language team, like you.
00:01:10 NEW_SPEAKER_SPEAKER_00: like you just said.
00:01:12 NEW_SPEAKER_SPEAKER_00: My team focuses a lot on the user-facing language features like the generic system, type inference, and this year our major focus has been the concurrency model and specifically data array safety in Swift 6.
00:01:23 NEW_SPEAKER_SPEAKER_00: Before I joined the Swift team, I was a Swift programmer working on Xcode, and before that I was a computer science student at the University of Michigan.
00:01:30 John: That's incredible.
00:01:31 John: And Ben?
00:01:32 NEW_SPEAKER_SPEAKER_01: Yeah, so my name is Ben Cohen, and I manage the Swift team overall.
00:01:35 NEW_SPEAKER_SPEAKER_01: So that includes the language, but also the backend, the optimizer, a lot of the tooling that goes around the language, like code completion and things like that.
00:01:44 NEW_SPEAKER_SPEAKER_01: At Apple, about eight years, I've worked on various parts of the Swift compiler, including the standard library, the optimizer.
00:01:50 NEW_SPEAKER_SPEAKER_01: And before that, I was not a compiler engineer.
00:01:52 NEW_SPEAKER_SPEAKER_01: So I was actually working in sort of fintech type stuff.
00:01:56 John: So, you know, I'm going to really make John happy, and I'm going to jump right to the end.
00:02:01 John: We're not doing follow-up, then.
00:02:04 John: No, we're not doing follow-up this time.
00:02:06 John: Well, I guess a real-time follow-up.
00:02:07 John: How did you end up, and I'm asking both of you, but Ben, since you most recently spoke, we'll start with you.
00:02:12 John: How do you end up being a compiler engineer?
00:02:14 John: Because my perspective as a Swift developer is there's people like me who kind of know what we're doing, and then there's compiler engineers who really know what they're doing.
00:02:22 John: It's like a priesthood where...
00:02:24 John: You're a programmer and you write the thing, but then if there's something wrong with the compiler, you're like, that's not my fault.
00:02:29 John: There are people in an ivory tower somewhere that make this work, and they're crossing over that path.
00:02:34 John: I know there's lots of advertising for job positions that say, you don't need compiler experience.
00:02:38 John: Just come and be on the team.
00:02:39 John: We'll teach you.
00:02:40 NEW_SPEAKER_SPEAKER_01: Well, that is true.
00:02:40 NEW_SPEAKER_SPEAKER_01: You do not need compiler experience.
00:02:41 NEW_SPEAKER_SPEAKER_01: And in fact, I think actually neither me nor Holly had direct compiler experience before joining the Swift team to work on the language.
00:02:50 NEW_SPEAKER_SPEAKER_01: To have a high tolerance for pain?
00:02:52 NEW_SPEAKER_SPEAKER_01: So...
00:02:53 NEW_SPEAKER_SPEAKER_01: Actually, I came to Swift through paying from other languages.
00:02:57 John: That is such a good answer.
00:02:59 NEW_SPEAKER_SPEAKER_01: That is so good.
00:03:00 NEW_SPEAKER_SPEAKER_01: Are you sure you're not in PR?
00:03:02 NEW_SPEAKER_SPEAKER_01: So my love for Swift comes from the fact that I have experienced what other languages have to offer.
00:03:07 NEW_SPEAKER_SPEAKER_01: And there are, you know, I've always been a language enthusiast.
00:03:10 NEW_SPEAKER_SPEAKER_01: And so whether it's
00:03:13 NEW_SPEAKER_SPEAKER_01: Java or C++ or higher level languages like Ruby or Perl.
00:03:18 NEW_SPEAKER_SPEAKER_01: There's something great about all of these different languages, but I always felt historically like these languages had compromises.
00:03:23 NEW_SPEAKER_SPEAKER_01: They were either a little bit too slow because they were more dynamic and scripting based, or they were unsafe like C++ or really hard to comprehend like C++.
00:03:32 NEW_SPEAKER_SPEAKER_01: It's a true story.
00:03:34 NEW_SPEAKER_SPEAKER_01: And my background is actually I used to work on trading systems, and performance is really important in trading systems.
00:03:41 NEW_SPEAKER_SPEAKER_01: And so we used to do a lot of things in C++, but at the same time, safety is really important in trading systems.
00:03:48 NEW_SPEAKER_SPEAKER_01: You do not want the machine to do the wrong thing.
00:03:51 NEW_SPEAKER_SPEAKER_01: And so we always used to have this trade-off between C++ and Java.
00:03:55 NEW_SPEAKER_SPEAKER_01: And when I saw Swift 10 years ago now, I was actually...
00:04:00 NEW_SPEAKER_SPEAKER_01: blown away by the fact that it actually managed to find the sweet spot between those different things.
00:04:05 NEW_SPEAKER_SPEAKER_01: It was deterministic.
00:04:06 NEW_SPEAKER_SPEAKER_01: It didn't have a garbage collector.
00:04:07 NEW_SPEAKER_SPEAKER_01: But also, it had that higher level feel.
00:04:09 NEW_SPEAKER_SPEAKER_01: It does sometimes look a lot more like sort of the Ruby-like language, where it's really joyful to program in.
00:04:15 NEW_SPEAKER_SPEAKER_01: And it's really great to see that realized in things like Swift UI, where it brings back that joy of programming that I think sometimes we lose a little bit.
00:04:22 NEW_SPEAKER_SPEAKER_01: And so that was what brought me to Swift.
00:04:24 NEW_SPEAKER_SPEAKER_01: And I joined Apple originally.
00:04:25 NEW_SPEAKER_SPEAKER_01: I was actually a library developer.
00:04:28 NEW_SPEAKER_SPEAKER_01: So I didn't have that background in compilers, but I did have that background in writing algorithms and data structures and things like that.
00:04:34 NEW_SPEAKER_SPEAKER_01: And that was a really nice route in.
00:04:35 NEW_SPEAKER_SPEAKER_01: And from that, I learned about compiler performance.
00:04:38 NEW_SPEAKER_SPEAKER_01: And from that, got more into the general language design.
00:04:41 NEW_SPEAKER_SPEAKER_01: And that's how come I ended up here.
00:04:44 John: And then Holly, you said you started working in Xcode, is that right?
00:04:46 John: And then kind of meandered from there.
00:04:48 John: What was that story like?
00:04:49 NEW_SPEAKER_SPEAKER_00: Yeah, that's right.
00:04:50 NEW_SPEAKER_SPEAKER_00: So I actually signed up for a mentorship program that the developer tools organization offered.
00:04:55 NEW_SPEAKER_SPEAKER_00: And they deliberately paired mentees up with mentors from different parts of the organization so that you could get to meet people who you didn't work with on a day-to-day basis.
00:05:06 NEW_SPEAKER_SPEAKER_00: And I got paired up with a Swift compiler engineer.
00:05:08 NEW_SPEAKER_SPEAKER_00: And that sort of sparked my interest in actually joining the team.
00:05:12 NEW_SPEAKER_SPEAKER_00: So for me, I feel like I became a compiler engineer by accident.
00:05:17 NEW_SPEAKER_SPEAKER_00: What brought me to developer tools at Apple is I was really interested in education for programming.
00:05:21 NEW_SPEAKER_SPEAKER_00: I also ended up studying computer science sort of by accident.
00:05:25 NEW_SPEAKER_SPEAKER_00: I didn't go into university knowing anything about programming or computer science like a decade ago today.
00:05:32 NEW_SPEAKER_SPEAKER_00: You know, it's Swift's 10-year anniversary.
00:05:33 NEW_SPEAKER_SPEAKER_00: Ten years ago, I knew nothing about programming.
00:05:35 NEW_SPEAKER_SPEAKER_00: I was graduating high school.
00:05:37 NEW_SPEAKER_SPEAKER_00: Yeah.
00:05:38 NEW_SPEAKER_SPEAKER_00: set to study dance at the University of Michigan, and engineering was sort of my backup, and all engineers have to take a programming class, and I really enjoyed it, and that, I think, for me, really showed the power of making Swift, or not Swift, making programming more approachable to people who weren't exposed to that previously, so I thought
00:06:01 NEW_SPEAKER_SPEAKER_00: Working on developer tools was a good way to do that, and that was how I started to learn Swift when I joined the Xcode team.
00:06:09 NEW_SPEAKER_SPEAKER_00: The part of Xcode that I worked on had just been entirely rewritten in Swift.
00:06:14 NEW_SPEAKER_SPEAKER_00: So yeah, it was this series of opportunities that led me to really becoming interested in working on the Swift language itself, and now this is sort of the ultimate opportunity to make programming more approachable.
00:06:25 NEW_SPEAKER_SPEAKER_00: to people who have an idea and are interested in bringing that to life through code.
00:06:32 John: I love that.
00:06:33 John: And I'll throw Marco under the bus with me, because I can tell you that Marco and I went to school for CS and computer engineering, and I cannot fathom a situation where engineering is like my fallback.
00:06:43 John: Like, oh, I'm sure I'll be fine in engineering if this other stuff doesn't work.
00:06:46 John: That's incredible.
00:06:47 John: I just couldn't dance.
00:06:48 John: Her story is like an after-school special of how you can slippery slope into the seedy world of compiler engineering.
00:06:56 John: She started out as a promising dancer, but somehow the compiler people got her, and now look at her.
00:07:01 John: Now, I'm going to continue to make John upset by continuing to be at the bottom of the document, but I promise, John, I will come back up to the beginning.
00:07:07 John: At least you're in the – I'm about to ask if it's not even in the document.
00:07:09 John: There's that.
00:07:10 John: You're doing great.
00:07:10 John: We have a structure.
00:07:11 John: We're sticking to it.
00:07:12 John: Are we?
00:07:12 John: Well, this is our structure, despite what John says.
00:07:15 John: It's not copyable.
00:07:16 John: John, have you heard the show?
00:07:17 John: Right.
00:07:18 John: So, Ben, you were very rightfully, in my opinion, slagging on C++ just a few minutes ago.
00:07:24 John: Guess what the Swift compiler is mostly right?
00:07:27 John: Well, that's exactly what I was going to say.
00:07:29 John: So, last I remember hearing, the Swift compiler, last I looked, the Swift compiler is largely, if not entirely, C++.
00:07:34 John: So, you're pointing at me like, wait, there's more.
00:07:38 John: So, tell me, is there more?
00:07:39 NEW_SPEAKER_SPEAKER_01: Okay.
00:07:39 NEW_SPEAKER_SPEAKER_01: There is more.
00:07:40 NEW_SPEAKER_SPEAKER_01: So the compiler, I actually don't have the right percentage.
00:07:43 NEW_SPEAKER_SPEAKER_01: It's actually slightly difficult to tell because if you look at the GitHub repo, it gives you lies for two reasons.
00:07:50 NEW_SPEAKER_SPEAKER_01: One is, like, we have a lot of tests written in Swift, and those shouldn't count, right?
00:07:54 NEW_SPEAKER_SPEAKER_01: Right, right, right.
00:07:54 NEW_SPEAKER_SPEAKER_01: But also, we have started the process of writing parts of the compiler in Swift.
00:08:00 NEW_SPEAKER_SPEAKER_01: Okay.
00:08:00 NEW_SPEAKER_SPEAKER_01: And that started quite a while ago now.
00:08:03 NEW_SPEAKER_SPEAKER_01: I think maybe four years ago now.
00:08:05 NEW_SPEAKER_SPEAKER_01: But when we do that, we actually create those bits of the compiler that we rewrite as packages.
00:08:10 NEW_SPEAKER_SPEAKER_01: And when you do that, we break them out into a separate repo.
00:08:12 NEW_SPEAKER_SPEAKER_01: So if you go to github.com slash Apple for now, soon, Swift Lang, slash Swift dash driver, that was the first part of the Swift compiler that we started rewriting in Swift.
00:08:24 NEW_SPEAKER_SPEAKER_01: That happened about four years ago.
00:08:27 NEW_SPEAKER_SPEAKER_01: And the driver is basically the way into the front end of the compiler.
00:08:31 NEW_SPEAKER_SPEAKER_01: So it's the thing that does the initial processing of your command lines, and it organizes the build and things like that.
00:08:37 NEW_SPEAKER_SPEAKER_01: That was written in Swift.
00:08:39 NEW_SPEAKER_SPEAKER_01: Two years ago now, we started rewriting the parser in Swift.
00:08:42 NEW_SPEAKER_SPEAKER_01: And so that is actually part of a wider project called Swift Syntax, which is itself written in Swift, which is originally a way of just manipulating Swift code.
00:08:50 NEW_SPEAKER_SPEAKER_01: It was a library for manipulating Swift code.
00:08:53 NEW_SPEAKER_SPEAKER_01: And that evolved into a replacement for our current C++ parser.
00:08:56 NEW_SPEAKER_SPEAKER_01: That is actually a foundation for macros.
00:08:58 NEW_SPEAKER_SPEAKER_01: So last year, when we introduced macros, those are based around Swift Syntax and the Swift parser.
00:09:02 NEW_SPEAKER_SPEAKER_01: We have some ongoing work that's happening at the moment to do the next layer down, which is
00:09:08 NEW_SPEAKER_SPEAKER_01: what's called AST generation.
00:09:11 NEW_SPEAKER_SPEAKER_01: So what you do is you parse the code and then you turn it into an abstract syntax tree.
00:09:15 NEW_SPEAKER_SPEAKER_01: And then you have to lower that down into the underlying representation.
00:09:18 NEW_SPEAKER_SPEAKER_01: That is ongoing at the moment.
00:09:21 NEW_SPEAKER_SPEAKER_01: And once we've done the AST gen layer, we will actually be throwing away the C++ parser.
00:09:26 NEW_SPEAKER_SPEAKER_01: Now, that's going to be an interesting moment because that is the point at which there is no way back.
00:09:32 NEW_SPEAKER_SPEAKER_01: That is the point at which you will need a Swift compiler to build Swift.
00:09:35 NEW_SPEAKER_SPEAKER_01: MARK MIRCHANDANIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
00:10:02 NEW_SPEAKER_SPEAKER_01: So we're very familiar with that.
00:10:05 NEW_SPEAKER_SPEAKER_01: But yeah, and then more recently than that, we have started writing optimizer passes in Swift.
00:10:12 NEW_SPEAKER_SPEAKER_01: So that is actually using C++ interop, which is another important feature of Swift.
00:10:17 NEW_SPEAKER_SPEAKER_01: We obviously interoperate with LLVM, which is written in C++.
00:10:21 NEW_SPEAKER_SPEAKER_01: And we use that to build our optimizer passes to do things like hoist variables out of loops and things like that.
00:10:28 NEW_SPEAKER_SPEAKER_01: And those are now written in Swift as well.
00:10:29 NEW_SPEAKER_SPEAKER_01: So we are getting there.
00:10:30 NEW_SPEAKER_SPEAKER_01: It'll be a ways away.
00:10:33 NEW_SPEAKER_SPEAKER_01: It's not our main goal.
00:10:35 NEW_SPEAKER_SPEAKER_01: We don't rewrite things for the sake of it, even though it's written in C++.
00:10:39 NEW_SPEAKER_SPEAKER_01: It's working.
00:10:40 NEW_SPEAKER_SPEAKER_01: And so really, when we decide we want to do something where we want to rewrite a part of the compiler, we try to make it for a good reason.
00:10:47 NEW_SPEAKER_SPEAKER_01: And those good reasons can be, for example, creating a macro system with a nice, friendly Swift API.
00:10:53 NEW_SPEAKER_SPEAKER_01: Or when we rewrite the optimizer passes, we usually do it in order to simplify them and make them more effective.
00:11:01 NEW_SPEAKER_SPEAKER_01: Yeah, so we are on that path to self-hosting.
00:11:05 NEW_SPEAKER_SPEAKER_01: But it's going to feel really good when you get to delete that code, though.
00:11:08 NEW_SPEAKER_SPEAKER_01: It feels very good to delete code.
00:11:10 John: So, Bill, I'm not sure which one of you is more appropriate to answer the following, but building on that, it certainly seems the implication is there is a strong interest to become self-hosted.
00:11:18 John: And I'm not sure I'm the best person to summarize that, but basically the Swift compiler is written in Swift, right?
00:11:24 John: And is it fair to say
00:11:26 John: the eventual, I'm not looking for a date, but the eventual one sometime goal would be to self-host entirely if possible.
00:11:32 John: Is that fair to say?
00:11:34 NEW_SPEAKER_SPEAKER_01: We don't comment on future products.
00:11:36 NEW_SPEAKER_SPEAKER_01: Well, this is not a product.
00:11:37 NEW_SPEAKER_SPEAKER_01: This is the Swift language that is entirely open source and that we are perfectly at liberty to comment on.
00:11:43 NEW_SPEAKER_SPEAKER_01: So, yes, I think the ultimate goal is that the compiler should be written in Swift.
00:11:47 NEW_SPEAKER_SPEAKER_01: If nothing else, it does improve the safety of the compiler.
00:11:51 NEW_SPEAKER_SPEAKER_01: The compiler...
00:11:52 NEW_SPEAKER_SPEAKER_01: is not filled with segfaults, but they can happen.
00:11:59 NEW_SPEAKER_SPEAKER_01: And obviously rewriting parts of it in Swift eliminates that possibility because it's a safer language.
00:12:04 NEW_SPEAKER_SPEAKER_01: And so that's one benefit that comes from it as well as bringing other features.
00:12:08 NEW_SPEAKER_SPEAKER_01: The other benefit is it makes it more approachable for outside people.
00:12:11 NEW_SPEAKER_SPEAKER_01: I mean, you were talking about working on the Swift compiler as if it's a very intimidating thing, but at the end of the day, it's...
00:12:16 NEW_SPEAKER_SPEAKER_01: It's actually kind of pretty straightforward code when you look at a small part of it, right?
00:12:21 NEW_SPEAKER_SPEAKER_01: When you look at a particular optimization pass, you can usually see pretty much what it's doing.
00:12:25 NEW_SPEAKER_SPEAKER_01: And it's actually a great opportunity to get contributors involved.
00:12:28 NEW_SPEAKER_SPEAKER_01: I know Holly's worked with quite a lot of people who've come new to the Swift programming language as well.
00:12:33 NEW_SPEAKER_SPEAKER_00: Yeah, we also organize a mentorship program called the Swift Mentorship Program, where open source contributors who are interested in contributing to various parts of the Swift project, including but not limited to the compiler, they sign up, they get paired with someone who regularly contributes to the compiler, and they work together for 10 weeks on open source contributions.
00:12:53 NEW_SPEAKER_SPEAKER_00: And I find that a lot of people who write Swift, who are iOS developers, are really interested in making
00:12:59 NEW_SPEAKER_SPEAKER_00: some contributions to the compiler just as a learning experience or better understanding how their code works.
00:13:06 NEW_SPEAKER_SPEAKER_00: If you're in the depths of how type inference or the actor isolation checker works, it gives you a little more knowledge into how the compiler sees your code when you're writing Swift code.
00:13:18 NEW_SPEAKER_SPEAKER_00: So yeah, it's a cool program and a really good learning experience for people who are writing Swift.
00:13:23 NEW_SPEAKER_SPEAKER_00: And I completely agree that moving more of the compiler over to Swift will make contributing to the compiler a lot more approachable for people.
00:13:30 John: Does that include the standard library?
00:13:32 John: Like if someone wants to add a method that says first, second, third, spelled out, fourth, fifth, sixth, and you stop them when they get to 30 seconds.
00:13:39 John: Like that's all Swift code in the standard library.
00:13:40 John: So you can contribute to that and say, hey, I contributed to the Swift language, but you're just making Swift methods in the library.
00:13:45 John: So I'm curious, and probably for Holly, as we go into this new era of Swift concurrency and data race safety and everything, Swift, I think, has always struck an interesting balance.
00:13:58 John: I think it's kind of a roller coaster.
00:14:00 John: Sometimes it's more successful than other times at this balance of –
00:14:04 John: being easy to use for non-experts or newbies to a language or just new programmers, and also having all this power behind it and having quite a bit of complexity behind it.
00:14:17 John: And as we go into this new data race safety era,
00:14:22 John: How do you strike that balance?
00:14:24 John: Obviously, these are some very advanced concepts, and somebody might get some warning as they're building their code saying something's not sendable because it has mutable state, and they might not even know what any of that means.
00:14:35 John: How do you balance that with being approachable to new programmers or to less experienced programmers?
00:14:40 NEW_SPEAKER_SPEAKER_00: Yeah, so...
00:14:41 NEW_SPEAKER_SPEAKER_00: The goal for concurrency is really similar to what we've accomplished with other advanced features of the language, like the generic system is the one that I always go to because from the very first lines of code that you write in Swift, you're using the generic system because you're using standard library types like array.
00:14:58 NEW_SPEAKER_SPEAKER_00: Or you're using frameworks like SwiftUI, which are really heavily leveraging these advanced features to make APIs that are really natural to use for programmers.
00:15:08 NEW_SPEAKER_SPEAKER_00: But you don't need to understand generics.
00:15:09 NEW_SPEAKER_SPEAKER_00: You don't need to understand how it works until you're at a point where you need to use those advanced features in your own code.
00:15:15 NEW_SPEAKER_SPEAKER_00: And that's the end goal with concurrency as well.
00:15:19 NEW_SPEAKER_SPEAKER_00: For newcomers to app development or newcomers to Swift, when you're writing code, by default, that code should be on the main actor.
00:15:26 NEW_SPEAKER_SPEAKER_00: And you shouldn't have to actively think about the fact that that code is on the main actor until you're trying to actively introduce concurrency into your project.
00:15:36 NEW_SPEAKER_SPEAKER_00: And at that point, you'll be confronted when you make a mistake that can lead to a data race in your code.
00:15:42 NEW_SPEAKER_SPEAKER_00: And I think
00:15:43 NEW_SPEAKER_SPEAKER_00: that both the progressive disclosures is the way to make that complexity more approachable, but I also think introducing those checks at compile time will also make learning to write concurrent code a lot more approachable for people who are new to concurrency in general.
00:16:01 NEW_SPEAKER_SPEAKER_00: And this is a continued evolution of making concurrent programming more approachable,
00:16:05 NEW_SPEAKER_SPEAKER_00: Like concurrent programming is just notoriously really hard to get right.
00:16:09 NEW_SPEAKER_SPEAKER_00: I don't know if you've ever debugged a data race before, for those of you who are listening, but if you have, you know that it can take days or even weeks.
00:16:17 NEW_SPEAKER_SPEAKER_00: And the introduction of dispatch even was a huge step forward for making concurrent code easier to write.
00:16:24 NEW_SPEAKER_SPEAKER_00: Working with dispatch queues is way easier than managing low-level system resources like threads manually in your app.
00:16:31 NEW_SPEAKER_SPEAKER_00: But you still have to know when to apply those tools to protect mutable state in your code.
00:16:36 NEW_SPEAKER_SPEAKER_00: And with data race safety in Swift 6, you can't get it wrong.
00:16:41 NEW_SPEAKER_SPEAKER_00: The compiler will tell you if there's a risk of a data race in your code.
00:16:45 NEW_SPEAKER_SPEAKER_00: And having to confront those concepts at the point when you make a mistake is better for...
00:16:54 NEW_SPEAKER_SPEAKER_00: forming a mental model of how concurrent code should be written in your project.
00:16:58 NEW_SPEAKER_SPEAKER_00: So I'm really excited for people to start to learn concurrency for the first time with data ray safety in Swift 6, as opposed to, I think a lot of people right now have internalized how to use dispatch, and they've been using that for many years, and now they're trying to learn this other, like...
00:17:13 NEW_SPEAKER_SPEAKER_00: It's not a completely different system in how you write code, but it is different in how you approach it and at what point you're confronted with the issues.
00:17:21 NEW_SPEAKER_SPEAKER_00: And I think that might be a little bit more difficult than learning concurrency for the first time with the compiler checks in place to help prevent you from making mistakes.
00:17:28 John: Is that how you characterize the difference between the Swift concurrency and the predecessor concurrency systems at Apple?
00:17:33 John: Like we've had...
00:17:35 John: Grand Seltzer Dispatch, the Dispatch Queues, NS Operation Queue, P-threads back in the day, locks of various kinds over the years.
00:17:43 John: And all of those were kind of, you'd have sessions on, and they'd say, here's how you properly use this.
00:17:48 John: Here's how many queues you should have, and stuff like that.
00:17:50 John: But it was all sort of like runtime stuff.
00:17:52 John: And everything I hear about Swift concurrency is always,
00:17:54 John: we will do these checks for you at compile time so that you don't have to run your thing to see if there is a problem or audit the code and look over it.
00:18:02 John: This is like the compiler will check it for you and make sure it's mostly OK.
00:18:07 John: Would you say that's the big difference?
00:18:08 NEW_SPEAKER_SPEAKER_00: Yeah, absolutely.
00:18:08 NEW_SPEAKER_SPEAKER_00: You should be able to program by bumper where the compiler is there to tell you, oh, no, you got this a little bit wrong with actionable suggestions for how to fix that code.
00:18:18 John: So you're talking about the progressive disclosure and you don't have to know about this until you start introducing concurrency.
00:18:24 John: That's true of the Swift language, if you're writing just Swift code.
00:18:26 John: But everyone else in this company makes a bunch of frameworks.
00:18:30 John: And those don't know or care about Swift concurrency for the most part.
00:18:34 John: And they're in your code.
00:18:35 John: And you think, I haven't introduced any concurrency.
00:18:38 John: But it's like, well, this method has a callback.
00:18:41 John: And it is cranky now.
00:18:43 John: And you're like, but why?
00:18:44 John: I didn't make that API.
00:18:46 John: It's complaining about something that I don't understand.
00:18:48 John: It's not an API that I wrote.
00:18:50 John: And so you're faced with this dilemma of just
00:18:52 John: You stare at it for a while, it's like, should I not use that API?
00:18:56 John: I think we've all had experience, and everyone you've probably talked to has had experience trying to enable strict concurrency in 5.10.
00:19:04 John: And you set the setting in Xcode, you see all the warnings, and you're like,
00:19:08 John: How far away am I really?
00:19:09 John: You're like, how many, you know, and I think we've all taken different swings at this, like, and I've seen you both sort of counter the conventional wisdom.
00:19:15 John: It's like, I'll just make everything sendable and that will fix everything, but that doesn't work.
00:19:18 John: And so you're like, well, maybe I can just add annotations.
00:19:20 John: I'll put main actor on a bunch of things, but that doesn't work.
00:19:22 John: And it's like, well, maybe I'll just sprinkle a Zoom isolated everywhere.
00:19:24 John: And it's like, well, that's probably not the right approach.
00:19:26 John: And I think my personal experience is I've taken like four different runs at bringing one of my apps on just stricken currency.
00:19:33 John: And I just keep backing off and scratching my, I know there's a WWC session about it and I haven't seen it, my bad.
00:19:37 John: It was a busy day.
00:19:38 John: And it's migrating to Swift concurrence.
00:19:40 John: But I feel like that is a lot of the barrier.
00:19:41 John: And it's nothing to do with the language.
00:19:43 John: It has to do with the APIs that we're using that were created decades ago that have their own conventions.
00:19:48 John: And stricken currency.
00:19:49 John: And it's not wrong.
00:19:50 John: It's correct.
00:19:50 John: There is a potential for a mutable state to be messed up there.
00:19:53 John: And then, of course, even in our own code, it's like, well, I use queues for this.
00:19:56 John: And I use locks.
00:19:57 John: And I'm pretty sure it's safe.
00:19:59 John: But stricken currency is safe.
00:19:59 John: Well, that's what unchecked sendable is for.
00:20:02 John: Yeah, but that's the whole thing.
00:20:03 John: Like you don't want to go through and sprinkle it through.
00:20:05 John: It says, I'm sure this is OK.
00:20:06 John: I'm sure this is OK.
00:20:07 John: Like there are annotations to do that.
00:20:09 John: But all you're doing is undercutting yourself by saying, no, I'm totally sure the code I wrote last year is bug free and there is no races.
00:20:15 John: And it will satisfy the compiler.
00:20:16 John: But you haven't actually solved the problem.
00:20:18 John: You haven't actually used the system you're saying, which is you should be able to write it.
00:20:21 John: The compiler tells you whether it's wrong.
00:20:22 John: You might as well just turn that mode off.
00:20:25 John: So, I mean, I think a lot of users find it frustrating, but it is a difficult problem.
00:20:28 John: And I'm assuming, well, you tell me what you think the correct approach is.
00:20:32 John: Give me the three-second summary of the session that I didn't watch.
00:20:35 NEW_SPEAKER_SPEAKER_00: I'll let Ben do that in a spend session.
00:20:38 NEW_SPEAKER_SPEAKER_01: It is, and well done for Casey for getting ahead of John and watching it already.
00:20:42 NEW_SPEAKER_SPEAKER_01: So...
00:20:44 NEW_SPEAKER_SPEAKER_01: It really partly depends on what kind of frameworks you're using, and it's possible that you're using some frameworks that make it harder or easier, depending on what kind of code you're using.
00:20:55 John: Mac frameworks.
00:20:56 NEW_SPEAKER_SPEAKER_01: Right.
00:20:56 NEW_SPEAKER_SPEAKER_01: Oh, you're screwed.
00:20:58 NEW_SPEAKER_SPEAKER_01: So, for example, the UI layer, we've actually, and it's worth tying the new SDK because...
00:21:05 NEW_SPEAKER_SPEAKER_01: At the UI layer, there's been a lot of work to indicate which parts of SwiftUI, also UIKit and AppKit, are by definition always supposed to be running on the main thread.
00:21:15 NEW_SPEAKER_SPEAKER_01: And that should actually, for people who've tried 5.10, it's well worth downloading the new SDK and giving that a go.
00:21:21 John: Does that also include, like, I know this is a documentation issue, but often you'll see a thing with a callback and you have a question, it's like,
00:21:27 John: What thread will the callback run on?
00:21:29 John: And you're just like, oh, you're just supposed to know whatever thread you register it on, that's the thread the callback will run on, but you don't see that in a documentation.
00:21:35 John: So you're like, well, I registered for this on the main thread.
00:21:38 John: And when the callback gets called, it will probably get called on the main thread.
00:21:41 John: And sometimes they take a queue as an argument, and you just have to know that the main queue is the same as the main thread.
00:21:45 John: But documentation-wise, I always feel like I look up one of these old AppKit things, and it's guesswork.
00:21:51 John: Well, but did you know, John, I learned this morning that there's a keyword, what is it?
00:21:55 John: It's assume main thread?
00:21:57 John: Yeah, assume isolated.
00:21:58 NEW_SPEAKER_SPEAKER_01: There it is.
00:21:59 John: I knew I couldn't quite get there.
00:22:01 John: But there's tools for this, John, as it turns out.
00:22:04 NEW_SPEAKER_SPEAKER_00: I know about assume isolated.
00:22:05 John: That's not the tool for that.
00:22:06 John: You're nuts.
00:22:06 John: Don't do that.
00:22:07 John: Assume isolated, all it's going to do is throw a runtime error when it finds out it's not on the main thread.
00:22:12 NEW_SPEAKER_SPEAKER_01: Yeah, don't do that.
00:22:13 NEW_SPEAKER_SPEAKER_01: Just dispatch it to me.
00:22:15 NEW_SPEAKER_SPEAKER_01: So assume isolated does throw a runtime error when you're not on the main thread.
00:22:20 NEW_SPEAKER_SPEAKER_01: This is actually something that a lot of good programmers are already doing, which is they put in preconditions where they know this is supposed to be on the main thread.
00:22:28 NEW_SPEAKER_SPEAKER_01: And they put in a precondition just in case they call it from somewhere else in their app where they're getting a call from a dispatch queue that's not isolated to the main thread.
00:22:37 NEW_SPEAKER_SPEAKER_01: And that can lead to trouble.
00:22:38 NEW_SPEAKER_SPEAKER_01: I think somebody was saying earlier
00:22:41 NEW_SPEAKER_SPEAKER_01: you run your program and you find out it doesn't quite work, as opposed to at compile time, you find out that you need to do something.
00:22:47 John: Yeah, it feels like it's undercutting.
00:22:48 John: The bumper thing Holly was saying is like, I don't want to find out at runtime.
00:22:51 John: Every time I do assume I isolate it, I'm like, there must be a better way.
00:22:54 John: Don't use that there, man.
00:22:55 John: That's not what it's for.
00:22:57 NEW_SPEAKER_SPEAKER_01: So I would say that finding out at runtime that your code is broken is the best case scenario under the old world, which is that you hope to find out when you run your code that something is wrong.
00:23:09 NEW_SPEAKER_SPEAKER_01: But what actually happens is that in some of these techniques,
00:23:15 NEW_SPEAKER_SPEAKER_01: you find out in the wild when your program is crashing and you do not exactly know why.
00:23:20 NEW_SPEAKER_SPEAKER_01: I'm always amused by people who make these jokes on Mastodon or Twitter where they say like, they make a joke about concurrency where they jumble up the words.
00:23:29 NEW_SPEAKER_SPEAKER_01: And that's cute.
00:23:30 NEW_SPEAKER_SPEAKER_01: But that is, again, the best case scenario is jumbled up words.
00:23:33 NEW_SPEAKER_SPEAKER_01: That's very benign.
00:23:34 NEW_SPEAKER_SPEAKER_01: What's worse is like, you know, you crash, you corrupt user data.
00:23:37 NEW_SPEAKER_SPEAKER_01: This is no good.
00:23:39 NEW_SPEAKER_SPEAKER_01: And so that's why a lot of people have these really great practices in the old world of dispatch.
00:23:43 NEW_SPEAKER_SPEAKER_01: where they will insert these assertions saying, I want you to stop me if I'm not running on the main queue.
00:23:51 NEW_SPEAKER_SPEAKER_01: So I think the long-term goal is that we need to lift this information out of documentation.
00:23:59 NEW_SPEAKER_SPEAKER_01: We want to take it out of documentation and put it actually in the definition of the API.
00:24:04 NEW_SPEAKER_SPEAKER_01: It's not in the documentation now, so you don't have to lift it out.
00:24:06 NEW_SPEAKER_SPEAKER_01: So the benefit of putting it there so that the compiler actually enforces it is that you can't not have that information.
00:24:18 NEW_SPEAKER_SPEAKER_01: By definition, your code does encapsulate the information about where you are running and how it's running.
00:24:23 John: Yeah, because one of the things I do when flailing is like there's a callback and I'm like, can I just annotate the callback as main actor?
00:24:29 John: And the answer is no.
00:24:30 John: And then it's like, why?
00:24:33 John: Is it already on, always on the main thread?
00:24:35 John: I figure what the error is, I'm sure.
00:24:37 John: Just wait for the framework to be updated with async calls.
00:24:39 John: Yeah, well, you don't have all the time in the world to wait.
00:24:43 John: What it comes down to, like you mentioned queues, right?
00:24:44 John: So one of my apps has concurrency.
00:24:47 John: I'm sorry it does.
00:24:48 John: And I use queues.
00:24:51 John: And in one situation, I wrote a little class and I use locks, old style locks.
00:24:54 John: And
00:24:55 John: Pretty sure it's probably okay.
00:24:58 John: But I look at that and I'm like, I would like to use Swift concurrency because then I would feel more sure.
00:25:02 John: But there's nothing you can do to sort of annotate or mark up dispatch cues or locks other than the reassurance of just telling the compiler, I'm pretty sure that I'm right.
00:25:10 John: I would rather just like pull that out and re-implement it with actors and so on.
00:25:16 John: And that sometimes just seems daunting.
00:25:18 NEW_SPEAKER_SPEAKER_00: So another thing that there's a ton of Swift code out there and Swift code that interoperates with C based languages like Objective-C and C++.
00:25:27 NEW_SPEAKER_SPEAKER_00: We're at the start of this transition to start to integrate Swift's native safer concurrency primitives into these like vast languages.
00:25:36 NEW_SPEAKER_SPEAKER_00: code bases that are using older library-based concurrency primitives like dispatch queues.
00:25:42 NEW_SPEAKER_SPEAKER_00: The system is designed for incremental migration.
00:25:44 NEW_SPEAKER_SPEAKER_00: So in the case, if you have a class backed by a dispatch queue, there is a technique that you can use to turn that class into an actor that's backed by a dispatch queue.
00:25:55 NEW_SPEAKER_SPEAKER_00: It uses a fancy feature called custom actor executors, but the way to do it, it's only like four or five lines of code that you actually have to write in your own code.
00:26:02 NEW_SPEAKER_SPEAKER_00: And what that lets you do is from your Swift code, it lets you use the static actor isolation and not have to mess with the dispatch queue.
00:26:10 NEW_SPEAKER_SPEAKER_00: But when you're interacting with APIs that are based on dispatch queues, you can still pass the dispatch queue there.
00:26:16 NEW_SPEAKER_SPEAKER_00: And then you can bridge between the dynamic isolation in the static world with tools like Assume Isolated.
00:26:22 John: That brings up another question of incremental adoption.
00:26:25 John: I know, so this Swift 6 just came out, and in the old 5 world, we had the little setting to set it on complete concurrency or whatever.
00:26:32 John: I know there's a whole bunch of features in Swift 6 and new things for setting ability and everything that make it easier.
00:26:37 John: But what is the mechanism in your project of saying, like, I want, you know, is it per module?
00:26:44 John: Is it per file to saying, I want the Swift 6 language features, but this file is not ready for strict concurrency?
00:26:48 John: What does that look like?
00:26:49 NEW_SPEAKER_SPEAKER_00: So the setting is per module.
00:26:52 NEW_SPEAKER_SPEAKER_00: So in your Xcode build settings, there's a language version setting, or if you're in a Swift package manifest, there's an API for setting it per target.
00:26:59 NEW_SPEAKER_SPEAKER_00: And many people currently have that set to something, whether it's for 4.2 or 5.
00:27:04 NEW_SPEAKER_SPEAKER_00: So you would change that to 6 for the specific module that you're looking to migrate to Swift 6.
00:27:11 NEW_SPEAKER_SPEAKER_00: And then if you have a particular file that...
00:27:14 NEW_SPEAKER_SPEAKER_00: violate some of the rules in ways that are really difficult for you to change, there are ways to opt out of checking in specific areas in your project using things like pre-concurrency import statements.
00:27:26 NEW_SPEAKER_SPEAKER_00: If the issue is in an API that you're using, or tools like non-isolated unsafe, if you have, for example, like a global variable that you're manually guarding with a lock or a queue, at the point when you access it, you can use non-isolated unsafe to opt out of the compilers checking there.
00:27:42 NEW_SPEAKER_SPEAKER_00: So there are a variety of tools like that to let you opt out of the checking in narrow situations in your code.
00:27:47 NEW_SPEAKER_SPEAKER_00: And then those are also things like handles that you can audit for later to actually take a look at the opt-outs that you're using in your code and try to use those as refactoring opportunities to rewrite some of that code to use something safer.
00:28:02 John: So you're picking the Swift 6 as the language, and that includes everything having to do with Swift 6.
00:28:07 John: No.
00:28:07 NEW_SPEAKER_SPEAKER_01: So Swift 6, the language mode where you go into the Xcode settings and you say language mode of Swift 6, that purely governs the strict concurrency checking.
00:28:18 NEW_SPEAKER_SPEAKER_01: So the Swift 6 compiler that you get with the latest Xcode, that has all of the new features.
00:28:23 NEW_SPEAKER_SPEAKER_01: So I think you made a glancing blow to non-copyable types.
00:28:27 NEW_SPEAKER_SPEAKER_01: Those features are available.
00:28:29 NEW_SPEAKER_SPEAKER_01: New generic capabilities for non-copyable types are available in the Swift 6 compiler.
00:28:33 NEW_SPEAKER_SPEAKER_01: You do not need to
00:28:33 John: So you would pick the Swift 5 language mode, but it's using the Swift 6 compiler to run in Swift 5 language mode.
00:28:39 John: You get non-copyable types.
00:28:40 John: You don't get the stricken currency.
00:28:41 NEW_SPEAKER_SPEAKER_01: That's right.
00:28:42 NEW_SPEAKER_SPEAKER_01: And that's exactly, this is part of a journey that the entire Swift ecosystem needs to go through.
00:28:47 NEW_SPEAKER_SPEAKER_01: So being ready for Swift 6, having your dependencies ready for Swift 6, there's actually at swiftpackageindex.com, which is this great website, they have a tracker.
00:28:57 NEW_SPEAKER_SPEAKER_01: now that tells you which packages they are compiling that build cleanly under Swift 6 code.
00:29:02 NEW_SPEAKER_SPEAKER_01: But it really does depend on the nature of your program and whether your dependencies are now ready for Swift 6, whether you want to turn on that language mode.
00:29:09 NEW_SPEAKER_SPEAKER_01: And this dates back to we've been doing this now since the Swift 4 days.
00:29:14 NEW_SPEAKER_SPEAKER_01: So since we introduced the Swift 4 language mode, we've always had this source compatibility guarantee promise that whenever you download the new compiler,
00:29:25 NEW_SPEAKER_SPEAKER_01: With a couple of exceptions, where maybe there are a couple of issues with your code where maybe the code was explicitly incorrect, we always want you to be able to compile your code as is with the latest compiler.
00:29:38 NEW_SPEAKER_SPEAKER_01: And then when you're ready for some breaking change, there were a few in Swift 5, and obviously in Swift 6, the key change here is strict concurrency, you're then able to turn it on on a per target basis.
00:29:50 John: MARK MANDELSKI- Is that like a ?
00:29:51 John: a longstanding kind of marketing decision to tie them to the, I mean, just deciding that Swift 6 means stricken currency.
00:29:57 John: You could have, for example, said Swift 6 just means Swift 6 language features and there's some other option for stricken currency.
00:30:02 John: But you said, no, we're tying this feature to this number because people want the higher number.
00:30:07 John: Is that like a sort of a...
00:30:09 John: social engineering decision?
00:30:11 NEW_SPEAKER_SPEAKER_01: It's a way of thinking about the forward progress.
00:30:13 NEW_SPEAKER_SPEAKER_01: I mean, you don't want to be stuck in this world with the Python 2 for 2 to 3 transition style thing, where those were tied to updating your compiler, and then you couldn't get the new stuff without changing your code to adapt to the way that the new language works.
00:30:28 NEW_SPEAKER_SPEAKER_01: So it's this way of helping engineer
00:30:31 NEW_SPEAKER_SPEAKER_01: the ecosystem to help have this continuous forward progress.
00:30:34 NEW_SPEAKER_SPEAKER_01: But at the end of the day, people also, you know, some people have written code in such a way that it won't be so easily adapted to Swift concurrency.
00:30:42 NEW_SPEAKER_SPEAKER_01: Some people have written code using a lot of new frameworks and a lot of async await, and the path for them is actually pretty clean.
00:30:49 NEW_SPEAKER_SPEAKER_01: And so we want people to be able to opt into that.
00:30:52 NEW_SPEAKER_SPEAKER_01: The choice as to whether you opt in or not is up to you.
00:30:55 NEW_SPEAKER_SPEAKER_01: If you're finding that you are experiencing quite a lot of pretty gnarly crashes,
00:30:59 NEW_SPEAKER_SPEAKER_01: It's probably worth considering opting in.
00:31:01 NEW_SPEAKER_SPEAKER_01: One great time to opt in is if actually you want to start introducing a lot more parallelism to your code, right?
00:31:08 NEW_SPEAKER_SPEAKER_01: So we have these powerful new devices.
00:31:10 NEW_SPEAKER_SPEAKER_01: They have many cores.
00:31:11 NEW_SPEAKER_SPEAKER_01: You might find yourself with an app that previously was doing most of its work on the main thread with a little bit of background processing, but you really want to take advantage of a lot more parallelism in your code.
00:31:21 NEW_SPEAKER_SPEAKER_01: That would be a great time to turn on Swift 6 mode in order to...
00:31:24 NEW_SPEAKER_SPEAKER_01: know that you can do those refactorings without fear of introducing new data races.
00:31:31 NEW_SPEAKER_SPEAKER_01: So yeah, it's really up to each individual project to make that decision and to see how the community is moving forward with them in order to update their dependencies and then take the plunge.
00:31:41 John: Do you worry about like releasing Swift version 10 many years from now and huge code bases are still in Swift 5 language mode?
00:31:49 John: Like they're using a Swift 10 compiler to run Swift 5 language mode because they could never get the wherewithal to go stricken currency compliant.
00:31:56 John: And you're just plowing bravely forward here at Apple for making version after version and they're all great, but they can never cross to the sixth threshold because they can never get their code
00:32:03 John: to run under stricken currency is millions of lines of like dispatch queue and manually created locks.
00:32:08 John: Like, do you worry about hindering your parks?
00:32:10 John: You've basically made a hard gate of like, you're not going to be running a Swiss 7 next year or whenever if you can't go stricken currency.
00:32:17 John: And you're like, well, my reason I can't go is because we have 10 million lines of, you know, manually managed locks or something.
00:32:23 NEW_SPEAKER_SPEAKER_01: So it really only governs a handful of things.
00:32:26 NEW_SPEAKER_SPEAKER_01: So the goal is always, whenever we introduce a new language feature, that you do not have to update to the new language mode.
00:32:31 NEW_SPEAKER_SPEAKER_01: We were looking at somebody's project yesterday where they were still on Swift 4 mode, and really there was not that much they were missing out on.
00:32:39 NEW_SPEAKER_SPEAKER_01: So we have this long-term promise to always support those language features so that people aren't forced to update.
00:32:48 NEW_SPEAKER_SPEAKER_01: But like I say, most of the language features themselves are not gated on the language version.
00:32:53 NEW_SPEAKER_SPEAKER_01: And so really, it's only when we need to take these big step forwards that we encourage people to upgrade.
00:33:01 John: They'd be running in Swift 5 language mode, but they'd still have access to all the new Swift 10 features, but they would feel bad about themselves.
00:33:06 John: They're not.
00:33:07 John: Because their number is five.
00:33:08 John: And you're rolling out seven and eight and nine and 10.
00:33:11 John: And people, they look at the little gamified badge on the Swift package index.
00:33:13 John: And like, you don't have the little things that Swift 10 compliant.
00:33:15 John: And I have a little star next to my package.
00:33:17 John: And you don't.
00:33:18 John: It's like, I get the language features.
00:33:19 John: It's just not compliant.
00:33:21 NEW_SPEAKER_SPEAKER_00: I also think there's a misconception that you need to totally eliminate all of the uses of tools like locks and dispatch queues in order to migrate to Swift 6.
00:33:29 NEW_SPEAKER_SPEAKER_00: I don't think that's true.
00:33:30 NEW_SPEAKER_SPEAKER_00: I think locks, I mean, the Swift 6 standard library includes a new...
00:33:36 NEW_SPEAKER_SPEAKER_00: primitive mutual exclusion lock called mutex.
00:33:39 NEW_SPEAKER_SPEAKER_00: And that is a tool that people can and should use in some scenarios in their code.
00:33:43 NEW_SPEAKER_SPEAKER_00: And I know there are a variety of other lock types out there that people are currently using.
00:33:46 NEW_SPEAKER_SPEAKER_00: You don't need to stop using those types in order to migrate your code base to
00:33:52 NEW_SPEAKER_SPEAKER_00: the Swift 6 language mode.
00:33:53 NEW_SPEAKER_SPEAKER_00: The same thing is true of dispatch queues.
00:33:55 NEW_SPEAKER_SPEAKER_00: And like I said, part of the reason why the system is built on incremental migration is because we know there's so much concurrent code out there that is using dispatch and other concurrency primitives.
00:34:07 NEW_SPEAKER_SPEAKER_00: And if you had to eliminate or just totally refactor all of your code in order to migrate to Swift 6, nobody would ever do it.
00:34:14 NEW_SPEAKER_SPEAKER_00: So I don't think you need to actually massively refactor your code in order to migrate to Swift 6.
00:34:20 NEW_SPEAKER_SPEAKER_00: Though in some cases, like in Ben's talk, you'll see the talk that he gave back in 2021, he actually took a sample app.
00:34:27 NEW_SPEAKER_SPEAKER_00: And it was using dispatch.
00:34:29 NEW_SPEAKER_SPEAKER_00: And he went through and replaced some uses of dispatch cues with actors.
00:34:33 NEW_SPEAKER_SPEAKER_00: And that might make the migration a little bit easier in some cases.
00:34:38 NEW_SPEAKER_SPEAKER_00: But you'll sort of see when you watch the talk.
00:34:42 NEW_SPEAKER_SPEAKER_00: some of the things that are made easier by introducing actors in some places, but it is still possible to do it if you're using other things like dispatch queues.
00:34:48 NEW_SPEAKER_SPEAKER_01: I have seen that talk.
00:34:50 NEW_SPEAKER_SPEAKER_01: One of the challenges there is that doing that refactoring prior actually made it a lot easier to migrate to Swift 6, and that's actually something that we'd encourage is people who have been adopting async and await and things like that, they will find that turning on strict concurrency mode is a lot smoother for them.
00:35:05 NEW_SPEAKER_SPEAKER_01: But we've also, in the latest compiler,
00:35:07 NEW_SPEAKER_SPEAKER_01: added a lot more affordances, for example, around not having to make your type sendable, but also be able to pass them through between isolation domains.
00:35:17 NEW_SPEAKER_SPEAKER_01: One of the challenges with writing the latest talk is that actually I had these great examples of problems that I was going to talk about, and then we fixed the compiler, so they weren't a problem anymore.
00:35:29 NEW_SPEAKER_SPEAKER_00: It happened like three times.
00:35:30 John: That's a good problem to have.
00:35:31 John: It's a very good problem.
00:35:32 John: I mean, that brings me to the next topic.
00:35:35 John: For both of you, what is it like
00:35:36 John: developing Swift in the open.
00:35:38 John: Because I'm watching all year on Swift Evolution.
00:35:40 John: I see the features coming in Swift 6 as part of the reason I kind of backed off my recent attempt.
00:35:44 John: I'm like, look, they're fixing a bunch of stuff in Swift 6.
00:35:45 John: And you see them go by.
00:35:46 John: You see the proposals.
00:35:47 John: Here, we're doing this thing.
00:35:48 John: They're fixing the problems in your talk.
00:35:49 John: And I see it happening all throughout the year.
00:35:51 John: That's very different than most other people here at Apple.
00:35:54 John: I mean, maybe some people sit down for WWDC and they're shocked by Swift 6.
00:35:57 John: But if you're following the forums and watching the proposals,
00:36:01 John: It's developed in the open.
00:36:02 John: It's open source.
00:36:03 John: The process of deciding what goes into it is open.
00:36:06 John: There's no mystery involved.
00:36:08 John: What is that like for you in a company where that is absolutely not true of all the other teams that you're working with, except for maybe WebKit?
00:36:15 NEW_SPEAKER_SPEAKER_01: For WebKit, but also increasingly we're seeing more of this style of operating
00:36:21 NEW_SPEAKER_SPEAKER_01: foundation now is operating in a similar fashion.
00:36:25 NEW_SPEAKER_SPEAKER_01: And that has actually been key to the next thing that we've announced this year, which is that we now have this single unified foundation code base across platforms.
00:36:35 NEW_SPEAKER_SPEAKER_01: So the same foundation that you're running
00:36:37 NEW_SPEAKER_SPEAKER_01: on your phone and on your Mac, is the foundation code that you will be running if you were to stand up a server running on Linux.
00:36:46 NEW_SPEAKER_SPEAKER_01: And so they've been running language proposals, sorry, language proposals, framework proposals to introduce new features such as, I think, Predicate, which is a foundation type, recently acquired support for regexes,
00:37:01 NEW_SPEAKER_SPEAKER_01: And that proposal was discussed in the open.
00:37:04 NEW_SPEAKER_SPEAKER_01: And then the other example, I heard your podcast last week where you were wondering, speculating about whether there was going to be a new testing framework.
00:37:13 NEW_SPEAKER_SPEAKER_01: That's because I couldn't remember the name of Swift testing.
00:37:15 John: That's the one I had seen, yes.
00:37:16 NEW_SPEAKER_SPEAKER_01: And yeah, so Swift testing was developed in the open.
00:37:22 NEW_SPEAKER_SPEAKER_01: We had some really great community feedback from that.
00:37:25 NEW_SPEAKER_SPEAKER_01: And so that's another place where we're doing that kind of open dialogue with the community about sort of the next layer up of Swift framework features.
00:37:37 John: You can use it as an example to the other groups.
00:37:39 John: Like, look, we have a public issue tracker.
00:37:41 John: And when people have problems, we can discuss them in the open.
00:37:44 John: And look how much more efficient it is to go back and forth on GitHub issues and discuss proposals.
00:37:49 John: And these other groups are sending carrier pigeons across the country through seven different intermediary parties with this game of telephone to find one crashing bug.
00:37:57 John: Do you ever pitch the other groups and say, hey, I mean, I obviously worked on Foundation.
00:38:02 John: This could be you.
00:38:03 John: You could be getting bug reports from people and communicating with them in an efficient manner and
00:38:07 John: and fixing them?
00:38:09 NEW_SPEAKER_SPEAKER_01: Yeah, we get a huge amount of benefit from the Swift community, I think.
00:38:12 NEW_SPEAKER_SPEAKER_01: When we bring ideas to them for new language features, we get this real-time feedback where the people on the forums, they spot issues with what we're proposing that we had not thought about.
00:38:25 NEW_SPEAKER_SPEAKER_01: And we iterate with them on that, and we get a huge amount of value from getting that real-time feedback from people.
00:38:34 NEW_SPEAKER_SPEAKER_01: And so I would...
00:38:35 NEW_SPEAKER_SPEAKER_01: I would say that's certainly been a valuable process for us.
00:38:38 NEW_SPEAKER_SPEAKER_01: Plus you get to argue about keywords.
00:38:39 NEW_SPEAKER_SPEAKER_01: The true purpose of every language evolutionist.
00:38:43 NEW_SPEAKER_SPEAKER_01: We've fallen into this mode now where we, this is something we've evolved as a process in the language steering group that Holly and I sit on, which is we're now in this mode where we will agree a proposal in principle, where we talk about the fundamentals of the language proposal and how it's going to work.
00:39:01 NEW_SPEAKER_SPEAKER_01: And then what we say is we've agreed that in principle, and now there's like a free swim where everybody gets to specifically focus on the name we're going to use for the keyword.
00:39:11 NEW_SPEAKER_SPEAKER_01: And that has actually helped the process a lot because the bike shedding is a shiny thing that people immediately move towards.
00:39:19 NEW_SPEAKER_SPEAKER_01: And so if you say like, let's park the naming discussion for now.
00:39:23 NEW_SPEAKER_SPEAKER_01: Let's talk about the fundamental feature.
00:39:25 NEW_SPEAKER_SPEAKER_01: Then when we've agreed the fundamental feature and we accept it in principle, then we can have like a discussion about what we're actually going to call it.
00:39:30 John: And I know that's a source of contention and it's a silly argument with people, but it really does make a big difference in language.
00:39:37 John: Some people look at the Switch Evolution or other language lists and they're like, it just seems like a bunch of people arguing over whether copyable should have a tilde in front of it, should be a new keyword.
00:39:46 John: But that's so important because those decisions you make, people live with those for decades.
00:39:51 John: So you should spend a month arguing about it.
00:39:54 John: Because I've seen it change.
00:39:55 John: And for the illusion, like the original proposal will have this thing or whatever, and you'll end up with a different thing.
00:39:59 John: And it's better.
00:40:00 John: You're making it better by arguing about it.
00:40:02 John: I guess people just don't have a tolerance for it.
00:40:03 John: They think, oh, that's not important.
00:40:04 John: I don't care what the word is called.
00:40:05 John: But it makes such a big difference to the language.
00:40:07 John: And anytime you make a slightly wrong choice.
00:40:09 John: I remember I was talking to, I don't know, it was Dennis Ritchie or one of the old Unix guys or whatever.
00:40:14 John: He said, do you have any regrets about your career?
00:40:15 John: And he said, I wish I'd put an E on the create system call.
00:40:18 John: C-R-E-A-T.
00:40:19 John: Wow.
00:40:19 John: How long is he been living with that?
00:40:21 John: I wanted to save that character, and now it's created for just for the rest of it.
00:40:25 John: It's on macOS.
00:40:26 John: It's on every Apple platform right now somewhere.
00:40:28 John: In the source code, there's a call to create with no E on it because this guy made a bad decision in the 70s.
00:40:34 John: And so you don't want that to be you.
00:40:35 John: So yeah, spend the time arguing about it.
00:40:36 John: And I think that what you said, figuring out what you're going to do and arguing about the keywords is a nice separation so you can make forward progress.
00:40:43 John: But I'm here to endorse arguing about keywords.
00:40:45 NEW_SPEAKER_SPEAKER_00: It's also really valuable because there was a recent proposal.
00:40:49 NEW_SPEAKER_SPEAKER_00: called Sending, Parameter, and Result Modifiers.
00:40:53 NEW_SPEAKER_SPEAKER_00: And we did the same thing there where we had the concept from the proposal, we accepted it in principle, and then we had a revision review to focus on the name of the keyword, which was originally called transferring, now it's called sending.
00:41:04 NEW_SPEAKER_SPEAKER_00: But the revision review thread is really interesting because a lot of people are coming in and as part of justifying why they think this keyword should be called something specific, they're reasoning through how they're thinking about the feature and how they would explain it to other people.
00:41:19 NEW_SPEAKER_SPEAKER_00: And at points where they maybe got something slightly wrong, someone else would come in and say, oh, I think this actually works this way, and I think this keyword's a little bit misleading.
00:41:27 NEW_SPEAKER_SPEAKER_00: And so that review thread is really cool because it didn't feel like a really heated, contentious debate.
00:41:34 NEW_SPEAKER_SPEAKER_00: It felt like a healthy debate of people trying to come in and explain a concept and then listening to other people explain how they thought about it.
00:41:41 NEW_SPEAKER_SPEAKER_00: And that's also valuable for us in figuring out...
00:41:44 NEW_SPEAKER_SPEAKER_00: how to actually explain the feature to Swift programmers, because what the formal specification is in the proposal is not, you know, the level of detail that you actually need to understand in order to use the feature.
00:41:57 NEW_SPEAKER_SPEAKER_00: So yeah, those name bike shedding threads are valuable for a bunch of different
00:42:02 John: Yeah, and that's part of the reason doing it in public I feel like is so beneficial because the people who are working on the proposal know it at such an intimate level.
00:42:09 John: And then you throw it in a bunch of people who have no idea what you're talking about.
00:42:11 John: And they will tell you, this is confusing to me.
00:42:13 John: Like if they're using a term of art that's meaningful to compiler people or you've just all internalized as a group what this means because you've been debating it for a month or whatever.
00:42:20 John: And the word doesn't make in their mind make them think of what it actually is.
00:42:25 John: And so changing the word will make it more learnable and more memorable.
00:42:29 John: And again, the people who don't like bike skating will say, well,
00:42:31 John: yeah, it's a weird word, but you learn it and then it just becomes internalized.
00:42:35 John: That's what happens to everybody, but that doesn't make the language approachable.
00:42:37 John: If you pick a good word, if the word means what you want it to mean, it will help people learn the feature faster.
00:42:43 John: I definitely find that because, again, some Swift features, I read the proposal and I don't understand it until you change the keyword.
00:42:50 John: And then I'm like, I read the same proposal.
00:42:51 John: I'm like, oh, now I get it because the word you've chosen is different and now I understand what you're getting at.
00:42:56 John: Even non-copyable types was like that because I didn't understand what you were trying to do until it went around a few times.
00:43:01 John: I'm like, okay,
00:43:01 John: It's not like the sending or whatever.
00:43:04 John: And I think you picked that because of the – was it part of the synergy with sendable and everything?
00:43:08 NEW_SPEAKER_SPEAKER_00: The connection with concurrency.
00:43:09 NEW_SPEAKER_SPEAKER_00: Yeah.
00:43:10 NEW_SPEAKER_SPEAKER_00: Previously, it didn't sound like it had anything to do with concurrency.
00:43:13 NEW_SPEAKER_SPEAKER_00: And so riffing off of sendable in a slightly different form so that it's not like if I'm talking about sendable versus sendable.
00:43:19 NEW_SPEAKER_SPEAKER_00: Someone did actually suggest calling it like lowercase s sendable.
00:43:22 NEW_SPEAKER_SPEAKER_00: Yeah.
00:43:22 NEW_SPEAKER_SPEAKER_00: It's really difficult to talk about.
00:43:23 NEW_SPEAKER_SPEAKER_00: But sending is close enough that you're, it's very clear you're talking about sending a value over an isolation boundary because that's the term that Swift uses for that concept.
00:43:30 NEW_SPEAKER_SPEAKER_00: So you have this immediate connection to concurrency and then you can dig in deeper to how it works.
00:43:34 John: Just don't let the math people know the language.
00:43:36 John: That's all I'm saying.
00:43:37 John: Well, it's funny just to kind of reiterate what John said, you know, when I still had a real job and I was working with other Swift developers, it was hilarious the younger ones when our code base was, some Objective-C was largely Swift, but you would bring a young,
00:43:51 John: typically a younger person who has grown up on more, you know, JavaScript-y languages.
00:43:56 John: And I think Swift is like that.
00:43:58 John: And I don't mean that in a bad way.
00:43:59 John: I mean, in a good way, it's much more approachable.
00:44:01 John: And then we would, they would look at a file of Objective-C and they would just recoil because it just looks so different.
00:44:09 John: Like, even though there, I like Objective-C just fine.
00:44:11 John: I'm not a super fan, but I like it just fine.
00:44:13 John: But it's so much less approachable, I think in so many ways, because it's so different.
00:44:16 John: And I think
00:44:17 John: Those silly arguments about a tilde, one of you said a minute ago, like a tilde or not, and what keyword to use, they really dramatically, in aggregate, can change the whole kind of vibe of a language.
00:44:28 John: And Swift's vibe, I think Marco had said earlier, or maybe somebody said, you know, there was a window of time where...
00:44:35 John: It was getting a little architecture astronaut-y, I feel like, but I feel like that's really been brought around in a good way, and I feel like we're heading on a good path.
00:44:43 John: And those arguments, while I was one of those people that was like, oh my God, why do I care?
00:44:47 John: But then, just like John said, you think about it for a minute, and you're like, oh no, this is what you two just said.
00:44:52 John: This is worth arguing about, and I think it's important.
00:44:54 John: Architecture astronauts are saving your butt, okay?
00:44:56 John: That's very true.
00:44:58 John: You're doing a good enough job of architecture astronaut, and you're like, oh, they all went away.
00:45:01 John: No, they didn't.
00:45:02 John: They just did their job.
00:45:03 John: No, that's fair.
00:45:04 John: That's fair correction.
00:45:05 NEW_SPEAKER_SPEAKER_01: Yeah, I mean, the goal is very much we have to plot this path, right, between helping people make code correct and also helping make people easily able to bring forth what's on their mind and make it like a low-ceremony language where they don't have to put that many keywords...
00:45:21 NEW_SPEAKER_SPEAKER_01: And sometimes those two things can be intention, and that's something that the community really helps us work through.
00:45:27 NEW_SPEAKER_SPEAKER_01: So I think even with concurrency, the strict checking mode, the goal there is to have the compiler help you work through exactly what you're trying to express.
00:45:38 NEW_SPEAKER_SPEAKER_01: And so...
00:45:40 NEW_SPEAKER_SPEAKER_01: sometimes we do have to resolve that tension.
00:45:43 NEW_SPEAKER_SPEAKER_01: And that's really the game of language design, is making sure that we keep that vision of having Swift be as low ceremony as possible, but not any lower than that.
00:45:52 NEW_SPEAKER_SPEAKER_01: Because if you have no ceremony, then you don't know what's going on.
00:45:56 NEW_SPEAKER_SPEAKER_01: And right now you're in an untyped language where it's really difficult to understand exactly what the code is doing.
00:46:02 NEW_SPEAKER_SPEAKER_01: If you have too much ceremony, then you get...
00:46:05 NEW_SPEAKER_SPEAKER_01: a language more like Java, where you have to write multiple different things to achieve the same result that in Swift would just be like a couple of words.
00:46:14 NEW_SPEAKER_SPEAKER_01: So yeah, it's plodding that path.
00:46:16 NEW_SPEAKER_SPEAKER_01: And that's actually something that we think Swift hits the spot of, which is why we think it would be such a great language to expand beyond just its existing app development ecosystem and expand into other places where people want
00:46:31 NEW_SPEAKER_SPEAKER_01: the performance of a ahead-of-time compiled language that doesn't have garbage collection, whilst also giving you the ability to have a joyful experience writing code, where you don't have to write that much code, and you don't have to fit too much stuff in your head at once.
00:46:44 John: MARK MIRCHANDANI- Still hanging on to that dream of Swift being the language that spans from the lowest level of the operating system up to scripting.
00:46:50 John: And there's a lot of programmers who are the potential audience for Swift.
00:46:54 John: But obviously, a lot of the programmers who are your target audience are Apple employees.
00:46:58 John: how do you work with the other teams at Apple when it comes to language features?
00:47:03 John: How does that work?
00:47:04 John: So to just give an example, like result builders for the SwiftUI thing, non-copyable types, Objective-C interop.
00:47:10 John: Do you come to them and say, hey, we think I have an idea?
00:47:13 John: Do they come to you?
00:47:14 John: What is the interaction with the rest of Apple for language features?
00:47:17 John: The language features, obviously, they will benefit everybody when they get out there in the world.
00:47:20 John: But sometimes you look at them, you're like, OK, that was a language feature that was made specifically for teams at Apple so they could adopt Swift faster or whatever.
00:47:28 NEW_SPEAKER_SPEAKER_01: I mean, I think the way I would think about it is that no feature is ever good unless you use it.
00:47:33 NEW_SPEAKER_SPEAKER_01: So when we're developing a feature, we really need to do that development with somebody who is directly using that feature.
00:47:43 NEW_SPEAKER_SPEAKER_01: And ideally, you do that development in real time.
00:47:46 NEW_SPEAKER_SPEAKER_01: And so when we're working with developers,
00:47:50 NEW_SPEAKER_SPEAKER_01: a team like the SwiftUI team, we really want to know that something like Result Builders is really going to hit the spot of them being able to create that really expressive API and develop that feature with them and have them use it and give us feedback in real time.
00:48:04 John: MARK MIRCHANDANI, Are you bringing Result Builders to them?
00:48:06 John: Or are they bringing the idea of the SwiftUI to you and saying, we need a generic system to do this?
00:48:11 John: And I don't think SwiftUI in particular is not... So another example would be Embedded Swift.
00:48:17 NEW_SPEAKER_SPEAKER_01: So obviously we've got a lot of material this week and we've been putting it up actually prior to this week encouraging people to check out Embedded Swift and use it for developing for the Raspberry Pi Pico or the Playdate or something like that.
00:48:31 NEW_SPEAKER_SPEAKER_01: But we also developed it in conjunction with some of our developers who are working on things like the Secure Enclave.
00:48:38 NEW_SPEAKER_SPEAKER_01: And we've talked about that's actually one of the
00:48:40 NEW_SPEAKER_SPEAKER_01: the places where we've adopted it this year.
00:48:43 NEW_SPEAKER_SPEAKER_01: And so we directly work with them and they inform our thinking about how to target that language mode.
00:48:51 NEW_SPEAKER_SPEAKER_01: And it really ends up being a better product.
00:48:53 NEW_SPEAKER_SPEAKER_01: I think if we developed the language ahead of time and then said, here it is, we knew you needed to do some firmware development, here's a language that does it, we would not get as good a result.
00:49:02 John: And another example of SwiftUI is like the old...
00:49:04 John: the old limitation for the parameter thing.
00:49:07 John: So you get 1 through 10 or whatever.
00:49:08 John: And what was it, parameter packs or whatever thing that goes around that?
00:49:11 John: Was that an example of like, OK, well, obviously you didn't have that language feature.
00:49:14 John: They rolled out SwiftUI anyway, and there was this kind of semi-not-well-known limitation or whatever.
00:49:19 John: And why was the limitation?
00:49:20 John: There was a language limitation.
00:49:21 John: Then you could look at that and say, all right, well, our language is failing the team here.
00:49:27 John: How can we solve that, but not just by hard coding a thing for SwiftUI, but adding a language feature that now is
00:49:32 John: beneficial to anybody who wants to use it.
00:49:35 John: But as a side effect, that limitation in SwiftUI is gone.
00:49:38 NEW_SPEAKER_SPEAKER_00: Yeah.
00:49:38 NEW_SPEAKER_SPEAKER_00: So parameter packs specifically were a generics feature that I think we always knew we wanted to have because there are such a wide variety of use cases for them.
00:49:48 NEW_SPEAKER_SPEAKER_00: And SwiftUI ViewBuilder is not the only API that adopted parameter packs last year.
00:49:53 NEW_SPEAKER_SPEAKER_00: You also see it in Foundations Predicate API.
00:49:55 NEW_SPEAKER_SPEAKER_00: You see it in WeatherKit APIs because there's a lot of APIs that are structured like that where you have a variable number of things that you pass in and then you get the same variable number of things as your output there.
00:50:06 NEW_SPEAKER_SPEAKER_00: But I help a lot of people try to express something in Swift every day across a wide variety of framework teams, people writing apps, people on the forums.
00:50:17 NEW_SPEAKER_SPEAKER_00: And one really important job of my team, the language team, is to take...
00:50:22 NEW_SPEAKER_SPEAKER_00: see all of these different use cases that people have, and first and foremost, help them use the language as it is today.
00:50:28 NEW_SPEAKER_SPEAKER_00: In a lot of cases, people are just trying to use some feature that already exists, and they need some help figuring out how to exactly make it work for their specific use case.
00:50:37 NEW_SPEAKER_SPEAKER_00: And in cases where there is an expressivity limitation in the language, we take all of these different use cases, again, from a variety of different sources.
00:50:46 NEW_SPEAKER_SPEAKER_00: We use the forums as a big source of use cases for different things as well.
00:50:51 NEW_SPEAKER_SPEAKER_00: Macros are a really great example of this.
00:50:54 NEW_SPEAKER_SPEAKER_00: There were a variety of different use cases for frameworks at Apple.
00:50:57 NEW_SPEAKER_SPEAKER_00: Swift data adopted macros.
00:50:59 NEW_SPEAKER_SPEAKER_00: The new observation library from last year as part of the Swift standard library uses macros.
00:51:05 NEW_SPEAKER_SPEAKER_00: But there were also a ton of use cases spinning up on the forums about people who were wanting to do really similar things in their code.
00:51:11 NEW_SPEAKER_SPEAKER_00: And something that was
00:51:12 NEW_SPEAKER_SPEAKER_00: awesome during the review process of macros in Swift Evolution was people were trying it out and putting up example macro packages on GitHub.
00:51:23 NEW_SPEAKER_SPEAKER_00: And that also was a really great example of people actually trying out the feature and seeing how it worked for them at the same time that it was being developed.
00:51:31 NEW_SPEAKER_SPEAKER_00: And that turned into real feedback that was incorporated into the design.
00:51:35 NEW_SPEAKER_SPEAKER_00: So yeah, usually the way that these things work out, unless there's some big overarching goal like data race safety, that was a goal that was driven by us.
00:51:44 NEW_SPEAKER_SPEAKER_00: But a lot of times it's that we're helping so many different people use the language in a variety of different ways, and we can generalize these expressivity limitations into a single language feature that works for everybody.
00:51:58 NEW_SPEAKER_SPEAKER_00: It's a really interesting process.
00:52:01 NEW_SPEAKER_SPEAKER_01: Parameter packs is actually, I think, an example where we really feel like we're successfully doing what we try to do, which is have this progressive disclosure where we have these really advanced language features that ultimately are able to produce APIs, help people produce APIs, that you would not know you're using these advanced features when you use them day to day.
00:52:22 NEW_SPEAKER_SPEAKER_01: You do not know when you go create a view with 11 things in it that actually that is only possible because of parameter packs.
00:52:28 NEW_SPEAKER_SPEAKER_01: You don't know that when you're
00:52:29 NEW_SPEAKER_SPEAKER_01: when you've got this really nice api where you tell the weather api to give you like temperature and wind speed it's actually giving you two strongly typed values that then instead of giving you like two untied values like in any type value that you used to have before you immediately get these two strongly type values where you get like code completion on exactly the the the types that you have that that make it so much easier to use um macros is another example where like
00:52:54 NEW_SPEAKER_SPEAKER_01: The creation of macros was general enough that people were able to create these great new APIs that you do not have to think about when you're using them.
00:53:01 NEW_SPEAKER_SPEAKER_01: So Swift Testing is another one I know you folks were ragging on the fluent design of other testing frameworks.
00:53:09 NEW_SPEAKER_SPEAKER_01: And one of the beautiful things about Swift Testing is that you write just regular expressions.
00:53:14 NEW_SPEAKER_SPEAKER_01: Sorry, I shouldn't say regular expressions.
00:53:17 NEW_SPEAKER_SPEAKER_01: I can't say that's a jump game.
00:53:18 NEW_SPEAKER_SPEAKER_01: You write ordinary expressions, ordinary Swift expressions like A is not equal to nil or something like that.
00:53:25 NEW_SPEAKER_SPEAKER_01: You put them inside a pound expect and then the pound expect macro will do some magic stuff under the hood to do reflection actually exactly similar to what you were talking about where it breaks down the object and looks at all the different properties.
00:53:36 NEW_SPEAKER_SPEAKER_01: We don't have diffing quite yet.
00:53:37 NEW_SPEAKER_SPEAKER_01: That's a great idea to...
00:53:38 NEW_SPEAKER_SPEAKER_01: Maybe bring to the Swift forums and talk about it.
00:53:40 John: If you just look at any other testing framework, I'm pretty sure they know it exists.
00:53:44 John: Fair enough.
00:53:44 John: That's the thing with testing frameworks.
00:53:46 John: There's so many of them.
00:53:46 John: There's so much prior art.
00:53:48 John: NexiTest was a little bit crusty, but you're spoiled for choice.
00:53:51 John: You just look at all the popular languages and all the testing frameworks, and you've chosen this time not to go with a bunch of words with dots between them, but some people like that.
00:53:58 John: So I predict that Swift testing, it looks like a great advancement over what came before, but I feel like testing frameworks are difficult to get right on the second or third try.
00:54:08 John: Going beyond XC tests is great.
00:54:12 John: We actually had planned to talk to the both of you more about Swift testing, but in interest of time, I wanted to give, or we wanted to give you guys a couple of, the floor to answer a couple of softball questions.
00:54:23 John: First of all, I'm going to start a little bit negative, and then we're going to end with a positive.
00:54:28 John: Is there any misunderstanding?
00:54:29 John: It's more of a curveball.
00:54:30 John: Yeah, right.
00:54:31 John: I actually have a statement.
00:54:32 John: I don't know if it supports me.
00:54:33 John: Is there any common misunderstanding in the community that maybe grinds your gears or you just feel bad, like I'm trying to make this not so negative, like you just feel bad that people just haven't grokked that, oh, you know, all of us, myself maybe included, think A, but it's actually Z, you know, or whatever the case may be.
00:54:51 John: And maybe there isn't anything, but if you had, let's say, you know, a couple of minutes to correct some common misunderstanding, is there anything that jumps to mind?
00:55:00 John: About Swift, not just the one.
00:55:01 NEW_SPEAKER_SPEAKER_00: Yes.
00:55:02 NEW_SPEAKER_SPEAKER_00: Yeah.
00:55:02 NEW_SPEAKER_SPEAKER_00: There is one immediate one that comes to mind.
00:55:05 NEW_SPEAKER_SPEAKER_00: People in Swift love protocols.
00:55:06 NEW_SPEAKER_SPEAKER_00: Protocols are great.
00:55:07 NEW_SPEAKER_SPEAKER_00: I love protocols, too.
00:55:09 NEW_SPEAKER_SPEAKER_00: But a lot of people, when they're starting to write an app, they start by adding a protocol into their code, and then they end up
00:55:18 NEW_SPEAKER_SPEAKER_00: using a lot more abstraction than they really needed to in their code.
00:55:22 NEW_SPEAKER_SPEAKER_00: Like they end up using any types, or if you're familiar with the formal term, existential types, which we try to steer people away from because those are a really complicated feature.
00:55:31 NEW_SPEAKER_SPEAKER_00: And understanding why they have some of the behaviors they have is really, really nuanced and hard for a lot of people to grasp.
00:55:38 NEW_SPEAKER_SPEAKER_00: And in a lot of cases, you don't need them.
00:55:41 NEW_SPEAKER_SPEAKER_00: So I would tell people to start with a concrete type, start with a struct.
00:55:44 NEW_SPEAKER_SPEAKER_00: specifically until you need more abstraction or you need reference semantics and then sort of evolve from there.
00:55:52 NEW_SPEAKER_SPEAKER_00: The same thing is true of global.
00:55:54 NEW_SPEAKER_SPEAKER_00: I've seen so many people write static variables that never change throughout their code base.
00:56:00 NEW_SPEAKER_SPEAKER_00: So I would tell people to start with a let and that's really helpful for data race safety as well.
00:56:03 John: I blame, what is it, maybe you know, protocol-oriented programming.
00:56:07 John: Remember that LWDC session?
00:56:08 NEW_SPEAKER_SPEAKER_00: I was thinking the same thing.
00:56:09 John: A lot of people went to that session and were like, protocols, they're the future.
00:56:12 John: I'm starting every app with protocols.
00:56:13 NEW_SPEAKER_SPEAKER_01: It's worth re-watching that talk.
00:56:15 NEW_SPEAKER_SPEAKER_01: What the talk said was, if you're thinking about creating a subtyping relationship, instead of a class hierarchy, start with the protocol.
00:56:23 NEW_SPEAKER_SPEAKER_01: Unfortunately, what people heard was, start with the protocol.
00:56:26 NEW_SPEAKER_SPEAKER_01: It's right in the title.
00:56:27 John: They read the title and they're like, great, I'm on board.
00:56:29 NEW_SPEAKER_SPEAKER_01: It's the right tool for everything.
00:56:31 NEW_SPEAKER_SPEAKER_01: It gets to that point where it's kind of like the black box.
00:56:33 NEW_SPEAKER_SPEAKER_01: Why don't they make the entire plane out of protocols?
00:56:36 NEW_SPEAKER_SPEAKER_01: That's not what you want.
00:56:37 NEW_SPEAKER_SPEAKER_01: You want to start from structs, like Holly said, and then generalize your problem when you find you need to generalize it.
00:56:43 John: That's what programmers do, though.
00:56:45 John: They generalize it from the start.
00:56:46 John: Yeah, that's really good advice.
00:56:48 John: And then finally, because we really are running low on time, what are you proud of lately?
00:56:51 John: Like, I mean, obviously, and I mean, there's obvious answers like Swift concurrency in the strict concurrency.
00:56:58 John: It's an incredible land and you should be proud of that.
00:57:00 John: But is there maybe something that, you know, your pet feature or project or what have you that maybe not a lot of people have seen, like embedded Swift is a great example that, I mean, I've seen a lot of this on the WWDC session titles anyway, but is there something maybe a little more esoteric or just your pet thing that you're really, really into that you're
00:57:16 John: proud of?
00:57:17 NEW_SPEAKER_SPEAKER_01: I don't know if it's esoteric, but I think we're pretty proud of the progress we've made around cross-platform support.
00:57:22 NEW_SPEAKER_SPEAKER_01: And that's especially something that we've been pushing this year.
00:57:24 NEW_SPEAKER_SPEAKER_01: We have support for more distros this year.
00:57:28 NEW_SPEAKER_SPEAKER_01: We have now Debian and Fedora.
00:57:30 NEW_SPEAKER_SPEAKER_01: We've been working with the community on creating this really great plugin for VS Code that allows you to use VS Code if that's what you're into.
00:57:40 NEW_SPEAKER_SPEAKER_01: Personally, I'm sticking with Xcode, but a lot of people have very personal preferences.
00:57:45 NEW_SPEAKER_SPEAKER_01: We also have some articles up on how to integrate code completion into NeoVim and Emacs, if that's your jam as well.
00:57:52 NEW_SPEAKER_SPEAKER_01: So I think we've made some really great progress in that area, and we've seen both internally and in the outside community a lot of more rapid adoption of Swift on Linux environments and on the server generally.
00:58:07 NEW_SPEAKER_SPEAKER_01: I think if you saw
00:58:10 NEW_SPEAKER_SPEAKER_01: some discussion in the keynote to the fact that we're now running Swift on the server to do some of the new Apple intelligence features.
00:58:16 NEW_SPEAKER_SPEAKER_01: And that's all built on this foundation that we've been working on for years with projects like the Swift Neo framework and things like that that have always given us this ability to stand up servers that have this really great ability to, again, have this high-level
00:58:32 NEW_SPEAKER_SPEAKER_01: language that we feel is really enjoyable to write, but that managed to get you, in the case of the server, really low memory footprints, which can be a big challenge when it comes to large server farms, especially.
00:58:46 NEW_SPEAKER_SPEAKER_01: And that's been a really big win for us that we're pretty proud of.
00:58:49 NEW_SPEAKER_SPEAKER_01: World domination is still on the table.
00:58:51 John: Still on the table.
00:58:52 NEW_SPEAKER_SPEAKER_01: How about you, Holly?
00:58:54 NEW_SPEAKER_SPEAKER_00: My team's focus this year was, you know, data race safety and SWIFT 6.
00:58:58 NEW_SPEAKER_SPEAKER_00: I'm personally really proud of my team because a lot of the team was new to the data race safety model and the concurrency model in general.
00:59:06 NEW_SPEAKER_SPEAKER_00: You know, at the beginning of this year, originally it was built by...
00:59:12 NEW_SPEAKER_SPEAKER_00: a smaller group of engineers and then more people got involved in concurrency.
00:59:16 NEW_SPEAKER_SPEAKER_00: So yeah, I'm really proud of the work that the team has put in, in general, into this release.
00:59:21 NEW_SPEAKER_SPEAKER_00: And I'm also really excited by how the community has started to adopt these features and surface feedback to us and talk about what's difficult, talk about what error messages are confusing, and sort of seeing the community
00:59:36 NEW_SPEAKER_SPEAKER_00: really embrace this new model of programming and come to a shared understanding and improve both the compiler and the documentation and the language.
00:59:47 NEW_SPEAKER_SPEAKER_00: I'm really excited to see where this goes from here.
00:59:50 John: That's awesome.
00:59:51 John: Ben Cohen, thank you so much for joining us.
00:59:53 John: I really appreciate it.
00:59:54 John: Thank you very much.
00:59:54 John: Holly Borla, thank you so very, very much to both of you guys.
00:59:57 John: We really, really appreciate it.
00:59:59 NEW_SPEAKER_SPEAKER_00: Thank you so much for having us.
01:00:00 John: And thank you to Apple for hosting.
01:00:02 John: And with that, I think we're good.
01:00:04 John: See you next week.

ATP Interview: Holly Borla & Ben Cohen

00:00:00 / --:--:--