All Case Studies Design Development Interviews Our Way Project Management

Starting a new project for iOS? Use Apple's new language, Swift, not Objective-C

Should startups build new iOS MVP projects in Objective-C or Apple's new language, Swift? When trying to answer this question, it’s helpful to understand a little bit about the history of Objective-C and Swift.

Apple started developing Swift in 2010 and the language remained secret for four years until WWDC in June 2014. The language represents a huge shift for Apple and developers alike and leaves startups facing a new question when starting new projects targeting iOS: should new projects be developed in Swift or Objective-C?

When trying to answer this question, it’s helpful to understand a little bit about the history of Objective-C and Swift. Objective-C was built as a successor to Smalltalk in 1983. As an object-oriented language it was far ahead of its time and was adopted by NeXT after Steve Jobs left Apple in 1985.

Besides being Object-oriented which allowed for more code reuse between applications, the language also had the advantage that it could be compiled with GCC making Objective-C slightly easier to use on different hardware. This ability to compile cross-platform was important when Apple purchased NeXT and Macs were later transitioned from PPC to X86 Intel processors and yet again with the advent of iPhones and now watches.

But Objective-C’s age and the fact that it was ahead of it’s time also left the language with a quirky syntax filled with brackets, biblically long variable names, and traces of low-level C.

Sure, Objective-C code is relatively readable — certainly for a language dating back to the early 1980s, but its drawbacks make it almost universally detested by developers with a modern-languages background.

<code>- (int) doSomethingWith: anotherObject { return [anotherObject multiply: 3 by: 4]; } </code>

(taken from: Objective-C is fun)

The advent of LLVM in 2003 pioneered by Vikram Adve and Chris Latter, who would later create Swift, provided Apple with a whole new dimension in compatibility and interoperability. LLVM also made it easier to transition iOS and Mac development tools to new language: hello, Swift.

But what does all of this mean for startups considering how to be able to invest scarce resources for mobile development? Should new applications targeting iOS be developed in Swift or Objective-C?

Use Swift and don’t look back

First, unless your developers are currently coding in C or Assembly, quite simply, they’re going to hate Objective-C.

s3

Even when working with partners like us to develop and enhance mobile apps, it’s vital for a project’s long term success that stakeholders inside the organisation be able to understand the code developed. Swift, with it’s javascript, Python, and Ruby inspired syntax is a lot more fun and approachable to developers with different language backgrounds.

But isn’t the talent pool of developers writing Objective-C larger than Swift? It’s important to keep in mind that only half of learning a new development environment involves the actual language. Cocoa and more specifically Cocoa-touch have their own learning curves.

And while it probably isn’t a good idea to transition existing code to Swift or tell a project manager that you need time to learn a new language — developers familiar with Cocoa already have a head start learning how to use Swift + Cocoa to build amazing apps.

Moreover, creating well-written, team-built code isn’t about using the most advanced development trickery — it’s about writing code in a manner that can be understood and serve as a building block for amazing apps.

Taken another way, a developer with a strong grasp of Cocoa and a basic understanding Swift is probably already equipped to start developing reliable code in Swift.

Finally, the learning tools for Swift are much more engaging than Objective-C. Lattner, the author of Swift, put particular emphasis on developing interactive playgrounds where developers can try out coding in Swift. Playgrounds, he wrote,

"appeal to the next generation of programmers and ... help redefine how Computer Science is taught” (Lattner’s personal homepage).

It’s the future, ready or not

Finally, Swift is the future. I know this seems simple, but the iOS and Mac development ecosystems are tightly coupled with development tools which allows Apple to move forward relentlessly fast and with more ease than its competitors. Swift already has a whole host of language features not available in Objective-C. It won’t be long before the tools accessible from code written in Swift surpass Objective-C.

Helpful resources for common issues

A style guide is more important in Swift than Objective-C because of the language’s flexibility. While Apple, Google, and Facebook have yet to release a comprehensive style-guide for Swift, one is available here which can serve as a template for your organisation.

Code interoperability is fairly well-managed between Objective-C and Swift by importing Objective-C headers in Swift files and compiler-generated headers in Objective-C method files. Apple provides a helpful guide here.

Every day there are new blogs being started for learning Swift. Apple’s definitive guide, The Swift Programming Language is well written and easy to understand. Apple also has a blog available here and I also like the Swift Yeti and We heart Swift.

If you'd like to know more about our mobile plans, take a look at the previous post describing our mobile strategy & Middle East expansion.

New Call-to-action
Scaling SaaS
READ ALSO FROM Mobile
Read also
Need a successful project?
Estimate project or contact us