SlideShare ist ein Scribd-Unternehmen logo
1 von 25
Developer’s Viewpoint on Swift
Programming Language
Agenda
• Overview
• Requirement of New Programming Language
• Why Swift?
• Is it a Right Time to Jump into Swift?
• Summary
Overview
• Chris Lattner, is the designer/creator/maker of Swift programming
language. Previously who has built the powerful LLVM (Low Level
Virtual Machine) compiler that Apple is using with XCode to build
Objective-C programs.
• After the success of LLVM, Apple invests Chris for designing a new
programming language Swift.
Drawbacks of Objective-C
In Objective-C,
• Need to Write more lines of code for the same functionality
• Memory Management is Difficult
• Can’t implement accurate automatic garbage collection in a
language that has pointers
Why Swift Programming Language?
Easy
Constants & Variables
Defining constants or variables is simple in Swift, use “let” to
define constant and “var” to define variable.
let companyName = "XYZ"
var stockPrice = 256
Easy
Type Inference
• Don’t require to specify the type with constants and variables.
• The Compiler automatically inferred it based on the value you
have assigned.
let userName = "Eric" // inferred as String
let userAge = 28 // inferred as Int
Easy
String Interpolation & Mutability
• include value in string using () to concatenating string
let Points = 500
let output = "Jimmy today you earned (Points) points.“
• The simple way of string Mutability with swift
var message = "Good Morning"
message += "Karan"
// Output will be "Good Morning Karan"
Easy
Optional Variable & Function Return Types
• You can define possibly missing or optional value in variables,
so you don’t need to worry about nil value exception
var optionValue: Int?
• You can also make your function return type options
func getUserName(userId: Int) -> String?
Easy
Array & Dictionary
• It's easier to work with Array & Dictionary
let usersArray = ["John","Duke","Panther","Larry"] // Array
println(usersArray [0])
let totalUsers = ["male":6, "female":5] // Dictionary
println(totalUsers["male"])
Easy
For-In: Ranges
• Just use .. to make range that exclude the upper value, or use
… to include the upper value in the range.
for i in 0...3 {
println("Index Value Is (i)")
}
Modern
Switch Cases
• Now it’s possible to compare any kind of data with Switches .
You can also make conditions with Case statement.
let user = "John Deep"
switch user {
case "John":
let output = "User name is John."
case let x where x.hasSuffix("Deep"):
let output = "Surname of user is (x)."
default:
let vegetableComment = "User not found."}
Modern
Functions
• You can return multiple values from the function using tuple
func getUserList() -> (String,String,String){
return ("John","Duke","Panther")
}
• You can also pass variable number of arguments, collecting
them Into an array
Modern
func addition(values:Int...) -> Int{
var total = 0
for value in values {
total += value
}
return total
}
• You can set the default parameter value into a function
func sayHello(name: String = "Hiren"){
println("Hello (name)")
}
Modern
Enumerations
• It’s providing multiple functionalities. Like classes, now you
can also write methods
into enumerations:
enum Section: Int {
case First = 1
case Second, Third, Fourth
case Fifth
func Message() -> String {
return "You are into wrong section"
} }
Modern
Closures
• You can write Closures without a name with braces ({})
var users = ["John","Duke","Panther","Larry"]
users.sort({(a: String, b: String) -> Bool in
return a < b
})
println(users)
// Output = ["Duke", "John", "Larry", "Panther"]
Modern
Tuples
• Tuples enable you to create and pass groupings of values.
Also, allow you to return multiple values as a single compound
value.
(404, "Page Not Found", 10.5) // (Int, String, Double)
Modern
Generics
• You can make generics of any functions, classes or
enumerations when you required variety of variable types.
enum jobType<T>{
case None
case Some(T)
}
Modern
Structs
• Structs are similar to classes, but it excludes inheritance,
deinitializers and reference counting.
struct normalStructure {
func message(userName: String) -> String{
return "Hello (userName)"
}
}
Fast
Auto Memory Management
• ARC working more accurately with Swift.
• ARC track and manage your app memory usage, so you did not
require managing memory yourself.
• ARC frees up your created objects when they are no longer
needed.
• ARC automatically identify the object which you want to hold
temporarily and which for long use by reference of every
object.
Fast
LLVM Compiler
• The LLVM compiler converts Swift code into native code.
• Using LLVM, it's possible to run Swift code side-by-side with
Objective-C.
• LLVM is currently the core technology of Apple developer
tools; it helps to get the most out of iPhone, iPad and Mac
hardware.
Fast
Playgrounds
• Playgrounds make writing Swift code simple & fast.
• Playgrounds help you to view your variables into a graph, it
directly displays output of your code, and you don't require to
compile it every time.
• Playground is like a testing tool of your code. First check
output of your code with playground, when you have
perfected it, just move it into your project.
• Playground will be more useful when you are designing any
new algorithm or experimenting with some new APIs.
Is it a Right Time to Jump into Swift?
NO!
Is it a Right Time to Jump into Swift?
• Swift & XCode-6 both is currently in a beta version.
• Many issues found in XCode-6, even in default templates of
Swift. It will take 2-3 months for stable release.
• In iOS Application development, 3rd party libraries &
frameworks are used which is in Objective-C. This will take
time to convert into Swift, May be 2-3 months or more time!
• You will argue that Apple provided functionality to work Swift
code side-by-side with Objective-C, but is it worth to develop
application in Swift using Objective-C libraries?
Summary
Learning advanced & new things into IT field is
defiantly a plus point. But when its used and
applied with proper supports it will be more
beneficial to you.
Follow Us:

