Swift in your Production apps

The Short version of this article, if you want to read the summary - Swift is now production ready for most applications

My current impressions about Mobile Development

I have had the change to meet up with several development companies that have a name and a brand associated with it. These are the companies that develop applications for you on a turnkey / hourly basis. The clients that they service are usually the big businesses where the charges for a single consultation can be more than the cost many free lancers charge for the entire project.

Choice of Language

The two options available to iOS developers are either Objective-C or Swift. Apart from the fact that many of the Objective-C developers have not been able to get their heads around Swift (which is strange, because it is quite easy and forgiving, the compiler isn't - there by resolving many simple overlooked errors). The other reason is that while they want to use Swift, they are unable to use it in a combination (it is painful integrating both Swift and Objective-C in the same project) or worse still, using Swift could mean refactoring their code to Swift.

Advantages of using Swift

There are several advantages of using Swift, however the common few are discussed here.

1. Easy and relaxed syntax as compared to a strict structured syntax
2. More compact code within a single file (even with a badly written code structure / architecture)
3. The Categories (Objective-C) provide more powerful features with extensions (Swift)
4. Protocols and protocol extensions make an application written in Swift more modular and compact
5. Swift code can be modular and extensible, adding features via extensions to the existing classes and sub-classes.
6. Closures(Swift) are easier to use than Blocks (Objective-C)
7. You can have complex functions with amazingly complex signatures
8. Global imports, Swift functions and variables are available through out the application.

And this is just scratching the surface, this article is more of a beginners introduction to Swift, the advance features available with Swift are even more awesome and amazing. For future articles where we talk about the other features.

The issues

Like everything each technology has its own share of pros and cons. Some of them are faced by developers that were trying to use Reactive Cocoa or Functional programming with Objective-C and now apply the same 1-on-1 with Swift. The other issue is trying to get somethings done via Objective-C and others via Swift. From one codebase that I have recently seen, it is a big mess. There are several hundred files. For each and every little structure there is a new file. Given that it is Objective-C codebase, each .m file has a corresponding .h file. In swift I could have the Enums, Struct and the class in the same file (as they relate to each other) and work with them.

Summary

If you look at the Source Code released by Apple, most of the new code is written in Swift. However the advance samples that work with Metal and other technologies (usually written by low level/assembly type developers) prefer the use of C/C++ type languages to get the maximum performance.

Unless you are writing an app that is critical and relies on those mili-seconds you are fine with Swift and it has everything that you need for a fast turn around. It is nearly time when Swift will be open-sourced, so it would be exciting times.

If you are a Developer or a Team Leader, you can consider Swift, it is safe for use in a production environment and can provide faster and more efficient outputs.

Comments

Popular Posts