Android Application Development
Kotlin Programming 1.
Statically typed programming language for modern multiplatform applications.
2.
Developed by JetBrains which has 20% faster compiler & better multi platform projects support.
3.
Kotlin is a new programming language that runs on JVM & can be compiled to JavaScript source code.
4.
It is fully supported programming language on Android : Android 3.0 Beta version.
5.
Google has announced official support for Kotlin Programming language for Android App Development.
Kotlin Programming Features 1. Concise Kotlin is more concise & reduces the amount of boilerplate code. For example we create a POJO with getters, setters, equals(), hashCode(), toString() and copy() in a single line. ďƒźdata class Customer(val name: String, val email: String, val company: String) 2. Interoperable Kotlin is 100% interoperable with Java language. It means you can easily call java code from Kotlin & Kotlin code from Java. ďƒźval userClass = userInstance.javaClass // From an instance
Kotlin Programming Features 3. Open Source It is an open source programming language in which source code is available to th e general public for use. Kotlin has open access to source code as The Kompiler — Kotlin compiler, Build tools — Ant and Maven integration, and IntelliJ IDEA plugin — Kotlin’s native IDE. 4. Null Safety Avoid null pointer exception or null reference exception also known as The Billion Dollar Mistake. var b: String? = "abc" b = null // ok
Why to Choose Kotlin Over Java 1. Familiar Syntax Kotlin is also designed to have learning curve for Java developers. Java developers should find that most of the Kotlin syntax feels familiar; for example, the code that's used to creat e a new class in Kotlin is very similar to Java: class MainActivity : AppCompatActivity() { 2. String Interpolation String templates are a simple and effective way of embedding values, variables, or even e xpressions inside a string without the need for pattern replacement or string concatenati on. This is called string interpolation. val x = 4 val y = 7 print("sum of $x and $y is ${x + y}") // sum of 4 and 7 is 11
Why to Choose Kotlin Over Java 3.Type Inference The compiler figure out the type of an expression from the information in the expression. A simple “VAL” is an easy case for the compiler because the type is clear from the right-ha nd side. This mechanism is called type inference. This reduces boilerplate code keeping the type safety. val a = "abc" // type inferred to String val c: Double = 0.7 // type declared explicitly 4. Smart Cast In Kotlin Programming Language - The Kotlin compiler tracks your logic and auto-casts t ypes if possible, which means no more instance of checks followed by explicit casts. if (obj is String) { print(obj.toUpperCase()) } // obj is now known to be a String
Why to Choose Kotlin Over Java 5. Intuitive Equals You can stop calling equals() explicitly, because the == operator now checks for structur al equality. val john1 = Person("John") val john2 = Person("John") john1 == john2 // true (structural equality) john1 === john2 // false (referential equality) 6. Default Arguments No need to define several similar methods with varying arguments. fun build(title: String, width: Int = 800, height: Int = 600) { Frame(title, width, height) }
Why to Choose Kotlin Over Java 7. Named Arguments Combined with default arguments, named arguments eliminates the need for builders. build("PacMan", 400, 300) // equivalent build(title = "PacMan", width = 400, height = 300) // equivalent build(width = 400, height = 300, title = "PacMan") // equivalent 8. Data Classes It’s a POJO complete with toString(), equals(), hashCode(), and copy(), and unlike in Jav a it won’t take up 100 lines of code. data class Person(val name: String, var email: String, var age: Int) val john = Person("John", "john@gmail.com", 112)
Why to Choose Kotlin Over Java 9. Operating Overloading A predefined set of operators can be overloaded to improve readability. data class Vec(val x: Float, val y: Float) { operator fun plus(v: Vec) = Vec(x + v.x, y + v.y) } val v = Vec(2f, 3f) + Vec(4f, 1f) 10.Extension Functions Kotlin provides the ability to extend a class with new functionality without having to in herit from the class or use any type of design pattern such as Decorator. This is done by special declarations called extensions. Kotlin supports extension functions & properties. fun String.replaceSpaces(): String { return this.replace(' ', '_')} val formatted = str.replaceSpaces()
Learn More About Kotlin Programming •https://kotlinlang.org/ •https://en.wikipedia.org/wiki/Kotlin_(programming_language) •https://github.com/JetBrains/kotlin •http://www.ficode.co.uk/blog/kotlin-programming-language-android-app-development/ •https://www.kotlinconf.com/
About Ficode Ficode Technologies Limited is a Web, Mobile & Software Development Company in the United Kingdom. We mainly focuses on delivering best solutions for our client as per their requirement. We have an expert team of developers who can make your idea into reality that’s why, Ficode is one of the leading mobile app development company in London. Our team is fully focused on the latest technologies as Kotlin, Java, PHP & JavaScript a lot more.
THANK YOU FOR WATCHING! CONNECT WITH US
www.ficode.co.uk