Lot’s of people will talk to you about Swift.They’ll talk to you about type safety, relying on the compiler and optionals.They’ll talk to you about functional patterns.They’ll talk to you about functions as first-class objects.I want to talk about the potential of Swift in learning.About using it’s clear, concise syntax to teach the concepts and practices of programming.
T H E N E E D
But why? Why teach kids to code?Learning to code does not mean funnelling every child into a job as a programmer. By the time they are adults the landscape will have changed probably beyond our imagination. The real benefit of teaching kids to code is to pass on skills that are useful in many other paths through life. Ordered thinking, problem solving, abstraction and attention to detail are general skills that benefit any occupation.
B R I D G I N G T H E G A P
Resources in schools are often limited, and it's difficult for teachers to not only maintain knowledge of technology but to also learning new technologies.Because of this, it’s essential to have ways of complimenting the current curriculum.When I heard about this after school club for teaching children to code, I really wanted to get involved.So a few months ago I went to a code club induction session, super-excited about the possibility of teaching kids to code.
W H AT I S C O D E C L U B ?W W W. C O D E C L U B . O R G
What is code club?-For children aged 9-11-Volunteer-led after-school coding club.-For one hour a week, kids get to learn to program starting with Scratch and working their way up through HTML and CSS up to Python.
After-school clubs are often the only place where children can discover what is going on behind the games they play. It's great for them because they are not forced to be there, they want to be there, it creates a different relationship for them.We are a huge, untapped, reservoir of knowledge and enthusiasm that can make a real difference.I love that we are a passionate, excited and friendly community and I think it would be amazing to leverage that excitement and pass it on to a new generation of programmers.
C O D E C L U B C U R R I C U L U M
I wanted to spend some time working on helping kids learn to code, but I couldn’t commit to running a club.I’ve been looking at the Code Club tools and examining them as a framework for how Swift could be an amazing tool for learning.Before I get into what I’ve been working on, I want to give you a brief overview of what gets covered in code club.
H T T P : / / S C R A T C H . M I T. E D U
S C R AT C H
The first two terms involves using Scratch to build programmatic structures like loops and conditions with coloured blocks and immediately see the results on the screen.It’s all drag and drop, so it really focuses on learning logic without having to also learn a language.It’s mostly targeted at simple game mechanics as a way to get children interested.
After completing Scratch, the students can move onto a term of HTML and CSS.They get to build some simple websites and learn how to style them.
P Y T H O NFinally, they get to learn Python.It builds well off of everything they’ve learned so far, but focuses on learning more about programming languages.The lessons for the first term of Python include:Printing text, catching errors, variables, data types, conditionals, loops, using libraries, collections.It provides a decently comprehensive introduction to structures and data types.I’d like to take a moment to look at the Python language and tools and why they make a good choice for learning.
W H Y P Y T H O N ?So why choose Python for learning?Simple, clear syntax: -there’s no division between primitives and objects.-no complications around pointer notation and memory management.Focuses on what-to-do not how-to-do-it.Widely available:-free to obtain and ships with most OS.Wide selection for functions like math, drawing etc..And it has a choice of interaction methods.There’s Python IDLE. This is the method of choice for Code Club.And There are also Web-based tools.So now we understand the basis for using Python, let’s take a look at Swift in comparison.
S W I F T A S A N A LT E R N AT I V E
Swift embraces most of the points that made Python a good choice: Simple syntax, focus on what over how, great library support from Foundation and UIKit, and some choices as to how to interact with it.In less than a year, Swift has become hugely popular, just imagine where it will be in 5-10 years.
A C C E S S I N G S W I F T
There are three main ways to access Swift-Xcode-REPL-Web-based tools
X C O D E
Xcode gives you access to full projects and playgrounds.Playgrounds allow you to use a huge spread of libraries and features to ‘live code’ anything from ‘Hello, world’ up to Scene Kit 3D game views.
R E P LThe closest match for the Python IDLE is the Swift REPL. This can be access by typing ‘swift’ on the command line and requires at least that the Xcode Command Line tools package be installed. The REPL allows commands to be typed and executed immediately, referencing previously typed declarations and commands. Alternatively you can pass in a Swift file at the command prompt and have it executed automatically. You can also specify command line arguments, which can be accessed via Process.arguments
W E B - B A S E D T O O L S
W W W. R U N S W I F T L A N G . C O MThere are also some great web-based resources for running Swift, like runswiftlang.com. They are restricted to using Foundation only and so you do not have access to UIKit.The big advantage of this is you can run it on any computer that has access to the internet and you don’t need to install any software or tools.
There are some challenges to overcome before Swift can be embraced as a learning tool.
E N V I R O N M E N T A N D FA C I L I T I E S
The biggest problem is schools don’t usually have Macs, schools are most likely to have PC hardware running Windows. There are usually safeguards in place to limit accessing content outside of the school network and restrictions on installing additional software on any of these machines. At the end of the day, there is a potential roadblock around either needing Mac hardware to fully engage with Swift or using Web-based tools and accepting the limitations they have.Outside of having direct access to macs or using web-based tools, there are some other options I’ve looked into.
S S H I N T O A S I N G L E M A C T O R U N R E P L
You can SSH into a mac to run the REPL.Here you’d use a single Mac with Xcode Command Line Tools installed, either added to the local network or remotely located and accessible through the firewall as a server and open up SSH sessions in a command line on any platform to access the REPL.The difficulties with this are you’d still need a Mac somewhere and you wouldn’t have access to Playgrounds.
A C C E S S I N G A M A C V I A V N C
You could also give visual access to a Mac to use Playgrounds across VNC or other Screen Sharing technology.Again, with this option you’d still need a Mac somewhere and there could be performance issues, but you would have access to Xcode, Playgrounds and REPL.
R U N O S X I N A V I R T U A L M A C H I N ERun OS X in a virtual machine. This would enable both Xcode and REPL access.But, this would require the school to keep Xcode up to date, and for their IT team to know how to use Macs. This could also have performance issues since most computers in schools are not designed to run Xcode.
C O R P O R AT E S P O N S O R S H I P
Get some corporate sponsorship to finance a small mobile mac lab.It means you don’t have to interfere with the schools hardware or network.You would still have to deal with individual schools requirements over what software is installed on the machines, how it’s monitored and who is in charge of upkeep.
L I M I TAT I O N S O N I N P U TThe REPL and Playgrounds are missing one significant feature that Python possess.And that’s an way to easily capture input from devices, commonly standard input from the keyboard. This input allows interaction with running code, and that immediate feedback is a great way of providing a reward for work when children might have a small attention span.Although REPL has access to command line arguments, this is still limited and not in real time during execution.
W H AT A B O U T W I N D O W S ?
Use your skills and imagination to build tools to make using Swift easier in other environments. Could you make playgrounds that work on Windows?Or a more full-featured web-based tool?
G O G E T I N V O LV E D
Kids need the opportunity to learn from coding, not just for the next generation of programmers but also as general life skills.Swift is an amazingly suitable language to use to help kids understand the concepts and practices of programming.The tools are still maturing and need our input and innovation to reach the ubiquity of other languages.Our community is so ideally placed to make a difference to the education and abilities of children, we owe it to them to make the effort.
H O W T O G E T I N V O LV E D
There are a number of organisations for supporting this, but these are the two I’m most familiar with:Code Club and Stemnet.
R U N A C O D E C L U B
You can run a club: you don’t have to do this on your own, in fact it’s better to get a few volunteers to run a club.There will also be a teacher with you at all times.Try to get your employer to agree to send a few people from your team, alternate between weeks if that’s easier.
H O S T A C L U B
You can also host a club.Code clubs don’t have to be in schools,they also take part in libraries and community centres.If you know a place that would work - talk to them.
V O L U N T E E R T O T E A C H T E A C H E R S
You can volunteer to teach teachers so they can better support students.Many teachers don’t have training to properly teach the new computing curriculum,help them get where they need to go.(Find out more: http://www.codeclubpro.org/become-a-trainer)
If you’re worried about commitment, or maybe terrified of children, you can contribute by making some cool new projects.
There are almost 3000 code clubs worldwide.Since it’s so global, there’s a massive need for the materials to be translated into other spoken languages,so if you speak other languages, then help them out.
S T E M N E T A M B A S S A D O R
W W W. S T E M N E T. O R G . U KThere’s also STEMNet where you can go and volunteer on a more ad-hoc basis: they do lots of career fairs and classroom talks. They also have active forums where you can help teachers and other volunteers out.They also handle getting the necessary background checks you need, and Code Club recommend going through STEMNet to get this sorted.As developers, we make magical, wonderful things, if you’ve lost that feeling - of making something magical then spend some time teaching kids, and you’ll get it back.