Weitere ähnliche Inhalte

Was ist angesagt?

The Java Script Programming Language
The  Java Script  Programming  LanguageThe  Java Script  Programming  Language
The Java Script Programming Language
zone
 
Session 2 - Objective-C basics
Session 2 - Objective-C basicsSession 2 - Objective-C basics
Session 2 - Objective-C basics
Vu Tran Lam
 
Overview of c language
Overview of c languageOverview of c language
Overview of c language
shalini392
 
JavaScript - Programming Languages course
JavaScript - Programming Languages course JavaScript - Programming Languages course
JavaScript - Programming Languages course
yoavrubin
 

Was ist angesagt? (18)

Oop2010 Scala Presentation Stal
Oop2010 Scala Presentation StalOop2010 Scala Presentation Stal
Oop2010 Scala Presentation Stal
 
Swift, swiftly
Swift, swiftlySwift, swiftly
Swift, swiftly
 
Javascript
JavascriptJavascript
Javascript
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
 
Client sidescripting javascript
Client sidescripting javascriptClient sidescripting javascript
Client sidescripting javascript
 
Ppt of c vs c#
Ppt of c vs c#Ppt of c vs c#
Ppt of c vs c#
 
The JavaScript Programming Language
The JavaScript Programming LanguageThe JavaScript Programming Language
The JavaScript Programming Language
 
The Java Script Programming Language
The  Java Script  Programming  LanguageThe  Java Script  Programming  Language
The Java Script Programming Language
 
Learn Java Part 2
Learn Java Part 2Learn Java Part 2
Learn Java Part 2
 
C#
C#C#
C#
 
Javascript Basics
Javascript BasicsJavascript Basics
Javascript Basics
 
Session 2 - Objective-C basics
Session 2 - Objective-C basicsSession 2 - Objective-C basics
Session 2 - Objective-C basics
 
Overview of c language
Overview of c languageOverview of c language
Overview of c language
 
C++ Programming Course
C++ Programming CourseC++ Programming Course
C++ Programming Course
 
16 virtual function
16 virtual function16 virtual function
16 virtual function
 
JavaScript - Programming Languages course
JavaScript - Programming Languages course JavaScript - Programming Languages course
JavaScript - Programming Languages course
 
Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++
 
DIWE - Advanced PHP Concepts
DIWE - Advanced PHP ConceptsDIWE - Advanced PHP Concepts
DIWE - Advanced PHP Concepts
 

Andere mochten auch

WSO2 ESB and SOA
WSO2 ESB and SOAWSO2 ESB and SOA
WSO2 ESB and SOA
WSO2
 
Enterprise Integration made easy with WSO2 ESB
Enterprise Integration made easy with WSO2 ESBEnterprise Integration made easy with WSO2 ESB
Enterprise Integration made easy with WSO2 ESB
WSO2
 

