Swift lessons

Learning Swift programming isn’t easy, but I must admit the language has stuck with me far more than any other attempts I’ve made to learn programming languages in the past. I credit much of that to the 100 Days Of Swift schedule that I mentioned last time – a brilliantly structured path that gives you code snippets to learn, example apps, and challenges to keep practicing.

With that in mind, here are five things I’ve uncovered so far in my journey.

  1. Practice with challenges. Learning the various Swift fundamentals is good and working through tutorials is a vital part of moving forward. But I’ve found the key to really reinforcing the lessons is the call to add functionality to your practice apps without guidance. In the 100 Days of Swift, every app we’ve made comes with three additional challenges, and then every few days there’s a bigger task of creating an app from scratch. Using your head, thinking about how best to achieve something, that’s some of the most important work in coding.
  2. It’s also worth mentioning that you don’t have to learn everything off by heart. You just need to understand what you’re doing and build up a library of code that you can refer back to. As with most learning these days, it’s not about being word perfect, it’s about knowing what to search for and where to look. Copy and paste that code all you like, as long as you know what it’s doing and how to tweak it for your current project.
  3. Don’t be scared of the documentation. If I’m honest, I still actually am quite scared of the documentation, but the few times I’ve dived in there and had a look, I can see it is really well done, very useful, lots of details. I’m probably not at the level where this is a regular feature of my studies, but I’m still impressed with what I’ve seen.
  4. Try not to get carried away. At the moment I’m limited to Swift practice at the weekends, which means when I do sit down to open up Xcode, I want to do ALL THE THINGS. And then suddenly it’s late and you’ve had some wine and your brain is fried. It’s easy to get carried away, and I can’t pretend that I’ve got this under control yet, but it’s quite important not to get burnt out.
  5. Try not to get carried away, part 2. Once you reach a point where you’ve made a couple of apps that work, and when you go to set up a new project, you know the early stages off by heart, you start to think you can take on the world. You can, of course, but not all in one go. My app ideas aren’t going to revolutionise the world but already I want to make this to do this, and that to do that and another one to do something else. It’s quite hard to remember that I’m still very new at this, I’ve only really got the basics down, and that building apps takes time, effort and work. Becoming the next app millionaire isn’t something that happens overnight!

Here’s a video from another fabulous iOS engineer and Swift advocate, Sean Allen, who covers 9 things he recommends for newbies – some of which I’ve mentioned above but others I hadn’t even thought of.

Speaking my language

My Swift journey so far has been stop/start in nature, but recently it has become one of those hobbies that occupies a significant portion of my mind, one that I think about a solid 90% of the day. That’s good, really, because it’s a useful skill, coding, and one I am still very much at the early stages of grappling with.

I’m never quite sure how much detail to go into here, really, because is it interesting to read about someone else learning how to code? I don’t know. What I am confident in, though, is sharing the resources that are helping me along the way.

My current focus is on the really quite excellent 100 Days of Swift from Paul Hudson over at Hacking with Swift. Each day there’s some new stuff to learn or try out, with reviews and tests and even a bonus wordsearch to reinforce what you’ve learned. The structure of the course really helps to give you something to grab on to and stick with, and that’s what I’m aiming to do. 18 days and counting! I really recommend checking it out if you’ve ever wondered about diving into Swift.

If you’re still not convinced, then Paul has previously created the best video I’ve seen about programming – combining both my relatively new loves of Star Wars and Swift to convey what is actually a really good message for programmers and non-programmers alike. Sure, there’s a bit of nerdy stuff in the middle, but the first third about change and the final third about community really applies to everyone.

I hadn’t realised the diversity issue at the top of the Swift org chart, but it’s definitely something that could do with being addressed. The more people coding, the better, and the more people coding, the more representation and diverse opinions we’re going to need and hopefully going to get.

I’m under no illusions that I can influence anyone in the Swift world or get anywhere even near the org chart, certainly not at the slow pace I’m going. But hey, it’s about spreading the word and championing those that are doing the same, and I hope to learn and share a lot more about the people doing good in this arena.

Here’s to life-long learning!

If you want a job doing right…

I had to put my ‘learn Swift’ project on the backburner for the last few weeks but I’m catching up again now we have a few festive days of freedom. That’s what most people do, right? Spend Christmas afternoon digesting mince pies and learning how to code?

Last time I wrote about finishing up the first course on Ray Wenderlich’s iOS path and moving on to the second which was more about Swift. I’ll admit, I found that one a touch harder than I was expecting – some of the concepts seemed a bit unnecessary for this stage in the course (still being a total beginner), and they also used not-so-simple maths concepts as a way to demonstrate some of the coding tricks. It was hard to relate, so I had to keep stopping and pausing and thinking about what it would mean if I was making my own app.

Thankfully, the fact that I could see the issues with what I was learning actually gave me confidence that I’m getting a good grounding in the Swift language. And I have to keep remembering that it’s not about retaining all the information first time through. It’s about knowing what is possible and being able to reference back to it when you need it.

So, now I’m on the third course wherein we are building a to do list app. The number of times have I written about to do list apps hoping that I’ve found the new one that will fix all my problems and inevitably failing to keep up the habit of using it! Now, I’m writing my own! Okay, it’s a pretty simple app with limited features, but it brings to life the concept of having a problem in your own life and fixing it.

