Title: An Overview of Kotlin Programming Language & Its Features
1Android Application Development
2 Kotlin Programming
- Statically typed programming language for modern
multiplatform applications. - Developed by JetBrains which has 20 faster
compiler better multi platform projects
support. - Kotlin is a new programming language that runs on
JVM can be compiled to JavaScript source code. - It is fully supported programming language on
Android Android 3.0 Beta version. - Google has announced official support for Kotlin
Programming language for Android App Development.
3Kotlin 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
4Kotlin Programming Features
- 3. Open Source
- It is an open source programming language in
which source code is available to the 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 Kotlins 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
5Why 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 create 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
expressions inside a string without the need for
pattern replacement or string concatenation. 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
6Why 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-hand 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 types
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
7Why to Choose Kotlin Over Java
- 5. Intuitive Equals
- You can stop calling equals() explicitly, because
the operator now checks for structural
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)
8Why 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
- Its a POJO complete with toString(), equals(),
hashCode(), and copy(), and unlike in Java it
wont take up 100 lines of code. - data class Person(val name String, var email
String, var age Int) - val john Person("John", "john_at_gmail.com", 112)
9Why 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 inherit
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()
10Learn 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-la
nguage-android-app-development/ - https//www.kotlinconf.com/
11About 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
thats 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.
12 THANK YOU FOR WATCHING!
CONNECT WITH US
www.ficode.co.uk