Kotlin is a statically-typed programming language that runs on the Java Virtual
Machine and also can be compiled to JavaScript source code or uses the LLVM compiler infrastructure. Its primary development is
from a team of JetBrains programmers
based in Saint Petersburg.
The name comes from Kotlin Island, near St.
Petersburg. Andrey Breslav mentioned
that the team decided to name it after an island just like Java was named after
the Indonesian island of Java.
Google
just announced that it will officially support Kotlin on Android as a “first-class”
language.
Kotlin tools will be included with Android Studio 3.0 by
default, and JetBrains and Google are pledging to support the language going
forward. Kotlin as a language has a lot of similarities to Java in
structure — it's object oriented and statically typed, and designed for
similar problems Java solves. But because it's a clean slate in many ways,
Kotlin adds a lot of nice-to-have features, a much cleaner syntax, ideas from
functional programming, and other enhancements over Java.
Using Kotlin for Android Development
Kotlin is a great fit for developing Android
applications, bringing all of the advantages of a modern language to the
Android platform without introducing any new restrictions:
·
Compatibility: Kotlin is fully compatible with JDK 6,
ensuring that Kotlin applications can run on older Android devices with no
issues. The Kotlin tooling is fully supported in Android Studio and compatible
with the Android build system.
·
Performance: A Kotlin application runs as fast as an
equivalent Java one, thanks to very similar bytecode structure. With Kotlin's
support for inline functions, code using lambdas often runs even faster than
the same code written in Java.
·
Interoperability: Kotlin is 100% interoperable with Java,
allowing using all existing Android libraries in a Kotlin application. This
includes annotation processing, so databinding and Dagger work too.
·
Footprint: Kotlin has a very compact runtime library,
which can be further reduced through the use of ProGuard. In a real
application, the Kotlin runtime adds only a few hundred methods and less than
100K to the size of the .apk file.
·
CompilationTime: Kotlin
supports efficient incremental compilation, so while there's some additional
overhead for clean builds, incremental builds are usually as fast or
faster than with Java.
·
Learning
Curve: For a Java
developer, getting started with Kotlin is very easy. The automated Java to
Kotlin converter included in the Kotlin plugin helps with the first
steps. Kotlin Koans offer a guide through the key features of the
language with a series of interactive exercises.
Packages
A source file may start with a package declaration:
packagefoo
.
bar
funbaz
() {}
classGoo
{}
// ...
All the contents (such as classes and functions) of the source
file are contained by the package declared. So, in the example above, the full
name of
baz()
is foo.bar.baz
,
and the full name of Goo
is foo.bar.Goo
.
If the package is not specified, the contents of such a file
belong to "default" package that has no name.
A number of packages
are imported into every Kotlin file by default:
·
kotlin.*
·
kotlin.annotation.*
·
kotlin.collections.*
·
kotlin.comparisons.* (since 1.1)
·
kotlin.io.*
·
kotlin.ranges.*
·
kotlin.sequences.*
·
kotlin.text.*
Additional packages
are imported depending on the target platform:
·
JVM:
o java.lang.*
o kotlin.jvm.*
·
JS:
o kotlin.js.*
The Kotlin Standard
Library provides living essentials for everyday work with Kotlin. These
include:
·
Higher-order functions
implementing idiomatic patterns (let, apply, use, synchronized, etc).
·
Extension functions
providing querying operations for collections (eager) and sequences (lazy).
·
Various utilities for
working with strings and char sequences.
·
Extensions for JDK
classes making it convenient to work with files, IO, and threading
Packages
kotlin
|
Core functions and types,
available on all supported platforms.
|
kotlin.annotation
|
Library support for the Kotlin
annotation facility.
|
kotlin.browser
JS
|
Access to top-level properties (
document , window etc.)
in the browser environment. |
kotlin.collections
|
Collection types, such as Iterable, Collection, List, Set, Map and related top-level and extension functions.
|
kotlin.comparisons
|
|
kotlin.concurrent
JVM
|
Utility functions for concurrent
programming.
|
kotlin.coroutines.experimental
1.1
|
Library support for coroutines,
including support for lazy sequences.
|
kotlin.coroutines.experimental.intrinsics
1.1
|
Low-level building blocks for
libraries that provide coroutine-based APIs.
|
kotlin.dom
JS
|
Utility functions for working
with the browser DOM.
|
kotlin.experimental
1.1
|
Experimental APIs, subject to
change in future versions of Kotlin.
|
kotlin.io
|
IO API for working with files
and streams.
|
kotlin.js
JS
|
Functions and other APIs
specific to the JavaScript platform.
|
kotlin.jvm
JVM
|
Functions and annotations
specific to the Java platform.
|
kotlin.properties
|
Standard implementations of
delegates for delegated properties and
helper functions for implementing custom delegates.
|
kotlin.ranges
|
Ranges, Progressions and related top-level and extension
functions.
|
kotlin.reflect
|
Runtime API for Kotlin reflection
|
kotlin.reflect.full
JVM
1.1
|
Extensions for Kotlin reflection provided by
kotlin-reflect library. |
kotlin.reflect.jvm
JVM
|
Runtime API for interoperability
between Kotlin
reflection and
Java reflection provided by
kotlin-reflect library. |
kotlin.sequences
|
Sequence type that represents lazily evaluated
collections. Top-level functions for instantiating sequences and extension
functions for sequences.
|
kotlin.streams
JVM
1.1
JRE8
|
Utility functions for working
with Java 8 streams.
|
kotlin.system
JVM
|
System-related utility
functions.
|
kotlin.text
|
Functions for working with text
and regular expressions.
|
org.khronos.webgl
JS
|
Kotlin JavaScript wrappers for
the WebGL API.
|
org.w3c.dom
JS
|
Kotlin JavaScript wrappers for
the DOM API.
|
org.w3c.dom.css
JS
|
Kotlin JavaScript wrappers for
the DOM CSS API.
|
org.w3c.dom.events
JS
|
Kotlin JavaScript wrappers for
the DOM events API.
|
org.w3c.dom.parsing
JS
|
Kotlin JavaScript wrappers for
the DOM parsing API.
|
org.w3c.dom.svg
JS
|
Kotlin JavaScript wrappers for
the DOM SVG API.
|
org.w3c.dom.url
JS
|
Kotlin JavaScript wrappers for
the DOM URL API.
|
org.w3c.fetch
JS
|
Kotlin JavaScript wrappers for
the W3C fetch API.
|
org.w3c.files
JS
|
Kotlin JavaScript wrappers for
the W3C file API.
|
org.w3c.notifications
JS
|
Kotlin JavaScript wrappers for
the Web Notifications API.
|
org.w3c.performance
JS
|
Kotlin JavaScript wrappers for
the Navigation Timing API.
|
org.w3c.workers
JS
|
Kotlin JavaScript wrappers for
the Web Workers API.
|
org.w3c.xhr
JS
|
Kotlin JavaScript wrappers for
the XMLHttpRequest API.
|
For more information, please visit: http://www.osglsofttech.com
Mobile: +91-8650030309, 8650030308, info@osglsofttech.com
Address: Shanti Vihar, Behind Mahindra Showroom, Ajabpur
Khurd, Dehradun
Comments
Post a Comment