4 Reasons to choose Swift as your Programming Language
For years Apple and iOS developers were only using Objective-C as their coding language. However, Objective-C comes with certain restrictions that are hard to get rid off and newbies and experienced programmers from different schools of languages find it difficult to grasp. But we didn’t really have another option until recently.
Apple’s much-talked-about Swift programming language has been creating a rather good reputation for itself for being a smart alternative for Objective-C.
Swift employs contemporary programming concepts and ideas from languages like Objective-C, Ruby, Python, C# and many more. At its launch, Apple software engineering VP Craig Federighi called the new language “fast, modern, and designed for safety.” It’s like “Objective-C, without the C,” he said.
What’s more, Apple just announced to open source Swift.
Swift at First Sight
For all developers using Objective-C like us, programming in Swift sounded like a completely new paradigm. Interesting but still unknown. So like all newbies in development, we wrote a “Hello World” program, our first step into the brand new programming world of iOS development using Swift. What caught our fancy right at the start was Interactive Programming through Playgrounds (REPL). Simple things like this make a developer’s life easier.
A brief for a crossword game development without hard and fast rules or mandatories was the perfect opportunity to try our hands at Swift.
While developing this app, we found a whole bunch of reasons to choose Swift over Objective-C. Here are just a few:
Easier to read and write:
Requires fewer resources:
Swift combines the Objective-C header (.h) and implementation files (.m) into a single code file (.swift) while maintaining the build-time and efficiency of Obj-C. So you can forget about toggling between files and work with the complete class code in one spot.
Swift introduces Optional Types which handles the absence of values. Quoting from apple’s reference, it basically means, either “there is a value, and it equals ‘x’ or there isn’t a value at all”. This feature not only makes the Swift programming language more expressive but is also at the core of many other significant features that Swift offers.
Swift is type-safe, meaning it helps you be clear about the type of values that the code can handle. This prevents you from accidentally passing Int to a piece of code that is expecting a String thus helping you identify and rectify errors as early as possible in the development process.
Overall, you spend less time bookkeeping and spend more time working on the app logic. But not everything in the garden is rosy; Swift still being an actively evolving language there are plenty of changes in method names as well as in the syntax with every single update and new release. So you’ve got to constantly go back to the existing code to optimise it.
Also, Swift language has decent documentation that illustrates basic syntax and some of the built-in data structures and concepts. However, anything that’s not in the reference, like some built-in data structures and methods discovered by the tech community, gets piled up in forums and has no official documentation yet.
In spite of these inconveniences, working with Swift was a refreshing experience. At Gaja Digital we find it to be a well-designed modern programming language that helps you develop with ease given you have the sufficient tooling support. And Apple making it open source is only going to better the language. The way we see it, Swift could be leading the way for the future of programming, if not, it will surely be among the most popular languages.
By Bhargava Shekar C | Senior Mobile Programmer