From Objective-C to Swift and the Latest Innovations at Apple

#Objective-C #swift #Apple

Daniel H Steinberg, a leading pioneer of Swift, iOS, and Java, shares his story and views on the early transition from Objective-C to Swift and the impact the latter had on the entire Apple ecosystem. Daniel also discusses recent highlights like SwiftUI and Combine while casting a light on how innovation is encouraged at Apple and where and what developments will lead us to in upcoming years.

Intro

Jørn Larsen: We are here in the studio in Copenhagen at GOTO Copenhagen. This is one of our really old conferences and it's still going very strong. This year (2019) we have 1,750 people, and the first year we did it in the exact location with 200 people. We are very happy to welcome Daniel H Steinberg here. Welcome.

 

Daniel H Steinberg & Jørn Larsen

 

Daniel H Steinberg: Hi.

Jørn Larsen: You're one of the pioneers in iOS and Swift and Java. Maybe you can tell a little bit about your journey before iOS and coming into development for Apple.

Daniel H Steinberg: Sure. So I'm trained as a mathematician. I'm a differential geometer and I was a college professor, but I kept going to code and got into Java in the very early days, the 1.0.2 days. My sister was managing "JavaWorld" magazine so I started writing articles for her, and the next thing I knew I was writing books and I was doing training and I left academia. Then I was very lucky that some friends sort of pushed me that if you wanna be on the Mac platform you're gonna have to learn Objective-C. In fact, Java derives from Objective-C so it wasn't that big of a shift. 

I was lucky to come to Objective-C the year before the iPhone shift, so I was really in a nice position there. Then Swift was just magical. It's just changed the way we write code and it's been a lot of fun.

Jørn Larsen: So that was good timing.

Daniel H Steinberg: Yes.



The Year of the iPhone

 

Jørn Larsen: Yes. So the year of the iPhone, can you describe that, how have you experienced that?

 

Daniel H Steinberg: Well, again, I was very lucky that when Steve came back to Apple, I got to see every keynote he did at "Macworld" and the WWDC and I remember the WWDC video, the keynote where the debuts of the iPhone and there was nothing we could do as developers for it, but it was just so cool to see and to have and to touch. Then when they gave us this API and they gave us access to coding for it with the iPhone 2, it was really before we had iOS 3, 4, or 5 and all that, but we weren't allowed to teach it because it was still under NDA. So we were doing these kinds of sneaky things. We were teaching Mac and saying, "It's just like the iPhone." Then the NDA dropped and we were really positioned to start teaching that and so we had one of the first classes on iOS development.

 

Jørn Larsen: So the first year the iPhone came out, it was really one screen full of apps but only from Apple.

 

Daniel H Steinberg: Yes.

 

Jørn Larsen: And then after a while, after a year or so, they decided maybe we should have an App Store.

 

Daniel H Steinberg: They did really clever things. Like, they didn't have GPS in those days, but then they did the thing where they used Wi-Fi near you to try to figure out your location. So they did just really clever things on this constrained device. You think of what we have on our iPhone now and the cameras and our watches, it's just incredible. I'm clearly a fanboy.

 

Jørn Larsen: Yes. I mean, when you do something… if you're committed to a platform, it gives you so much in return, right?

 

Daniel H Steinberg: Yes.

 

The Transition from Objective-C to Swift

 

Jørn Larsen: So, in the beginning, it was Objective-C, and Objective-C came from NeXTSTEP from when Steve went out and did his NeXT Computer. I was a happy owner of a NeXT Computer and I was programming Objective-C.

 

Daniel H Steinberg: Well, I mean, the language existed outside of that but that was the language that they chose to use.

 

Jørn Larsen: One big innovation that we learned about from Steve Wozniak yesterday, we had the pleasure of also meeting him yesterday. So he said, yeah, the thing he really loved about bringing NeXT into Apple was the Unix platform, the multiprocessing capabilities, multitasking, and that's what we really like today as well, that we can run apps and we can run more things on the iPhone and it's a real system.

 

