about kotlin by jetbrains team

13
Kotlin A Programming Language

Upload: mobio-solutions

Post on 23-Jan-2018

121 views

Category:

Technology


3 download

TRANSCRIPT

KotlinA Programming Language

What is Kotlin

▪ Kotlin is a programming language.

▪ Kotlin is a statically-typed programming language that runs on the Java virtual machine and also can be compiled to JavaScript source code or use the LLVM compiler infrastructure.

▪ While the syntax is not compatible with Java, Kotlin is designed to interoperate with Java code and is reliant on Java code from the existing Java Class Library, such as the collections framework.

▪ Kotlin support the .kt extension.

History of Kotlin

▪ In July 2011 JetBrains unveiled Project Kotlin, a new language for the JVM, which had been under development for a year.

▪ JetBrains lead Dmitry Jemerov said that most languages did not have the features they were looking for, with the exception of Scala.

▪ Kotlin addresses most of the redundancies in Java programming language, and also new features have been added that could make application development faster and easier and most importantly lot of fun.

Why Kotlin

▪ Here, explaining important features of Kotlin which makes you easily switch to the Kotlin

▪ Java Interoperability

▪ Kotlin is 100% interoperable with Java.

▪ You can literally continue work on your old Java projects using Kotlin.

▪ All your favorite Java frameworks are still available, and whatever framework you’ll write in Kotlin is easily adopted by your stubborn Java loving friend.

▪ Familiar Syntax

▪ Its syntax is familiar to any programmer coming from the OOP domain, and can be more or less understood from the get go.

▪ There are of course some differences from Java such as the reworked constructors or the val var variable declarations.

Continue…

▪ String Interpolation

▪ It’s as if a smarter and more readable version of Java’s String.format() was built into the language.

▪ Type Inference

▪ Kotlin will infer your types wherever you feel it will improve readability:

▪ Smart Casts

▪ The Kotlin compiler tracks your logic and auto-casts types if possible, which means no more instanceof.

▪ Default Arguments

▪ No need to define several similar methods with varying arguments.

▪ Properties

▪ Custom set & get behavior can be added to public fields, which means we can stop bloating our code with mindless getters & setters.

Continue…

▪ The Data Class

▪ It’s a POJO complete with toString(), equals(), hashCode(), and copy(), and unlike in Java it won’t take up 100 lines of code.

▪ Null Safety

▪ Java is what we should call an almost statically typed language. In it, a variable of type String is not guaranteed to refer to a String— it might refer to null.

▪ Even though we are used to this, it negates the safety of static type checking, and as a result Java developers have to live in constant fear of NPEs.

▪ Kotlin resolves this by distinguishing between non-null types and nullable types.

▪ IDE Support

▪ You have a number of options if you intend to get started with Kotlin, but I highly recommend using IntelliJ which comes bundled with Kotlin—its features demonstrate the advantage of having the same people design both language and IDE.

Kotlin Support

▪ Kotlin support other platform such as Android, Java script, Web Development with Servlet, REST services etc.

▪ Android

▪ Kotlin is fully supported in Android Studio 3.0, so it's easy to create new projects with Kotlin files, add Kotlin files to your existing project, and convert Java language code to Kotlin.

▪ You can then use of all Android Studio's existing tools with your Kotlin code, such as autocomplete, lint checker, refactoring, debugging, and more.

▪ Intellij provides a nice way to work with Kotlin and Java in single project it called Java interop.

▪ https://developer.android.com/kotlin/index.html

Continue…

▪ Java Script

▪ Kotlin support a java script as well. There are multiple way to compile kotlin to javascript.

▪ The most and recommended approach is to use Gradle.

▪ For more information for project setup refer below link:

▪ http://kotlinlang.org/docs/tutorials/javascript/kotlin-to-javascript/kotlin-to-javascript.html

▪ Web Development

▪ By using Kotlin language we can develop a web application with servlet and create aREST services.

▪ For more information refer below link:

▪ http://kotlinlang.org/docs/tutorials/httpservlets.html

▪ http://kotlinlang.org/docs/tutorials/spring-boot-restful.html

Comparison between Java and Kotlin

▪ In Java some issues are there Kotlin addressed these issues and resolved it. Here are all all those issues which Kotlin has fixed:

▪ Null references are controlled by the type system.

▪ No raw types

▪ Arrays in Kotlin are invariant

▪ Kotlin has proper function types, as opposed to Java's SAM-conversions

▪ Use-site variance without wildcards

▪ Kotlin does not have checked exceptions.

What java has that Kotlin does not

▪ Checked exceptions

▪ Primitive types that are not classes

▪ Static members

▪ Non-private fields

▪ Wildcard-types

What Kotlin has that Java does not

▪ Lambda expressions + Inline functions = performance custom control structures

▪ Extension functions

▪ Null-safety

▪ Smart casts

▪ String templates

▪ Properties

▪ Primary constructors

▪ First-class delegation

▪ Type inference for variable and property types

Continue…

▪ Declaration-site variance & Type projections

▪ Range expressions

▪ Operator overloading

▪ Companion objects

▪ Data classes

▪ Separate interfaces for read-only and mutable collections

▪ Coroutines

Thank youCommunicate with us…

Mobio Solutions LLP

706/B, Ganesh Plaza, Navrangpura,

Ahmedabad - 380009, Gujarat, India

Phone: +91 79 65555706

Email: [email protected]

Web: www.mobiosolutions.com