Objective C or Swift: What is the right language for your iPhone app?

As a developer, you are constantly faced with challenges when deciding which technology to use for your applications. In the mobile development space, the first challenge is determining whether to create a Web, Hybrid or Native application. If you have chosen the path of developing a Native iOS app, you have yet another decision to make: Should you program in Objective C or Swift? Apple’s announcement of the new Swift Programming Language in June 2014 has inspired many developers to learn the language. According to Programmable Web, Swift “is already nearing the top twenty programming languages” while Objective C is rated #10 on the list. There are incentives for programming in Swift and submitting your Swift app to the Apple store, which includes increased chances of getting your app featured in the App store. Developing in this language is certainly much faster than developing in Objective C. However, is Swift a reliable solution when building out your app? If you have an app, should you change the language to Swift? I took the time to learn Swift in order to understand the limitations and features of this new language. Learning Swift was as simple as learning Ruby. For new native iOS developers, Swift will certainly be a quicker way to master Native iOS development. Some high level features include an interactive environment as well as the simple style of coding compared to Objective C. Key features include:

  • The Playground, an interactive environment providing immediate results of Swift without compiling.
  • Simplified language, similar to scripting languages such as Ruby or Python. No semicolons required.
  • No need to worry about memory management, although it still utilizes some of the ARC features (Automatic Reference Counting) currently existing in Objective C.

Code To fully evaluate the language even further, I decided to interview a Swift Programming Pro and Founder of a development firm, Andrew GarkaVyi , to find out what the real story is behind Swift and what the best language would be for the developer community. 1. What is your background in Native iOS Development? Currently I am the CEO and Mobile Engineering Manager at Stafy. I have been in the software industry for over 10 years. Initially, I started developing in Java, Javascript and CSS. I then moved into the mobile space, mainly programming in Objective C. Once the Swift programming language was released, I spent a lot of time learning to see if it is going to change the software world. 2. What are the high level differences between Objective C and Swift? Except for the syntax and a lot of new paradigms, it is different inside. On the performance level, Swift is more impressive than Objective C. This is because Objective C does not allow a compiler to do a lot of optimization due to its dynamic nature. With Swift, there is much more room for optimization at compile time. Apple states that Swift is 2.6 times faster than Objective C code. Swift removes the problems that Objective C has (while introducing some other challenges). Overall, it results in much better performance. There is still a lot of debate on the web, but it’s mostly about tools and less about language – buggy IDEs and surprises due to the young age of Swift.  3. How is Objective C better than Swift? First of all, developers need to know that Swift has all of the capabilities of communicating with Objective C code. However, libraries are not the most pleasant to work with. There are some challenges to constructing the Swift code, e.g. many nested blocks to unwrap the optional values. Overall, it ends up becoming a huge tree – some call it a pyramid of doom. There are ways to overcome this, but it is still not perfect. Talking about advantages of Objective C would likely lead to discussing Swift pain points, because there is not much Objective C has that is better than Swift. 4. What are your thoughts on adding new Swift code to existing Objective C code? I haven’t heard any complaints about combining two languages. You can make calls to your existing Objective C code, but not the opposite way. Also, you will not be able to make inheritance that easily (Objective C isn’t smart about Swift). It is still a good way to start using Swift in your current project if you are ready to purely limit it to iOS 8 (there is time to think about it). 5. Should a company consider switching over to Swift for its native app solution? If you are ready to fight some early day problems of Swift - welcome on board. There are successful cases of building a commercial solution, but risks are still associated with development. For companies beyond the startup stage, Objective C would probably be the preferred and most predictable solution as it makes sense not to rush. In summary, Swift has some great capabilities and allows for easy ramp-up time for development. Here’s a comparison of the performance of these two programming languages on Stack Overflow. However, it is critical to carefully evaluate your existing project prior to making the jump from Objective C to Swift. Are you developing an innovative FinApp using Objective C code? Have you tried adding new Swift code? We’d love to hear about your experiences and help answer any questions. Feel free to contact me at jswatton@yodlee.com. Happy coding!