How many times do you hear the story of app developers coming up with ideas just because they had a need in their own life? Now I’m starting to think about what things could work more smoothly in my life and what kind of app I could make to help. There are a lot of apps out there covering all manner of topics and genres, but hey, there’s always room for one more, right?

Finding the right path

Earlier this year, I worked my way through Swift Playgrounds – Apple’s easy-to-use educational tool to teach you the basics of the Swift language – and to celebrate, purchased a quite adorable R2D2 that you can program with that self-same language. Unfortunately, I couldn’t quite make the leap in my head from the playgrounds I had been messing about with to the more tangible efforts with a toy, and the instructions that came with that little droid were a bit more advanced than I was.

So I’ve been pondering what the next step is and that’s when Mr C suggested having a look at the courses on Ray Wenderlich’s site. The site has an iOS learning path that starts with building an app. It throws you right in at the deep end, opening up XCode and within minutes having an app that does something, however small.

I followed that first course from start to finish, and I loved it. It’s got the right mix of introducing the basics, guiding you through the more advanced sections and glossing over what you don’t need to know yet, so that you can still get the hands on feeling of making an actual product.

Unlike the playgrounds (which I still enjoyed, don’t get me wrong), you really have a sense of working towards something which makes it that much easier to join the dots in your head and solidify the learning.

I have finished the course now and have a fully-formed app that is actually a fun game. I’m not planning to submit this to the App Store considering it’s not my invention (although a quick search of the store suggests many people have), but I am diving straight into the next course on the Ray Wenderlich path to greatness – that’s what I’m calling it anyway.

The next course is more about the Swift programming language, so back to the slightly more abstract again, but I have faith that having achieved what I have so far, learning the language this time will be more meaningful. I also know that the third course on the list gets you building another app, this time a To Do app. Goodness knows I have experience of those, so I cannot wait!

That little droid

In my adventures with Swift programming, I mentioned the R2-D2 toy/gadget that you can bring home and programme yourself. When I wrote about it, it was a delicious want rather than a need, but somehow over the course of a sunny few days off, I ended up with the very same Artoo bluetoothing himself to my iPad.

I’ve only been playing for a little while but first impressions are: This is the cutest thing ever! It bleeps and bloops, the tripod wheel comes in and out and it whizzes around making that scream noise that R2-D2 is so famous for. You can control it via a Sphero app, which makes it more of a remote control style toy, or you can actually sit down and programme it.

The Sphero team have created a Swift Playgrounds book to guide you through an adventure with R2, but I find it slightly more advanced from where I am, and the teaching is somewhat lacking. It’s more encouraging of a “just keep trying and see what happens, and we’ll give you hints as we go” rather than teaching you what on earth you’re supposed to be doing in the first place.

Apparently, you can also get these app-enabled droids to react when you play any of the Star Wars movies. I haven’t managed to get that functioning yet, but I’m also not sure that’s a bad thing. Apparently if you have more than one, they will actually interact with each other while the feature film plays out. That seems a sure fire way of never getting anything done again.

But no matter. R2 is cute, and I love it, and it’s a motivational tool to keep learning, because programming the little droid to spin his dome left and right and keep scanning for stormtroopers seems like the kind of business that could save the entire galaxy. Am I right?

Swift progress

So, I mentioned Swift Playgrounds recently and thought I would share more of my experience with the app. I tweeted a summary that basically covered my history with trying to learn Swift.

I have tried, several times, to engage with this app. It’s totally up my street, after all – learning new things, in a fun and engaging way that is more like a game than an education. Getting ticks after completing each chapter helps too, I do love a good checklist.

But, up until now, I have always got stuck at the same point, to do with looping, and I would give up. This year, for whatever reason, I managed to push on through past that sticky point and have not only finished the first playgrounds book but also the second.

It’s really a very fun way of learning a new language, intuitive and helpful. If you do get stuck there are videos and further reading materials to help you out. And of course the entirety of the coding world to help you, or a Mr C if you happen to have one of those to hand.

The lessons start off really simply where you’re just asking a character to move forward, turn right, pick up gems. Things progress slowly to start with, to give you confidence, and then ramp up quite quickly to the point you are routinely employing ifs, fors and arrays.

There are a few areas where it doesn’t quite explain the fundamentals behind what’s going on which have seen me come unstuck a little, but this year’s  perseverance has allowed me to push on through, rather than giving up for another twelve months.

Having completed the main two courses, I’m now exploring the “further learning” options and boy are they interesting. There’s a Learn to Code 3, many game based books (Rock Paper Scissors being just one of them), and to progress even further, the enticing world of Sphero, Lego and other physical objects. I mean, how can I not?

So, as I said in the tweet, watch this space. I have zero ideas for apps and I’m not a coder, but I’m doing it anyway and enjoying the ride.

Rock, paper, scissors… you know the rest

I’m currently working my way through the various options for learning how to code via Swift Playgrounds, and branched out recently to the standalone session that lets you adapt a version of the well known game Rock Paper Scissors.

The demo first lets you play the game so you can see how it works, then it asks you to personalise the game with a variety of options. I think it wants you to pick the colours that each player uses and perhaps adjust the hue of the background, but I went for a slightly more ambitious personalisation scheme.

Rock Paper Scissors Lizard Spock. Sheldon would be proud.