Swift: A Step-By-Step Guide

Rosie Allabarton, contributor to the CareerFoundry blog

Do you keep hearing about Swift? Want to know more about it? Then you’ve come to the right place!

If you’re thinking of dipping your toe into the world of web development and are casting an eye on mobile development, then this article will help you get started.

Today we’re going to give you a complete introduction to what exactly Swift is, and why it’s so important for app developers.

Not only that, but we’ll be providing info on the best places to learn as a beginner, a list of great online resources on iOS development and mobile app programming, and the low-down on what you can use this sought-after programming language for.

  1. What is Swift?
  2. Swift vs Objective-C
  3. Why you should learn Swift
  4. Where to start when learning Swift
  5. Final thoughts

1. What is Swift?

Swift is a general-purpose, multi-paradigm, compiled programming language created for iOS, OS X, watchOS, tvOS and Linux development by Apple Inc way back in 2014.

It is an alternative to the Objective-C language, which used to be the recommended and most popular language for building apps for Apple’s ecosystem of devices.

Named after the bird (which is among the fastest fliers in the animal kingdom), this language was developed to be a faster alternative to Objective-C.

Other than speed, it offers many other advantages over Objective-C, including ease of learning, safety, requires less code, is interactive, among other things.

For beginners or those completely new to the field, next I’m going to explain Swift and and Objective-C in more detail, so you know the advantages and disadvantages of each.

A Swift developer tests an image app on their smartphone.

2. Swift vs Objective-C

Compared to Objective-C, Swift has a simpler syntax that makes it easier to learn for beginners or for anyone coming from another programming language.

The language took language ideas from Objective-C, Rust, Haskell, Ruby, Python, C#, CLU, and far too many others to list. This means that programmers coming from other languages or from other platforms (such as web development) will find a lot of concepts in Swift similar to what they were used to.

It’s is also easier to read and maintain than Objective-C. In Objective-C, you have to maintain two code files for each class you write—a header file with a .h extension and an implementation file with a .m extension.

Sometimes changes made in one file affect the other, so you have to make sure to keep the files in sync. Swift, just like other programming languages like Java, C#, JavaScript, etc. manages with just one file.

Objective-C’s syntax is quite verbose. It is also quite different from other programming languages. Take the below code comparison as an example. The first two statements shows some code in Objective-C and the other two statements shows the same code in Swift.
Objective-C:

NSString *str = @”hello,”; str = [str stringByAppendingString:@” world”];

Swift:

var str = “hello,” str += “ world”

If you are coming from another programming language, you will be able to understand the second piece of code as it is similar (with slight differences here and there) to how variables are declared in other programming languages.

Even for a beginner, the second example code seems less intimidating than the first.

3. Why you should learn Swift

While still a relatively new programming language, Swift’s popularity and adoption has been increasing faster than many others. It’s now the most popular language to develop for Apple devices.

Some popular apps built using Swift include Lyft, WordPress, WhatsApp, LinkedIn, Strava, Yahoo Weather, and Firefox.

Because it was open sourced by Apple, its use has spread to include development for other platforms other than Apple devices. This is a huge step-up from Objective-C, which could only be used on a Mac OS machine. Swift was released under the Apache 2.0 license, which means developers can use it as they like—even in commercial products.

A benefit of Swift is that it can serve as both a forward-facing language as well as a server-side one.

For a product like Facebook, being a full-stack language is extremely beneficial. Apps and servers can speak to one another seamlessly, and it potentially gives the company a wider scope to write APIs for services. What’s more for those who learn it, average full-stack developer salaries among the highest around.

Like any healthy programming language this one is still evolving, and it will be interesting to see what it grows up to be and what it will be used for in the future. Since its announcement at WWDC 2014, Apple developers have continued working on it, releasing incremental versions.

In 2016 Swift 3.0 brought portability, meant to make it more portable to other platforms. Whatever the future holds, its growth and popularity has increased job demands for it. Ranking highly in the StackOverflow Developer Survey on the “Loved” list, it’s definitely a good time to consider becoming a Swift developer.

4. Where to start when learning Swift

There are numerous resources you can use when learning this language. We can’t give you an exhaustive list, but we’ll mention some resources that you might find useful.

5. Final thoughts

As this article has shown you, not only is Swift future-facing and an improvement on Objective-C in terms of iOS development, it’s also easier for beginners to learn.

As is typical with learning to code, there is a whole host of different ways to learn all about it, from online bootcamps and tutorials, to books and documentation.

What is CareerFoundry?

CareerFoundry is an online school for people looking to switch to a rewarding career in tech. Select a program, get paired with an expert mentor and tutor, and become a job-ready designer, developer, or analyst from scratch, or your money back.

Learn more about our programs