Introduction of Kotlin Programing Language
Introduction of Kotlin Programing Language
Introduction of Kotlin Programing Language
Kotlin programing
language
Abaarso Tech University
Introduction
Kotlin is a statically typed, general-purpose programming language developed by JetBrains,
that has built world-class IDEs like IntelliJ IDEA, PhpStorm, Appcode, etc. It was first
introduced by JetBrains in 2011 and a new language for the JVM. Kotlin is object-oriented
language, and a “better language” than Java, but still be fully interoperable with Java code.
Kotlin is sponsored by Google, announced as one of the official languages for Android
Development in 2017.
Example of kotlin
fun main()
println("Hello Geeks");
}
Key features of Kotlin
1. Statically typed – Statically typed is a programming language characteristic that
means the type of every variable and expression is known at compile time. Although
it is statically typed language, it does not require you to explicitly specify the type of
every variable you declare.
2. Data Classes– In Kotlin, there are Data Classes which lead to auto-generation of
boilerplate like equals, hashCode, toString, getters/setters and much more.
3. Safe – It provides the safety from most annoying and irritating NullPointerExceptions
by supporting nullability as part of its system.
4. Interoperability: Kotlin is highly interoperable with Java. You would not face any
difficulty using Kotlin in a Java project.
Advantages of Kotlin language
● Easy to learn – Basic is almost similar to java.If anybody worked in java then easily
understand in no time.
● Kotlin is multi-platform – Kotlin is supported by all IDEs of java so you can write your
program and execute them on any machine which supports JVM.
● It’s much safer than Java.
● It allows using the Java frameworks and libraries in your new Kotlin projects by using
advanced frameworks without any need to change the whole project in Java.
● Kotlin programming language, including the compiler, libraries and all the tooling is
completely free and open source and available on github. Here is the link for Github
https://github.com/JetBrains/kotlin
Basics of Kotlin
For any language, there are three constructs primarily to learn before going to advanced
level.
● Learning alphabets for language is leaning variables in programming
● Constructing sentences with learned alphabets is like coding statements with
variables
● Combining sentences together to form paragraph for language is like writing
functions with a block of statements in programming
Variables
Variables are used in all programming languages and they serve one unique purpose of
holding values. Variables are used to hold values. To declare a variable we mainly need
to know the name, type of variable, initializing is like assigning a value to that variable.
Kotlin basically needs two keywords to declare variables: val and var.
● val variables are “read-only”. We use val for the variables whose value never
changes. We can't reassign the value of a variable that was declared using the
keyword val.
● We use var for a variable whose value can change. We can reassign the value at any
point of time after it’s declaration.
Statements
A statement is the syntactic unit of any programming language that expresses some action
to be carried out. A program is formed by the sequence of one or more statements. In Java,
a statement always ends with a semicolon but, in Koltin semicolon(;) is optional.