AndroidIOSMobile App

Apple’s Open Source Language “SWIFT” Good Ugly or Bad to Develop Android App

What is SWIFT?

Swift is a new multi-paradigm programming language used to develop iOS, OS X, watchOS and further available for developing Android apps. It is considered as much safer than C and Objective-C, the added features help in programming easier& more flexible. Swift’s clean slate is supported by Cocoa and Cocoa Touch frameworks which empower developers to preview how the software is working.

Swift uses Objective-C runtime which allows C, Objective C, C++ and Swift code to run together. It is built with the LLVM compiler framework available in Xcode 6. It is more about protocol-oriented programming which incorporates the concept of protocol extensibility that can be applied- structs and classes.

Apple introduced SWIFT at its World Wide Developer Conference. In 2015 WWDC- 2015, it was announced to be open source later that year, supporting iOS, OS X, and Linux.

Swift is considered as the future of iOS Development. Apple did enough of the groundwork to put a strong foundation for Swift by fostering their compiler, debugger, and framework infrastructure. With the implication of Automatic Reference Counting (ARC) Apple has simplified memory management.

The developers who are familiar with objective C, Swift is enjoyable for them. Empowered with dynamic object model and inherits readability mix matches interoperability of Objective-C, SWIFT provides seamless access to existing Cocoa frameworks and unifies the procedural and object-oriented portions of the language. It supports playground feature that allows developers to experiment and see the results immediately, without the overhead of building and running an app.

The compiler and language, both are optimized for performance and development, respectively without compromising on either. Swift is highly scalable, you can create a simple program for complex operating system. Having so much exciting features Swift comprise all is a fantastic way to write iOS, OS X, and watchOS apps.

SWIFT to be Used to Develop Android Apps

Apple has taken the decision to make SWIFT as an open source language. Its compiler is built on LLVM is a compiler infrastructure that leverages the concept of a retargetable compiler. Instead of generating machine code LLVM generates assembly code and then converts that intermediate representation of actual code.

llvm

Here is the process in which the Swift compilers generate LLVM-IR (intermediate representation); LLVM also generates the ARM ELF file format used for the intermediate representation. Then the Android NDK, which allows for the use of native-code languages on Android, generates a binary linking against the generated object file. The file is packaged as an Android app.

Targeting Android

The absence of SwiftCore library is the biggest hurdle in front of developers. Currently, Apple is working for the libraries for iOS, OS X and Watch OS but will they do it for Android version?

Though SwiftCore library is not required for all the Swift code in a similar way like all C++ code requires the STL. So as long as we use the subset of Swift that doesn’t hit SwiftCore. Let’s take an example:

// add.swiftfunc addTwoNumbers(first: UInt8, second: UInt8) -> UInt8 {  return first + second}

So basically the process it going to be threefold:

  1. Ask the Swift compiler to generate some LLVM-IR
  2. Use LLVM to generate ARM ELF from the intermediate representation
  3. Use the Android NDK to generate a binary that links against the generated object file

Can We Develop Cross-Platform Apps with SWIFT?

Swift gives cutting edge advantage which is forcing developers to think whether they can use this programming language to write an app once for iOS and Android simultaneously. We at Sphinx Solutions like to use a unified code-base to bring cross-platform apps for faster development. We are innovating to do the same with Swift, which will give us another great option for our customers.

Conclusion

We’re excited about SWIFT. But it is under development stage, writing code for Android for a corporate application may be time-consuming and there are chances to compromise on various exciting features of Android.  In current scenario would you want to write apps for iOS and Android using Swift? Comment below or Tweet to us.

Previous post

Quantifying ROI of Travel and Tourism Industry with Mobility and Apps

Next post

HOW TO SCALE AGILE IN OFFSHORE SOFTWARE DEVELOPMENT