Should beginners to iOS mobile game development learn Objective-C first, or is it all right for them to get started with Swift? In the Codementor Office Hours hosted by Benjamin Encz, the author of the Cocos2D and SpriteBuilder documentation, he briefly answers this question.
Picking Swift or Objective-C as a Beginner Game Dev
We are now starting to move to Swift, but I still think if you really want to get invested in game development for the iPhone, you should start with Objective-C. The main reason is Cocos2D is written with Objective-C, not to mentioncurrently all Apple frameworks are also written with Objective-C. So it is really helpful to understand Objective-C if you work with iOS.
Even if you want to call Objective-C code from Swift, if you understand both languages, it’s a lot easier to understand how you can call a certain method in Swift that is written in Objective-C.
Especially now, in the first year, there will be some rare cases where Swift will not support a certain feature, and you will probably have to fall back to the Objective-C code to actually accomplish some stuff. The third reason to learn Objective-C is that Swift has some weird cases where the performance is really poor, and sometimes people switch to Objective-C to work around this.
For the next one or two years, if you have time, start from Objective-C and pick up Swift later. If you want to start out from a small side project before you go through the rest, you can start out with Swift.
Swift vs. Objective-C: Performance Issues
I personally have not had any experiences with the speed or slowness of the Swift. There are a lot of good benchmarks out there, and most of these benchmarks tend to go in the direction where if you take an implementation in Swift, it will be much slower than Objective-C. However, if you tweak your code a little bit, you will get the speed of Objective-C.
In some ways, you have to understand the Swift layer of implementing other features, and how to get the old Objective-C speed. Generally, however, the two seem to be comparable.
Other Posts in this Series:
- 5 Best Practices for Mobile Game Development
- Handling Different Screen Sizes in Mobile Game Development
- Q&A With Author of Official Cocos2D Documentation
About Benjamin Encz
Benjamin started developing for the iOS platform in 2011 and has worked on a variety of enterprise apps to mobile games. He has written about graphics programming in WebGL, and is the author of the SpriteBuilder and Cocos2D documentation. He educates next generation of software engineers at Makeschool and also writes tutorials for them (you can also see their transcript of this office hours here.)