Andere mochten auch (20)

Overview of ESB at Azilen Tech Meetup
Overview of ESB at Azilen Tech MeetupOverview of ESB at Azilen Tech Meetup
Overview of ESB at Azilen Tech Meetup
 
Xamarin the good, the bad and the ugly
Xamarin  the good, the bad and the uglyXamarin  the good, the bad and the ugly
Xamarin the good, the bad and the ugly
 
Siddhi CEP 2nd sideshow presentation
Siddhi CEP 2nd sideshow presentationSiddhi CEP 2nd sideshow presentation
Siddhi CEP 2nd sideshow presentation
 
Siddhi CEP 1st presentation
Siddhi CEP 1st presentationSiddhi CEP 1st presentation
Siddhi CEP 1st presentation
 
Administration and Management with UltraESB
Administration and Management with UltraESBAdministration and Management with UltraESB
Administration and Management with UltraESB
 
Mule connectors
Mule connectorsMule connectors
Mule connectors
 
Debug Program in Mule
Debug Program in MuleDebug Program in Mule
Debug Program in Mule
 
ESB 4.9.0 extension points, Connectors and Inbound Endpoints
ESB 4.9.0 extension points, Connectors and Inbound Endpoints ESB 4.9.0 extension points, Connectors and Inbound Endpoints
ESB 4.9.0 extension points, Connectors and Inbound Endpoints
 
Wso2 esb
Wso2 esbWso2 esb
Wso2 esb
 
WSO2 ESB and SOA
WSO2 ESB and SOAWSO2 ESB and SOA
WSO2 ESB and SOA
 
Enterprise Integration made easy with WSO2 ESB
Enterprise Integration made easy with WSO2 ESBEnterprise Integration made easy with WSO2 ESB
Enterprise Integration made easy with WSO2 ESB
 
Systems management - UltraESB
Systems management - UltraESBSystems management - UltraESB
Systems management - UltraESB
 
Magento 2.0 - eCommerce Web Portal Solutions | Case Study
Magento 2.0 - eCommerce Web Portal Solutions | Case StudyMagento 2.0 - eCommerce Web Portal Solutions | Case Study
Magento 2.0 - eCommerce Web Portal Solutions | Case Study
 
Microintegration
MicrointegrationMicrointegration
Microintegration
 
WSO2 Gateway
WSO2 GatewayWSO2 Gateway
WSO2 Gateway
 
Deep-dive into WSO2 ESB 5.0
Deep-dive into WSO2 ESB 5.0 Deep-dive into WSO2 ESB 5.0
Deep-dive into WSO2 ESB 5.0
 
Mulesoft - Documentation (Automation)
Mulesoft - Documentation (Automation)Mulesoft - Documentation (Automation)
Mulesoft - Documentation (Automation)
 
WSO2-ESB - The backbone of Enterprise Integration
WSO2-ESB - The backbone of Enterprise IntegrationWSO2-ESB - The backbone of Enterprise Integration
WSO2-ESB - The backbone of Enterprise Integration
 
System Configuration for UltraESB
System Configuration for UltraESBSystem Configuration for UltraESB
System Configuration for UltraESB
 
Liferay (DXP) 7 Tech Meetup for Developers
Liferay (DXP) 7 Tech Meetup for DevelopersLiferay (DXP) 7 Tech Meetup for Developers
Liferay (DXP) 7 Tech Meetup for Developers
 

Ähnlich wie Developer’s viewpoint on swift programming language

Chapter-introduction about java programming
Chapter-introduction about java programmingChapter-introduction about java programming
Chapter-introduction about java programming
DrRajeshkumarPPatel
 
gdscWorkShopJavascriptintroductions.pptx
gdscWorkShopJavascriptintroductions.pptxgdscWorkShopJavascriptintroductions.pptx
gdscWorkShopJavascriptintroductions.pptx
sandeshshahapur
 

Ähnlich wie Developer’s viewpoint on swift programming language (20)

Unit 1
Unit 1Unit 1
Unit 1
 