Daniel H Steinberg: So you probably remember when those machines filled rooms this big and now I've got Unix on my watch.

 

Jørn Larsen: Exactly. That's pretty cool. So maybe can you tell me a little about the transition from Objective-C to Swift for you? When that happened and what do you think the motivation from Apple was to make that shift?

 

Daniel H Steinberg: So I was not like a lot of people. A lot of people were complaining that Objective-C is old, the square brackets, but these were a lot of people that had come to the platform from Ruby and other languages and they wanted to write for the iPhone but they wanted the language to look more like their language. These were not the old Mac guys who've been there forever and said, "What's wrong with square brackets? What's wrong with these colons?" Sending the messages, I mean, that was something that we thought of since Alan Kay, that you send a message to something, or even before Nygaard who was, you know, thinking about message passing. So Objective-C was a lovely language to write in, but there was something about Swift, and, in particular, working with blocks in Objective-C was very painful. So even though Swift wasn't a functional language, it allowed us to do functional things, and all of a sudden our code was cleaner. Although I didn't have a problem with Objective-C and still love it, man, Swift makes me happy every day.

 

Jørn Larsen: Yes.

 

Daniel H Steinberg: Yes. The early days of Swift were painful. There were things that it didn't do and things that it changed, but I'll give you an example from the first year. When Apple introduced variables they said some variables vary and some are constants, and we call one let and we call one var. So when they said arrays are fixed, you could still change what was in a certain element of an array, a position of an array in a let, and the community freaked out and said, "That's not what we expect." And Apple changed it, and this was before Swift was open source. So from the very start, you knew that they were listening to the community and that was a big change from Apple.

 

Jørn Larsen: But also how fast was the transition? How many developers actually moved from Objective-C to Swift, and how long did that take?

 

Daniel H Steinberg: I think it was a lot faster than Apple anticipated. The transition from Swift 2 to Swift 3 was very painful and people complained, and there were people at Apple that said, "We never thought so many people would come over so quickly. We thought people would just sort of put their toe in the water."

 

Jørn Larsen: Test it out.

 

Daniel H Steinberg: But, you know, Apple owns that world, and so when Apple says, "Your future is Swift," as developers we go, "Well, yeah"

 

Jørn Larsen: They move.

 

Daniel H Steinberg: Exactly.

Daniel H Steinberg & Jørn Larsen

Most Recent Highlights from the Swift and iOS World

 

Jørn Larsen: Yes. So that was a rough beginning, but where are we today? So let's just jump onto the latest release of iOS and Swift. Can you share some of the highlights there?

 

Daniel H Steinberg: Sure. A little over a year ago, the big news was ABI Stability. Apple did a very clever thing as Swift was changing, we want the apps that you worked on yesterday to work on iOS and back and forth, and so they would imbed the Swift runtime inside your app and your apps are bigger than they need to be. At some point, they said we can figure out the memory layout and we can stabilize this, and so that was the ABI Stability. Then in those past six months, we've gotten the Module Stability which says, "You don't have to share the code of your module. You can ship it as a binary and now that can stay from version to version." We got a lot of stability there. Then, of course, the big news was SwiftUI and Combine. These were the two huge frameworks that Apple announced in June (2019) at WWDC.

SwiftUI

Jørn Larsen: Let's talk about SwiftUI. So what are the highlights there?

 

Daniel H Steinberg: The highlight is that it's a totally different way of doing it. In a typical Hello World in Objective-C, you would have a view controller and you would add a label and you would add a button and when you press the button, the button would say to the label, "Hey, change your display to this." In SwiftUI, everything is done with state. 

The button would say, "Modify the state." And the label would get told, "Hey, the state is modified. You need to be changed out." So everything is done in the single direction of flow. It's declarative. It's a really different way of thinking about things, and now our views are value types, not reference types. Forever we've had subclasses of UIView and subclasses of UIViewController and now we have these structs that can form this protocol. Something I've been saying is Apple never tells you where they're going but they give you hints. So when Apple tells us to stop using pixels, use points instead, they're not telling us that we're going to a Retina display because they're not gonna tell us what hardware is coming. But if we do what they tell us, then we're ready when that retina display ships. So if you look back five years, they did a very famous presentation at WWDC called "Protocol-oriented programming" and it's the famous Crusty talk, and if you go back and look at it, there are the roots of SwiftUI. They're telling us that this is the direction we're moving. We just didn't know it at the time.

 

