Wednesday, June 11, 2014

Apple coding with Swift - new way of coding

Swift 

Swift is innovative programming language for cocoa and cocoa touch. As per Apple website, writing code is interactive an fun, syntax is concise yet expressive, and apps run lightning fast. Swift can be even integrated to current projects since it works side by side with Objective C.

Below are few acclaimed powers of Swift language

Modern : Swift is result of latest research on programming languages, combined with decades of experience building apple platforms. 
Named parameters brought from Objective C are expressed in a clean syntax that makes APIs even easier to read and maintain
Inferred type makes code cleaner and less prone to mistakes while modules eliminate headers and provide namespaces. 
memory is managed automatically and we don't have to even type semi colons. 

var sortedStrings = sort (stringArray)
{
$0.uppercaseString < $1.uppercaseString
}

Interactive Playground
Swift also provides interactive playground where if we write a line of code, the result appear immediately. with the timeline assistance, if the code runs in a loop we can see the progress of it. This approach can be used to test out new APIs, Design a new algorithm, watching results in every step. Create new tests, verifying tests before promote the test suite app. Experiment new APIs to hone new coding skills. 

Read-Eval-Print-Loop (REPL)
The debugging console on the Xcode includes an interactive version of the swift programming language built right in. Use swift syntax to evaluate and interact with the running app or write new code to see how it works in a script like environment. This is available from Xcode console or terminal 

Switft is desgined for Safety
Swift eliminates entire class of unsafe code. Variables are always initialised before use, arrays and integers are checked for overflow, and memory is managed automatically. Simple 3 letter words define the type of the variable. for e.g. var or constant (let) 

as per the overview, swift makes nil handling super easy. It claims that adding single character makes the same effect what would have been achieved by a line of code in objective C.

Fast And Powerful
Swift uses a high performance LLVM compiler which converts the swift code to the native code, tuned to get most out of the modern Mac, iPad, iPhone hardwares. 

Swift takes best features from C and objective C. It takes low level primitives such as types, flow control, and operators. It also provides object - orientated features such as classes, protocols, and generics giving Cocoa and Cocoa touch developers performance and power they wanted. 

Switft is ready today: 
Apple claims that using Xcode 6.0, the Swift code can be included in the existing projects or new projects. When iOS 8.0 and OS X Yosemite are released this fall, developer can submit apps that use Swift to the App Store and MAC store. 


  

No comments:

Post a Comment