swift & kotlin · looking to make swift more central to their operations. google’s android...
TRANSCRIPT
![Page 1: SWIFT & KOTLIN · looking to make Swift more central to their operations. Google’s Android operating system currently supports Java as its first-class language, and sources say](https://reader034.vdocuments.mx/reader034/viewer/2022050403/5f80bb39a3e66877e93e76c2/html5/thumbnails/1.jpg)
SWIFT & KOTLIN@DagnaBieda, #IOExtendedCLT, 18th May 2016
![Page 2: SWIFT & KOTLIN · looking to make Swift more central to their operations. Google’s Android operating system currently supports Java as its first-class language, and sources say](https://reader034.vdocuments.mx/reader034/viewer/2022050403/5f80bb39a3e66877e93e76c2/html5/thumbnails/2.jpg)
Software Engineer at Quoin, 209 Delburg Street, Davidson, NC
![Page 3: SWIFT & KOTLIN · looking to make Swift more central to their operations. Google’s Android operating system currently supports Java as its first-class language, and sources say](https://reader034.vdocuments.mx/reader034/viewer/2022050403/5f80bb39a3e66877e93e76c2/html5/thumbnails/3.jpg)
![Page 4: SWIFT & KOTLIN · looking to make Swift more central to their operations. Google’s Android operating system currently supports Java as its first-class language, and sources say](https://reader034.vdocuments.mx/reader034/viewer/2022050403/5f80bb39a3e66877e93e76c2/html5/thumbnails/4.jpg)
“Sources tell The Next Web that Google is considering making Swift a “first class” language for Android, while Facebook and Uber are also looking to make Swift more central to their operations.
Google’s Android operating system currently supports Java as its first-class language, and sources say Swift is not meant to replace Java, at least initially.
-The Next Web
![Page 5: SWIFT & KOTLIN · looking to make Swift more central to their operations. Google’s Android operating system currently supports Java as its first-class language, and sources say](https://reader034.vdocuments.mx/reader034/viewer/2022050403/5f80bb39a3e66877e93e76c2/html5/thumbnails/5.jpg)
“Unfortunately, sources tell The Next Web that Google’s current mindset is that Kotlin is a bit too slow when compiling.
But, Kotlin is billed as a language that “works everywhere Java works,” and has “seamless” support for projects that mix it and Java.
-The Next Web
![Page 6: SWIFT & KOTLIN · looking to make Swift more central to their operations. Google’s Android operating system currently supports Java as its first-class language, and sources say](https://reader034.vdocuments.mx/reader034/viewer/2022050403/5f80bb39a3e66877e93e76c2/html5/thumbnails/6.jpg)
DIFFERENCES
➤ Java, JVM, GC,
➤ created by JetBrains - mostly Java devs using IntelliJ for Android know about it,
➤ requires some level of programming knowledge,
➤ JetBrains has committed to long-term backwards compatibility starting with v1.0.
➤ Obj-C, rooted in C, ARC,
➤ created by Apple, so even non-devs know about Swift,
➤ very easy to pickup,
➤ community support, massive amount of courses,
➤ Swift 3.0 won’t be backward compatible.
![Page 7: SWIFT & KOTLIN · looking to make Swift more central to their operations. Google’s Android operating system currently supports Java as its first-class language, and sources say](https://reader034.vdocuments.mx/reader034/viewer/2022050403/5f80bb39a3e66877e93e76c2/html5/thumbnails/7.jpg)
THERE ARE 800,000 NEW APP DEVELOPERS EVERY
YEAR
![Page 8: SWIFT & KOTLIN · looking to make Swift more central to their operations. Google’s Android operating system currently supports Java as its first-class language, and sources say](https://reader034.vdocuments.mx/reader034/viewer/2022050403/5f80bb39a3e66877e93e76c2/html5/thumbnails/8.jpg)
WHERE TO LEARN FROM
➤ stackoverflow.com ~92k/1k vs ~1k/63 [question/votes]
➤ youtube.com: ~124k results vs ~2.3k results
➤ udacity.com:
A. Intro to iOS App Development with Swift
B. iOS Developer Nanodegree
➤ edx.com
➤ coursera.com
![Page 9: SWIFT & KOTLIN · looking to make Swift more central to their operations. Google’s Android operating system currently supports Java as its first-class language, and sources say](https://reader034.vdocuments.mx/reader034/viewer/2022050403/5f80bb39a3e66877e93e76c2/html5/thumbnails/9.jpg)
![Page 10: SWIFT & KOTLIN · looking to make Swift more central to their operations. Google’s Android operating system currently supports Java as its first-class language, and sources say](https://reader034.vdocuments.mx/reader034/viewer/2022050403/5f80bb39a3e66877e93e76c2/html5/thumbnails/10.jpg)
![Page 11: SWIFT & KOTLIN · looking to make Swift more central to their operations. Google’s Android operating system currently supports Java as its first-class language, and sources say](https://reader034.vdocuments.mx/reader034/viewer/2022050403/5f80bb39a3e66877e93e76c2/html5/thumbnails/11.jpg)
SIMILARITIES
➤ open sourced
➤
➤ mix of good practices from multiple languages, combination of functional and objective approach,
➤ optional types, no nil as we know it, (“Null References: The Billion Dollar Mistake”)
➤ all variables must be initialized before using them,
➤ extension functions,
➤ no semicolons ;D
![Page 12: SWIFT & KOTLIN · looking to make Swift more central to their operations. Google’s Android operating system currently supports Java as its first-class language, and sources say](https://reader034.vdocuments.mx/reader034/viewer/2022050403/5f80bb39a3e66877e93e76c2/html5/thumbnails/12.jpg)
CODE EXAMPLES - OPTIONAL TYPES
let n = nil // won’t compile (type of expression is ambiguous without more context) let i: Int? = nil // the result is actually Optional<Int>.None
var b: String = “Google I/O“ b = nil // won’t compile
val n = null // won’t compile val i: Int? = null
var b: String = “Google I/O“ b = null // won’t compile
![Page 13: SWIFT & KOTLIN · looking to make Swift more central to their operations. Google’s Android operating system currently supports Java as its first-class language, and sources say](https://reader034.vdocuments.mx/reader034/viewer/2022050403/5f80bb39a3e66877e93e76c2/html5/thumbnails/13.jpg)
CODE EXAMPLES - OPTIONAL TYPES
class Department { func description() -> String {
return “Name” }
}
class Employee { let department: Department? = nil }
let sara: Employee? = Employee()
sara?.department?.description() sara!.department?.description() sara!.department!.description() // !
// implicitly unwrapped values if let department = sara?.department { print(department.description()) }
class Department { fun description() = “Name” }
class Employee { let department: Department? = null
}
val sara: Employee? = Employee()
sara?.department?.description() sara!!.department?.description() sara!!.department!!.description() // !
// implicitly unwrapped values if (sara != null && sara.department != null){ println(sara.department.description()) }
![Page 14: SWIFT & KOTLIN · looking to make Swift more central to their operations. Google’s Android operating system currently supports Java as its first-class language, and sources say](https://reader034.vdocuments.mx/reader034/viewer/2022050403/5f80bb39a3e66877e93e76c2/html5/thumbnails/14.jpg)
CODE EXAMPLES - EXTENSIONS
extension UIColor { class var random: UIColor { switch random()%6 { case 0: return UIColor.greenColor() case 1: return UIColor.blueColor() case 2: return UIColor.yellowColor() case 3: return UIColor.redColor() case 4: return UIColor.purpleColor() default: return UIColor.blackColor() } } }
var Color.random: Color get() = when (Math.random().nextInt(6)) { 0 -> Color.GREEN 1 -> Color.BLUE 2 -> Color.YELLOW 3 -> Color.RED 4 -> Color.MAGENTA else -> { Color.BLACK }
} // https://kotlinlang.org/docs/reference/extensions.html
![Page 15: SWIFT & KOTLIN · looking to make Swift more central to their operations. Google’s Android operating system currently supports Java as its first-class language, and sources say](https://reader034.vdocuments.mx/reader034/viewer/2022050403/5f80bb39a3e66877e93e76c2/html5/thumbnails/15.jpg)
CODE EXAMPLES - FUNCTIONAL
func prepareStudentMessages(tutor: Tutor, on date: NSDate) {
let matchIdAndSelectedDate = { (m: Message) -> Bool in return m.tutorId == tutor.id && m.date ~= date }
for message in messages.filter(matchIdAndSelectedDate) { let view = MessageView(message: message) view.origin = calculateTimelineOffset(message.date) // ... } }
fun prepareStudentMessages(tutor: Tutor, date: NSDate) {
val matchIdAndSelectedDate = { m: Message -> m.tutorId == tutor.id && m.date.sameDayAs(date)
}
for (message in messages.filter(matchIdAndSelectedDate)) { val view = MessageView(message: message) view.origin = calculateTimelineOffset(message.date) // ... } }
![Page 16: SWIFT & KOTLIN · looking to make Swift more central to their operations. Google’s Android operating system currently supports Java as its first-class language, and sources say](https://reader034.vdocuments.mx/reader034/viewer/2022050403/5f80bb39a3e66877e93e76c2/html5/thumbnails/16.jpg)
![Page 17: SWIFT & KOTLIN · looking to make Swift more central to their operations. Google’s Android operating system currently supports Java as its first-class language, and sources say](https://reader034.vdocuments.mx/reader034/viewer/2022050403/5f80bb39a3e66877e93e76c2/html5/thumbnails/17.jpg)
USER BASE VS CODE BASE
![Page 18: SWIFT & KOTLIN · looking to make Swift more central to their operations. Google’s Android operating system currently supports Java as its first-class language, and sources say](https://reader034.vdocuments.mx/reader034/viewer/2022050403/5f80bb39a3e66877e93e76c2/html5/thumbnails/18.jpg)
THANK YOU!
#ifdef greatPresentation
#include ”standing-ovation.hpp”
#endif