Recorded – watch the full episode on YouTube.
How do you keep up with all the changes from Swift Evolution? What tips would you give to listeners who are struggling to stay on top of Swift's changes?
Daniel Steinberg: One is just to promote what you do, Paul. You do something amazing: every time Swift revs, you say, “here's what's new in Swift.” You have examples of how to use it and you have a nice UI where they can say, “well, I want just the changes between Swift 5.1 and 5.2.” So you have a great resource for that and you keep it very up to date. I don't know how you ever sleep. That's one thing.
The other thing is try things out and see if you like them. For instance, something that's new is we don't have to use return statements in single expression functions. So we've had that and closures forever. It makes SwiftUI read a lot nicer. Although you have to sit and think a moment, the first time you see SwiftUI like, “oh, it’s returning something.”
Other languages, anytime you have a function, the last line is what's returned. In Swift, it's only if it's a single expression. I think in the Swift Evolution proposal, they said, “that's just beyond what we are doing right now.” But for consistency, that would be nice, because it's odd that some places you use return, some places you don't. What I'm saying is, take a look at what you say is new, and then try it out for yourself. You might like it, you might not like it. Now that I'm not using return, I don't miss it the same way I don't miss semi colons.
“The other thing is try things out and see if you like them.”
Paul Hudson: And that's one of the interesting things I think about Evolution is that we can look at it and say, “they want this thing changed but it's always been like that. That's that feels wrong. It feels alien.” And one of them that did not get through was eliding commas at the end of lines for arrays. You could have A, new line, B, new line, C, and have those things be the same as a comma.
And it got a lot of pushback. And for me, it's like, wow, that is alien. Of course, it's alien. Because it's new. It's not what we're used to. But then a week, two weeks, three weeks of using it, and it stops being alien. It starts being natural. And you look back and think, "Well, hasn't it always been that way?" And of course, it hasn't been.
Daniel Steinberg: And then there was sort of the other side of that. Someone proposed in functions that the argument list, the last argument could have a comma after it because it made it easier for you to add additional arguments and remove things and not... There were no errors and that didn't go through. And the first community proposal that went through, the first thing proposed by someone outside of Apple was getting rid of the ++ and the --.
Paul Hudson: Erica's reign of terror she had on Swift 3!
Daniel Steinberg: That just looks so funny to us because we've used it for years. But now we don't.
Paul Hudson: Yeah, now we really don't. And it's interesting that... As a point somewhere, obviously we've passed Swift 3 now, so we don't want to break too much. But things we just take for granted, the ++ being one of them, -- being another one, exclamation marks to mean “not”. We just take that for granted. That's how it was in C or Objective-C, that's how it should be elsewhere. But it's not in any way natural. None of this stuff is natural.
“Just to go full circle back, a lot of people's objection as they come to functional programming is it's not natural, which just means I'm not used to it.”
We've been taught that this thing means “not”. That's interesting that in my own code, and I see a lot of other developers do the same thing. I would much rather write
if isLoggedIn == false than say,
if !isLoggedIn, because I can read one naturally like English and the other one I can't necessarily read like English.
Daniel Steinberg: And just to go full circle back, a lot of people's objection as they come to functional programming is it's not natural, which just means I'm not used to it. Who is the guy that wrote the Humane Interface Guidelines? The guy that was on the Mac project for Apple? Jef Raskin. And he says there isn't such a thing as an intuitive interface. It's the interface you're used to. And so it's the same with the language and functional is going to feel different. It's going to feel horrible. “This is just stupid.” And then you get used to it. And as you say, you don't even notice what bothered you yesterday.
Paul Hudson: Yeah, it's true. You're breaking the muscle memory and making new muscle memory. Literally carving out new neurons in your brain or at least retraining them to do different kinds of things.
Earlier this year before the lockdown, I was volunteering at my daughter's school teaching the girls there in a higher year some programming. And we were doing HTML and CSS. It was great fun. And they all use Windows. And they'd say, "Mr. Hudson, I've got a problem." And I'd go to help them with a problem. And I was trying to use their laptops and I really struggled.
It made me feel genuinely stupid that I struggled to use these laptops, which were touchscreen Windows laptops and I just couldn't do anything with it. My hands weren't working correctly to find things, to tap on things. I was pressing the wrong key half the time. And it just felt bad. And that's an OS, which is not the industry standard, but it's a huge... 85% of machines use Windows and I'm struggling to do it. Like I'm the guy who can't reprogram a VCR or something.
Daniel Steinberg: You had to remember that to fix a problem in Windows, you turn it off and turn it on.
Paul Hudson: Yeah. This is more them typing wonky HTML because they're still learning HTML. They were trying, that's the main thing.
Daniel Steinberg: That's another example. Windows isn't the Windows that we were brought up to hate. Everything has changed so much that to keep these old biases, it makes us sound old and dated.
Paul Hudson: It's certainly true. Microsoft today happen to be one of the leading open-source companies out there. They literally own GitHub for a start.
Daniel Steinberg: And they've been a good citizen with that.
Paul Hudson: They have.
Daniel Steinberg: As much of a fan as I am of Apple, the first thing they do when they buy a company is seek support for other platforms. When they just took over Dark Sky, they said that's the end of new product for Android. Well, that's a shame. Whereas GitHub has just been a really good citizen. When Microsoft bought it, I was really worried, especially because Apple had just announced how much they were keeping on GitHub. And I think Microsoft's been a very good steward for GitHub.
Paul Hudson: I don't think I was worried. I think I was quite optimistic because by that point Microsoft had proven their open-source commitment. Now I used to work in the Linux world along with time ago, and I remember so many folks in the community being terrified of the Mono project from Miguel de Icaza because they're convinced any day now Microsoft would sort of slap them down and say, “right. You're out. And all that work is wasted.” And Microsoft released so many statements saying, “listen. No, we think it's cool. Crack on.”
They ended up acquiring Mono, and it's still available for free. It's still looking great. They've actually open-sourced large swathes of .NET and C sharp, which is just awesome. They've gone the opposite direction. All those fears were just unfounded and ends up being a little bit paranoid, because there are doing great.
Daniel Steinberg: But VS code is just amazing. Probably when you were working with Linux, I was working for O'Reilly the book publishers. At OSCON, Microsoft would show up and say, “we're open-source.” But it was before they really had demonstrated they were. Now, they've just done a great job with it. They support multiple platforms, they're just not the Microsoft of Steve Ballmer.
Paul Hudson: I still think, I could look back at my OSCON photos and probably find you in the background somewhere and that would be so awesome. I'd love that so much, because it's a random coincidence that our lives are crossing over without realizing and then coming back full circle again.
Daniel Steinberg: That's funny.
This transcript was recorded as part of Swiftly Speaking. You can watch the full original episode on YouTube, or subscribe to the audio version on Apple Podcasts.
SAVE 50% To celebrate Black Friday, all our books and bundles are half price, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.
Link copied to your pasteboard.