Java-Intro.pptx
Java-Intro.pptxJava-Intro.pptx
Java-Intro.pptx
 
Java Fx
Java FxJava Fx
Java Fx
 
Lecture1_introduction to python.pptx
Lecture1_introduction to python.pptxLecture1_introduction to python.pptx
Lecture1_introduction to python.pptx
 
Core JavaScript
Core JavaScriptCore JavaScript
Core JavaScript
 
Java introduction
Java introductionJava introduction
Java introduction
 
What's coming to c# (Tel-Aviv, 2018)
What's coming to c# (Tel-Aviv, 2018)What's coming to c# (Tel-Aviv, 2018)
What's coming to c# (Tel-Aviv, 2018)
 
Scala, Play 2.0 & Cloud Foundry
Scala, Play 2.0 & Cloud FoundryScala, Play 2.0 & Cloud Foundry
Scala, Play 2.0 & Cloud Foundry
 
Scala-Ls1
Scala-Ls1Scala-Ls1
Scala-Ls1
 
Introduction Of C++
Introduction Of C++Introduction Of C++
Introduction Of C++
 
Introduction to Kotlin for Android developers
Introduction to Kotlin for Android developersIntroduction to Kotlin for Android developers
Introduction to Kotlin for Android developers
 
Should i Go there
Should i Go thereShould i Go there
Should i Go there
 
Dart programming language
Dart programming languageDart programming language
Dart programming language
 
C for Engineers
C for EngineersC for Engineers
C for Engineers
 
Chapter-introduction about java programming
Chapter-introduction about java programmingChapter-introduction about java programming
Chapter-introduction about java programming
 
Swift programming language
Swift programming languageSwift programming language
Swift programming language
 
TypeScript Overview
TypeScript OverviewTypeScript Overview
TypeScript Overview
 
gdscWorkShopJavascriptintroductions.pptx
gdscWorkShopJavascriptintroductions.pptxgdscWorkShopJavascriptintroductions.pptx
gdscWorkShopJavascriptintroductions.pptx
 
Aspdot
AspdotAspdot
Aspdot
 
Static abstract members nelle interfacce di C# 11 e dintorni di .NET 7.pptx
Static abstract members nelle interfacce di C# 11 e dintorni di .NET 7.pptxStatic abstract members nelle interfacce di C# 11 e dintorni di .NET 7.pptx
Static abstract members nelle interfacce di C# 11 e dintorni di .NET 7.pptx
 

Mehr von Azilen Technologies Pvt. Ltd.

Mehr von Azilen Technologies Pvt. Ltd. (20)

Software Product Development for Startups.pdf
Software Product Development for Startups.pdfSoftware Product Development for Startups.pdf
Software Product Development for Startups.pdf
 
How Chatbots Empower Healthcare Ecosystem?
How Chatbots Empower Healthcare Ecosystem?How Chatbots Empower Healthcare Ecosystem?
How Chatbots Empower Healthcare Ecosystem?
 
[Step by-step guide] configure document generation functionality in ms dynami...
[Step by-step guide] configure document generation functionality in ms dynami...[Step by-step guide] configure document generation functionality in ms dynami...
[Step by-step guide] configure document generation functionality in ms dynami...
 
How to overcome operational challenges in getting consistent beacon behavior
How to overcome operational challenges in getting consistent beacon behaviorHow to overcome operational challenges in getting consistent beacon behavior
How to overcome operational challenges in getting consistent beacon behavior
 
Liferay dxp – the good, the bad and the ugly
Liferay dxp – the good, the bad and the uglyLiferay dxp – the good, the bad and the ugly
Liferay dxp – the good, the bad and the ugly
 
Realm mobile platform – explore real time data synchronization capabilities
Realm mobile platform – explore real time data synchronization capabilitiesRealm mobile platform – explore real time data synchronization capabilities
Realm mobile platform – explore real time data synchronization capabilities
 
A step by step guide to develop temperature sensor io t application using ibm...
A step by step guide to develop temperature sensor io t application using ibm...A step by step guide to develop temperature sensor io t application using ibm...
A step by step guide to develop temperature sensor io t application using ibm...
 