Jørn Larsen: You need to find the hidden gold nuggets.

Daniel H Steinberg: You could always look back.

 

Combine

 

Jørn Larsen: Yes. And Combine. Maybe explain this as well?

 

Daniel H Steinberg: So, Combine is Apple's attempt to say, we've got all these ways of dealing with asynchronous. We've got delegates and we've got notifications and we got KVL and let's unify it under this framework that is based on reactive streams in the same way RxSwift is and other reactive frameworks are, but Apple has tied it into their APIs making it very easy for us to kick off a URL session and then react when something comes back. So it's really nicely integrated. Early days for SwiftUI and Combine. There are still things missing in both, but I expect in the next year when we see iOS 14, we'll see that fleshed out. That's clearly the future.

 

Jørn Larsen: It's a new world. The way Apple does things is that they really urge you to upgrade and use the latest as quickly as possible, and they have the App Store to actually, you know, empower that. So you have millions and millions of apps that get upgraded and they all work in a new way and use new capabilities fairly quickly.

 

Daniel H Steinberg: At the same time, they're very big on pushing end-users to update to the latest OS and they make that easy too. So you see the adoption of IOS 13 is much higher than on other platforms using the latest.

 

Innovations in the Swift and iOS World

 

Jørn Larsen: Yes, it makes things a lot easier. Let's talk a little bit about innovation. So what are the things Apple does on Swift and the iOS platform that keeps them innovating. Do they put a lot of new sensors in and capabilities in the hardware? So can you talk about this year, what were the biggest innovations?

 

Daniel H Steinberg: That's exactly the point. The point is Apple controls both the software and the hardware and that's been their secret sauce since the Mac. One of the first things that Steve did when he came back was to get rid of all the clones and he said, "We're gonna control." Now he knows which GPUs we are targeting, which CPUs.  When they say, "Oh, I think we're gonna add a sensor that's going to do a compass, they can add..." 

Each year they've added something. You saw they added some privacy chips and they're clearly going in the direction of AR and machine learning. So they're thinking about that through coprocessors. The other thing is they lay these things out and then they pay off later. So, Metal is doing a lot of visual things sure, but it's also doing a lot of calculations using the GPUs. So you're seeing a lot of Accelerate. One of the most exciting things that Apple does now that Swift is open source is they announce these things in public, and they recently announced a new numbers library. We're gonna have complex numbers coming up. The guy that's working on it is the guy that worked on it for the hardware in Accelerate frameworks, and so they've really got people working on things that are properly positioned.

 

Jørn Larsen: I learned that they built in a more precise sensor that you can build an app and if you walk a room, you can build an indoor map. I was at Apple two weeks ago and they showed me how to do indoor mapping. I think that's going to be some of the new stuff because we all know if we're walking the streets we have GPS and we have positioning from Wi-Fi and signals, but indoor has always been a little bit problematic to use apps to actually navigate people to the milk or whatever they need to find.

 

Daniel H Steinberg: What's interesting about that is an example of Apple trying something and it didn't work. So they tried it with beacons years ago. With beacons, you needed a lot of extra hardware and triangulation and it never quite worked well. 

Now their hardware has improved to a point where we don't need those externally. Also, the near form is kind of interesting because if I have something on my phone, and you're not necessarily a contact, if we're close by I can still send it to you.

 

Jørn Larsen: Yes, yes. Yeah. Also yesterday, Steve Wozniak talked about the way when they do something they do it right. Like with Apple Pay, I know in Japan they made a special version of Apple Pay for Japan so you could really just run through check-in for a train and you would pay while you run.

 

Daniel H Steinberg: That's funny.

 

Jørn Larsen: So that's just for one market that they do this.

