CICLO 4b
[FORMACIÓN POR CICLOS]
Computación móvil
KOTLIN
Agenda
• Kotlin overview
• History
• Advantages Using Kotlin for Android
• Kotlin Syntax
Kotlin Overview
• Kotlin is an open-source, statically-typed programming
language that supports both object-oriented and
functional programming.
• Kotlin provides similar syntax and concepts from other
languages, including C#, Java, and Scala, among many
others.
• Kotlin does not aim to be unique-instead, it draws
inspiration from decades of language development.
• Kotlin mainly targets the JVM, but also compiles to
JavaScript or native code.
• Kotlin is sponsored by JetBrains and Google through the
Kotlin Foundation.
• Kotlin is officially supported by Google for mobile
development on Android.
• Since the release of Android Studio 3.0 in October 2017,
Kotlin is included as an alternative to the standard Java
compiler.
• The Android Kotlin compiler lets the user choose between
targeting Java 6 or Java 8 compatible bytecode.
More info:
https://developer.android.com/kotlin/overview
History
• In july 2011, JetBrains unveiled Project Kotlin, a new
language for the JVM, which had been under development
for a year.
• The name comes from Kotlin Island, near St. Petersburg.
• February 2016, Kotlin v1.0 was released. This is considered
to be the first officially stable release.
• At Google I/O 2017, Google announced first-class support
for Kotlin on Android.
• November 2017, Kotlin v1.2 was released. Sharing code
between JVM and Javascript platforms feature was newly
added to this release.
• October 2018, Kotlin v1.3 was released on, bringing
coroutines for asynchronous programming.
• 7 may 2019, Google announced that the Kotlin
programming language is now its preferred language for
Android app developers.
Advantages using Kotlin for
Android
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 to use all existing Android libraries in a
Kotlin application. This includes annotation processing, so
databinding and Dagger work too.
Advantages and Disadvantages
• 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.
• Compilation Time. 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.
Kotlin Syntax
Syntaxis
• Basic Syntax
• Functions
• Properties and Fields
• Strings templates
• Control Flow: if, when, for, while
• Null safety
• Collections
• Class
• Objects and instances
Tutorials
• https://kotlinlang.org/docs/reference/basic-syntax.html
• https://codelabs.developers.google.com/codelabs/taking-
advantage-of-kotlin/index.html
• https://www.tutorialspoint.com/kotlin/index.html