|< If you were starting from scratch today, what would you do differently?||What’s the best way of learning Swift programming? >|
Recorded – watch the full episode on YouTube.
What is it you think makes Swift a great choice for someone’s first programming language?
Chris Lattner: I think there's a combination of two things. First, Swift is very easy to get in the door. So it's designed to be like Python and like other lightweight scripting languages, very easy to start from. Just
print("Hello world"), right? And so we put a lot of work into making it so that
print("Hello world") does not include a
\n, does not include semi-colons, doesn't include a main, etc; there's a lot of boilerplate that you see for more traditional compiled languages that just does not exist. So I think that accessibility to get started and the familiarity that a lot of the ideas and a lot of the syntax, even in Swift, it's very similar to other languages. And so Swift is a very transferrable skill in that respect.
"With Swift, you can start out very easy. You can use prebuilt APIs, very high-level APIs that are produced by experts. And then over time, as you learn more things, as you look at more code, as you get exposed to new things, you can learn as you go."
I think the biggest and most important thing about Swift though is that it's real. There's a lot of teaching languages that are not real. So you know everything from Logo to block-based programming – it is a very different mental model from what "real programmers," whatever that means, actually do. But also you hit that ceiling. And so with Swift, you can start out very easy. You can use prebuilt APIs, very high-level APIs that are produced by experts. And then over time, as you learn more things, as you look at more code, as you get exposed to new things, you can learn as you go.
And one of the things that I personally love as a human and I think that many people do is that feeling of growth, where you have that “aha!” moment where you learn a new thing. And one of the most frustrating things is when you feel like you're just like bashing your head into a wall and it's like I'm not smart enough to understand this and I just can't get it. Often that happens because you're trying to jump into things by taking too big of a step at a time.
"You don't have one of these nonlinear steps where you have to switch to a completely different world and I think that is one of the biggest features of Swift is that you don't get trapped in that way."
It's not that you can't understand it. It's just that there are smaller steps in between that would help you get there. A lot of the design of Swift was really set up such that there can be smaller steps. You can learn different pieces along the way. You can start out by just composing different APIs from other people and then as you start going from assembly, you can start going deeper and deeper into design.
You can go deeper into architecture and you can then go all the way down to writing systems programs or whatever, wherever your path takes you. But you don't have one of these nonlinear steps where you have to switch to a completely different world and I think that is one of the biggest features of Swift is that you don't get trapped in that way.
Paul Hudson: I remember years ago I was invited to give a lecture to a local girls' school and it was a lot of 17 year olds who were just finishing the last year of school, about to go to university. It was mostly about what life would be like as a programmer, but afterwards one of them came up to me and said, "I liked the talk very much, but I want to get into programming more and I've been doing all this Scratch stuff and I want to do programming with words." That was how she described it. I thought it was a quite startling thing to say because she was very aware that there was a Blockly which exists or Scratch or similar where you drag blocks around.
"Swift Playgrounds app is that it is almost useless when they can't read and so there is this threshold of being able to read that is an accessibility barrier, particularly when you're talking about a kindergartener."
That's very powerful and my kids love doing Blockly and Scratch but there's a bit of a leap from there to typing things in, whether it's Python, Ruby, Swift, C++, it doesn't really matter. It felt like it was different. And what Swift does I think very well and certainly the Playgrounds project does very well is it removes that barrier entirely. You can control a little on-screen character to move forward and collect gems, or whatever the task is, but then you start writing your own code and it is that whole progressive disclosure thing and you don't feel that jump – it goes away. It becomes a nice blend slowly step by step to get where you want to be which is an amazing difference.
Chris Lattner: One of the things that I've seen with my kids with the Swift Playgrounds app is that it is almost useless when they can't read and so there is this threshold of being able to read that is an accessibility barrier, particularly when you're talking about a kindergartner that is just getting there. And so I think that there's a huge place for block-based programming.
"One of the things that I always want to see in the Swift Playgrounds app is a block-based programming environment that's continuous with words."
I think that a lot of the things done in the Scratch and these kinds of ecosystems is really valuable. The problem with that though is that often because they're different systems, they are created as entirely different universes. They have different standard libraries and different programming methodologies. It's not just about being graphical – it's about being graphical and different. And so one of the things that I always want to see in the Swift Playgrounds app is a block-based programming environment that's continuous with words as you would say.
And so you could have it so that you started out with a basic set which is more block-based. You can still snap things together. It's very visual. You don't need as much reading cognition but then you're still using bite move forward or turnaround, you're keeping the standard library consistent so that then you can make leap into words and you can have consistency across it. Again, this is reducing the size of the step.
"I like to think about these systems as like if you take the big ideas and you blend them together in a new way, what can you get? And I think Swift in general is like that."
And I think that would be a really interesting way to take the curriculum and the Playgrounds app and take it down to a lower or a younger set of people or people that have other reading challenges.
So, anyways, a lot of times when I look at these systems I see there are really important premises that people anchor on. So it's block-based. But then there's a whole bunch of other ancillary decisions that are surrounding them. I like to think about these systems as like if you take the big ideas and you blend them together in a new way, what can you get? And I think Swift in general is like that: it doesn't have a lot of novel ideas in it. It's a fusion of a lot of preexisting good ideas that are blended together in a unique way.
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.
SPONSORED ViRE offers discoverable way of working with regex. It provides really readable regex experience, code complete & cheat sheet, unit tests, powerful replace system, step-by-step search & replace, regex visual scheme, regex history & playground. ViRE is available on Mac & iPad.
Link copied to your pasteboard.