Daniel H Steinberg: Because that's the way they work.

 

Jørn Larsen: That's the way they do it.

 

Daniel H Steinberg: You know, the other thing about Apple is people are always saying, you know, where's your this? Where's your that? You're not the first. They're never the first. Even going back to the iPod, they weren't the first MP3 player or the first watch, or even the first phone. So they always sit back and watch and say, "How can we do this differently?" The amount of electronics even in the earpiece, in your HomePod, it's a tremendous amount.

 

Kickstart Book Series

 

Jørn Larsen: Okay. So let's talk about, your recently published a new book on your birthday.

 

Daniel H Steinberg: I did.

 

Jørn Larsen: So tell me a little bit about that.

 

Daniel H Steinberg: On my 60th birthday.

 

Jørn Larsen:  I'm looking forward to reading it. Please talk a little bit about it, the content.

 

Daniel H Steinberg: Sure. So the way I write books is often different. I look around to see if someone has written a book that I would've written because I'd rather not write that book. And if no one's written it, what I write is, "You're a smart person. You're a good programmer. You just don't know this." So my books tend to focus on that. 

I work with a lot of intuition and metaphor. So I'm teaching SwiftUI based on what you do in UIkit. How is it different? What are the things you need to know? It's almost like a video game where you get stronger and stronger so you face harder and harder levels. I take a lot of inspiration from screenwriting. I write in terms of scenes and thoughts and acts, and I hope you enjoy the book.

Jørn Larsen: I'll read it. Actually, when we did these iPhone days in Geneva at the beginning of the era of the iPhone, I was actually programming with my daughter apps on the iPhone. That was pretty fun.

 

Daniel H Steinberg: Nice.

 

What will be in the Next Release of Swift?

 

Jørn Larsen: So let's talk a little bit about what do you think will be in the next release of Swift, iOS, and the whole programming environment?

 

Daniel H Steinberg: So it's hard to know for consumers, for developers, they'll certainly round out SwiftUI. There's a lot of things missing. For instance, this year (2019) one of the biggest non-SwiftUI announcements was a new UICollectionView, and CollectionView has got much stronger and then diffable collections underneath them, and we see no collections at all in SwiftUI, so we'll certainly get that. Combine will push out and will integrate better. So I expect to see those two frameworks. They've had massive announcements for AR and for machine learning each year. I expect that to continue. There was just a rumor that internally, they have an announcement to kind of reset our expectations that our AR glasses aren't coming in 2020 but they're coming in 2022 and then a lighter version in 2023. When Apple leaks something, it's usually because they don't want people to become too anxious and they're disappointed when something doesn't ship. So they're telling us don't look for this at next year's dub-dub.

 

Jørn Larsen: Yeah. But that will be the next product from Apple, the physical product from Apple? Will it be the AR glasses?

 

Daniel H Steinberg: It's certainly going to be one of them. Who knows? I mean, one of the areas that they haven't spent a lot of time on and which has surprised me is the HomeKit.

They have this ecosystem for home appliances and yet they aren't doing much to support it. Now that we have Swift on Linux, that should be much easier. Swift on the server they're mainly leaving to other people, but they're doing the plumbing with SwiftNIO, and you're seeing SwiftNIO and Swift on the server sort of pick up. The Package Manager this year was huge and I expect to see more things with that. They're working on including resources and binaries. When that happens, third-party things like Carthage and CocoaPods, I don't think they're in a hurry to keep developing things when there's a first-party application.

Jørn Larsen: The audience can meet you around Europe. Now we're in Europe. So you will be doing classes in…

 

Daniel H Steinberg: I'm here all the time.

 

Jørn Larsen: In Holland, in UK.

 

Daniel H Steinberg: In Paris, in the UK, sure. I'm here all the time and if you've got a private class, I'm happy to come to teach.

 

Jørn Larsen: Thank you so much. Thank you for coming.

 

Daniel H Steinberg: Thank you for having me. My pleasure.

Daniel H Steinberg & Jørn Larsen

Recommended talks

What’s New in Swift