By Adam Roberts

Swift: Apple’s New Language for iOS

By Adam Roberts

At about 10am (PST) today we had a bit of an unusual traffic spike here at SitePoint HQ. A 2002 article about Swift 3D v3 quickly became our most popular article, and as I write this about six hours later it remains in the second-most clicked article today.

Those of you who have kept up with the announcements coming out of Apple’s Worldwide Developers Conference will have probably worked out why: one of the biggest things Apple announced this morning was a new programming language, Swift.


After 20 years of favoring Objective-C, Apple is now striking out on its own with a language apparently years in the making. The new language emphasizes speed (hence the name), safety and an interactive approach to development. But devs nervous about having to move wholesale into a new language can be reassured that Swift code can work alongside the old Objective-C in the same app.

A brief list of features, from Apple’s introduction to the language:

  • Swift pairs increased type safety with type inference, restricts direct access to pointers, and automatically manages memory—making it easy to create secure, stable software.
  • Swift includes optionals, generics, tuples, and other modern language features. Inspired by and improving upon Objective-C, Swift code feels natural to read and write.
  • Take advantage of powerful pattern matching in Swift to write simple, expressive code. Format strings naturally with string interpolation. Use frameworks like Foundation and UIKit directly from Swift.
  • Use playgrounds to experiment with new technologies, analyze problems, and prototype user interfaces.
  • The Swift compiler applies advanced code analysis to tune your code for performance, letting you focus on writing great apps instead of on implementing complex optimizations.

You can pick up an iBook introducing Swift from the iBookstore. If you’d prefer to get stuck into the language, you can get started by downloading the Xcode 6 beta.

What do you think of Swift? Let us know in the comments below.

  • Marvin

    Oh no, not again!

  • M S

    Hooray, a new different syntax has been invented!

  • bl4de

    I wonder why Apple do not provide HTML5 apps support in XCode :/ This is the biggest disappoitment for me after WWDC 2014

    • wideEyedPupil

      There are a few videos about developing HTML5 on the WWDC 2014 site.

      Like using Apples latest video standards for streaming which they are proposing to become adopted by HTML5 committees. And WebGL which I haven’t seen yet.

  • MikeL

    I think the developers of SWIFT, the open-source content creator, should sue the pants of Apple for copy-write infringement. …More proprietary stuff from Apple, go figure.

  • Well this is interesting. Objective C is not an enjoyable language. I’ll look forward to digging in to Swift.

  • Anthony

    Is Swift for iOS only? I thought it was also for OSX. May have misunderstood

    • Chris Ward

      I’m pretty sure it will be for all Apple platforms.

  • Karl

    You can’t sue for copyright infringement based on a name, that would infringement of a trade or service mark, and they’d have to prove passing off and/or that it causes confusion in the market place or if the content creation people have a registered trade mark in the right category then they have a case regardless :)

  • Erik

    It’s a good opportunity to start developing iOS apps.

  • 127wexfordroad

    Because Apple just can’t use technology that would permit people to work on other platforms.

  • Chris

    Overall it’s much more intuitive than Objective-C but the ! and ? symbols are either confusing me or I simply don’t understand them having never used them before.

  • marioosh

    At least!!. Currently Objective-C is friendly only for experienced C-like languages. With Swift they can attract other languages’s programmers. Syntax is modern and fit other objective-fuctionallanguages like Scala, Kotlin, Groovy or Ruby. Now it’ll be easy switch from these languages into Swift.

  • jabrantes

    Groovy like.

  • itamer

    Big corporates might be able to insist all users use the same software/hardware and therefore this will work for them. People wanting to write code for a broader userbase will look for something that works across the board. #fail

  • Ian Joyner

    The claim is that it is a modern 21st century language. In some ways yes, but disappointingly, they have not ditched a lot of C baggage that should have been. Should not Apple lead the way into languages that ditch monospaced fonts. C syntax looks terrible in other fonts so needs to be in courier or monaco or similar. C syntax looks old now so Swift also looks dated.

    However, it is not artefacts of syntax. It’s things like the auto-increment and decrement operators – known horrors from C (side effects). Why have enums and structs, when they could be unified with class? Inclusion of this stuff so as not to upset C programmers is “tasteless”. Use of CamelCase – we do have underscores on our keyboards now (CamelCase came about because Xerox did not have underscores on their keyboards – that really makes programs look dated).

    On the other hand, Python-like lists, tuples, dictionaries are nice, in fact the unification of lists and dictionaries is nicer than Python. Optional values might be nice – do they give void-safe programming though?

    And they could have done garbage collection right. It was done in Obj-C many years ago, but dropped for iOS. So programmers will still have to deal with memory issues with ARC, which is bookkeeping that programmers should not have to deal with. ARC seems to cause a whole lot of issues and is frequently discussed in programming groups.

    Lack of true GC is a disappointment. Objective-C does have it, but it was ditched for iOS. ARC still has many problems, and non-GC is a nightmare in multiprocessing environments.

    Bill Bumgarner even had the good book on GC by Boehm which I’m pretty sure went into GC in obj-C. I think it must have only be left out of Swift because GC still frightens C and C++ programmers.

    But GC is now widely deployed in Eiffel, Java (not such a good implementation), Python, Ruby, etc.

    Not having GC means Swift really can’t be counted as a modern 21st century language.

    Return should also be gone. It does too things – sets the function return value. That parts ok, but it also does a goto out of a function. In structured programming it is important for simplicity and provability that each code structure, including routines have one way in and one way out.

    Why let and var? Distinguish constant from vars by equal and assignment op. An assignment op should be a left arrow to reflect the fact that data is moving, whereas mathematical = is a static assertion.

    Swift is a move in the right direction, but overall, I’m disappointed. It’s quite a long way short of Eiffel.

    • wideEyedPupil

      swift !=== eiffel

Get the latest in Mobile, once a week, for free.