How to create an angular 2.0 application in liferay dxp to fetch the ootb adv...
How to create an angular 2.0 application in liferay dxp to fetch the ootb adv...How to create an angular 2.0 application in liferay dxp to fetch the ootb adv...
How to create an angular 2.0 application in liferay dxp to fetch the ootb adv...
 
Register Virtual Device and analyze the device data
Register Virtual Device and analyze the device dataRegister Virtual Device and analyze the device data
Register Virtual Device and analyze the device data
 
Analytics and etl based bi solutions
Analytics and etl based bi solutionsAnalytics and etl based bi solutions
Analytics and etl based bi solutions
 
Advanced risk management &amp; mitigation system
Advanced risk management &amp; mitigation systemAdvanced risk management &amp; mitigation system
Advanced risk management &amp; mitigation system
 
Server driven user interface (sdui) – framework for i os applications!
Server driven user interface (sdui) – framework for i os applications!Server driven user interface (sdui) – framework for i os applications!
Server driven user interface (sdui) – framework for i os applications!
 
How to integrate portlet as widget in liferay to any website application
How to integrate portlet as widget in liferay to any website applicationHow to integrate portlet as widget in liferay to any website application
How to integrate portlet as widget in liferay to any website application
 
A walkthrough of recently held wwdc17
A walkthrough of recently held wwdc17A walkthrough of recently held wwdc17
A walkthrough of recently held wwdc17
 
How wearable devices are changing our lives
How wearable devices are changing our livesHow wearable devices are changing our lives
How wearable devices are changing our lives
 
iPad Application as Return Process Automation Solution for eCommerce Store
iPad Application as Return Process Automation Solution for eCommerce StoreiPad Application as Return Process Automation Solution for eCommerce Store
iPad Application as Return Process Automation Solution for eCommerce Store
 
[Part 3] automation of home appliances using raspberry pi – all set to automa...
[Part 3] automation of home appliances using raspberry pi – all set to automa...[Part 3] automation of home appliances using raspberry pi – all set to automa...
[Part 3] automation of home appliances using raspberry pi – all set to automa...
 
Rfid systems for asset management — the young technology on its winning path
Rfid systems for asset management — the young technology on its winning pathRfid systems for asset management — the young technology on its winning path
Rfid systems for asset management — the young technology on its winning path
 
[Part 2] automation of home appliances using raspberry pi – implementation of...
[Part 2] automation of home appliances using raspberry pi – implementation of...[Part 2] automation of home appliances using raspberry pi – implementation of...
[Part 2] automation of home appliances using raspberry pi – implementation of...
 
[Part 1] automation of home appliances using raspberry pi – software installa...
[Part 1] automation of home appliances using raspberry pi – software installa...[Part 1] automation of home appliances using raspberry pi – software installa...
[Part 1] automation of home appliances using raspberry pi – software installa...
 

Kürzlich hochgeladen

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Kürzlich hochgeladen (20)

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 

