Deep Dive

Swift Programming Language Crash Course

With the iPhone 6 announcement today, it’s the perfect time to talk about Swift and it’s impact on you as a developer or entrepreneur.

SO WHAT IS SWIFT?

Swift is a brand new programming language from Apple that you can use to build iOS and Mac apps with. It’s a modern language influenced by pretty much every other language out there. You can pinpoint features that come from Python, Ruby, C#, and others. That means Apple has spent a lot of time thinking about what impact these features will have upon developer productivity and happiness.

HOW IS IT DIFFERENT THAN OBJECTIVE-C?

You may not realize it, but Objective-C originally came out in 1983. That’s a very long time ago when it comes to computers.

For those of you who may not be familiar with it, Objective-C is essentially the C language with a slightly different syntax and an object oriented layer on top. It requires you to do a lot of manual work. For example, in most modern languages you can do something simple like this:

// What I wish we could do in Objective-C
NSString *first = “Chris”;
NSString *fullname = first + " Oliver”;

Instead, in Objective-C you’ve got to use a long-winded method to help you:

// Objective-C
NSString *first = @"Chris";
NSString *name = [NSString stringWithFormat:@"%@ Oliver", first];

The first example is far cleaner to read than the second Objective-C example.

With Swift, you’re able to do this:

// Swift
let first =Chrisvar name = first + Oliver// name now equals “Chris Oliver”

That’s a whole lot cleaner than both the previous examples! Swift even knows to interpret the variables as strings without us having to declare it.

IN COMES SWIFT

Many people have ideas for mobile apps these days. The problem is those ideas never get implemented after inception because you either need to hire an iOS developer or teach yourself Objective-C which is quite the commitment.

Apple knows that the barrier to entry of becoming an iOS developer has been fairly high. A modern language would solve a lot of these problems and make it a lot easier to build apps. So that’s exactly what they did with Swift.

At first glance, Swift looks awesome. Just look at the screenshot on the homepage:

https://developers.apple.com/swift

Are there no more semicolons? None! (Unless you want to for some crazy reason.)

Is that a simulator on the right side? Yes!!

Are they showing me a preview of my code in the sidebar? Yep! How cool is that?!

If you’re really interested in where some of these ideas came from, give Bret Victor’s Inventing on Principle a watch.

WILL IT BE AS GOOD AS THE HYPE?

Swift sounds really cool and a lot of people are talking about it but is it really going to be as good as the hype?

The short answer is yes.

Software is becoming an increasingly diverse industry. Phones and tablets are now entering almost every market imaginable. These devices are so helpful that everyone wants to figure out how to use them to make their lives easier.

This influx of interest in programming means that there are millions of people learning for the very first time. On the web, you can pick up Ruby on Rails very quickly but mobile has always been quite a bit harder. Swift aims to change that and provide a friendly language that can do everything Objective-C can with a much nicer syntax and feature set.

IT WILL BE WELL SUPPORTED

Apple isn’t generally a company to release something publicly and then abandon it. Swift has so much backing that it’s bound to grow extremely quickly. It can even work hand-in-hand with Objective-C code so you can start using it right away even.

I haven’t seen this much discussion about a new programming language for a while. Hacker News had a gigantic conversation thread with a lot of interesting insights into the language.

THE FUTURE OF SWIFT LOOKS VERY PROMISING

I’m sure you’ve noticed the trend of iOS-first releases for mobile apps over the past few years. Apple is aiming for Swift to help continue that trend. Everything seems poised for the language to be a huge hit as developers are incredibly excited with it. Someone even built a Flappy Bird clone in Swift after spending just 4 hours learning the language. Now that’s awesome!

Build an iPhone app using Swift →

Tags: Swift, iOS

Chris Oliver

Chris Oliver

Chris is our development wizard, affectionately known as a human swiss army knife. He does web development using Ruby on Rails and Javascript. His programming career started in the seventh grade, building open source software, spending a summer participating in Google Summer of Code, and eventually getting into web development with Python and Ruby on Rails. He’s the founder of GoRails.com and the creator of Launch Code and he joined the One Month team when we acquired GoRails (and Chris)!

Connect:
YOU MIGHT ALSO LIKE...