Developer’s viewpoint on swift programming language

  • 1. Developer’s Viewpoint on Swift Programming Language
  • 2. Agenda • Overview • Requirement of New Programming Language • Why Swift? • Is it a Right Time to Jump into Swift? • Summary
  • 3. Overview • Chris Lattner, is the designer/creator/maker of Swift programming language. Previously who has built the powerful LLVM (Low Level Virtual Machine) compiler that Apple is using with XCode to build Objective-C programs. • After the success of LLVM, Apple invests Chris for designing a new programming language Swift.
  • 4. Drawbacks of Objective-C In Objective-C, • Need to Write more lines of code for the same functionality • Memory Management is Difficult • Can’t implement accurate automatic garbage collection in a language that has pointers
  • 6. Easy Constants & Variables Defining constants or variables is simple in Swift, use “let” to define constant and “var” to define variable. let companyName = "XYZ" var stockPrice = 256
  • 7. Easy Type Inference • Don’t require to specify the type with constants and variables. • The Compiler automatically inferred it based on the value you have assigned. let userName = "Eric" // inferred as String let userAge = 28 // inferred as Int
  • 8. Easy String Interpolation & Mutability • include value in string using () to concatenating string let Points = 500 let output = "Jimmy today you earned (Points) points.“ • The simple way of string Mutability with swift var message = "Good Morning" message += "Karan" // Output will be "Good Morning Karan"
  • 9. Easy Optional Variable & Function Return Types • You can define possibly missing or optional value in variables, so you don’t need to worry about nil value exception var optionValue: Int? • You can also make your function return type options func getUserName(userId: Int) -> String?
  • 10. Easy Array & Dictionary • It's easier to work with Array & Dictionary let usersArray = ["John","Duke","Panther","Larry"] // Array println(usersArray [0]) let totalUsers = ["male":6, "female":5] // Dictionary println(totalUsers["male"])
  • 11. Easy For-In: Ranges • Just use .. to make range that exclude the upper value, or use … to include the upper value in the range. for i in 0...3 { println("Index Value Is (i)") }
  • 12. Modern Switch Cases • Now it’s possible to compare any kind of data with Switches . You can also make conditions with Case statement. let user = "John Deep" switch user { case "John": let output = "User name is John." case let x where x.hasSuffix("Deep"): let output = "Surname of user is (x)." default: let vegetableComment = "User not found."}
  • 13. Modern Functions • You can return multiple values from the function using tuple func getUserList() -> (String,String,String){ return ("John","Duke","Panther") } • You can also pass variable number of arguments, collecting them Into an array
  • 14. Modern func addition(values:Int...) -> Int{ var total = 0 for value in values { total += value } return total } • You can set the default parameter value into a function func sayHello(name: String = "Hiren"){ println("Hello (name)") }
  • 15. Modern Enumerations • It’s providing multiple functionalities. Like classes, now you can also write methods into enumerations: enum Section: Int { case First = 1 case Second, Third, Fourth case Fifth func Message() -> String { return "You are into wrong section" } }
  • 16. Modern Closures • You can write Closures without a name with braces ({}) var users = ["John","Duke","Panther","Larry"] users.sort({(a: String, b: String) -> Bool in return a < b }) println(users) // Output = ["Duke", "John", "Larry", "Panther"]
  • 17. Modern Tuples • Tuples enable you to create and pass groupings of values. Also, allow you to return multiple values as a single compound value. (404, "Page Not Found", 10.5) // (Int, String, Double)
  • 18. Modern Generics • You can make generics of any functions, classes or enumerations when you required variety of variable types. enum jobType<T>{ case None case Some(T) }
  • 19. Modern Structs • Structs are similar to classes, but it excludes inheritance, deinitializers and reference counting. struct normalStructure { func message(userName: String) -> String{ return "Hello (userName)" } }
  • 20. Fast Auto Memory Management • ARC working more accurately with Swift. • ARC track and manage your app memory usage, so you did not require managing memory yourself. • ARC frees up your created objects when they are no longer needed. • ARC automatically identify the object which you want to hold temporarily and which for long use by reference of every object.
  • 21. Fast LLVM Compiler • The LLVM compiler converts Swift code into native code. • Using LLVM, it's possible to run Swift code side-by-side with Objective-C. • LLVM is currently the core technology of Apple developer tools; it helps to get the most out of iPhone, iPad and Mac hardware.
  • 22. Fast Playgrounds • Playgrounds make writing Swift code simple & fast. • Playgrounds help you to view your variables into a graph, it directly displays output of your code, and you don't require to compile it every time. • Playground is like a testing tool of your code. First check output of your code with playground, when you have perfected it, just move it into your project. • Playground will be more useful when you are designing any new algorithm or experimenting with some new APIs.
  • 23. Is it a Right Time to Jump into Swift? NO!
  • 24. Is it a Right Time to Jump into Swift? • Swift & XCode-6 both is currently in a beta version. • Many issues found in XCode-6, even in default templates of Swift. It will take 2-3 months for stable release. • In iOS Application development, 3rd party libraries & frameworks are used which is in Objective-C. This will take time to convert into Swift, May be 2-3 months or more time! • You will argue that Apple provided functionality to work Swift code side-by-side with Objective-C, but is it worth to develop application in Swift using Objective-C libraries?
  • 25. Summary Learning advanced & new things into IT field is defiantly a plus point. But when its used and applied with proper supports it will be more beneficial to you. Follow Us: