DEV Community

Magda Miu
Magda Miu

Posted on • Originally published at Medium

Hello Kotlin

At this moment, in the world, there are more than 5000 programming languages available. Now, the first question asked by us, the developers, is why do we need another programming language like Kotlin?

Kotlin is a general-purpose language that supports both functional programming and object-oriented programming paradigms. It’s an open-source project developed mainly by JetBrains with the help of the community. Like Java, Kotlin is a statically typed language, however, in Kotlin we can skip the types.It’s an open-source (Apache 2.0) project developed mainly by JetBrains with the help of the community.

The Kotlin philosophy is to create a modern and pragmatic language for the industry, not an academic one. Pragmatic means getting things done, and in terms of programming represents the capability to easily transform an idea into software.

Kotlin is based on many programming languages like Java, Scala, C#, Groovy, Python and it tries to reuse what works better in those languages.

The name of the language represents the name of an island according to Wikipedia: “ Kotlin is a Russian island, located near the head of the Gulf of Finland, 32 kilometres (20 mi) west of Saint Petersburg in the Baltic Sea.”

Kotlin is a popular language: in the latest Stack Overflow developer survey, it ranks as the 4th most loved programming language and it is used to developer apps like Pinterest, Uber, Slack, Trello, etc

The Kotlin project was started in 2010 and it took 6 years in order to validate all the design choices made. The community was involved in this project, because community it is not only about validation but also about inspiration.

In 2017 Google officially announced at Google I/O that Kotlin is a first-class citizen in the Android world.

In 2018 JetBrains launched the 1.3 version and this year they launched 1.3.50 version.

✅ Conventions

  • The same conventions like on Java
  • Uppercase for types
  • Lower camelCase for methods and properties
  • Semicolons are optional
  • Reverse notation for packages
  • A file could contain multiple classes
  • The folder names not have to match the package name

🛠️ Development & Build tools

  • Kotlin/JVM : JVM 1.6+
  • Kotlin/JavaScript: transpile to JavaScript and it offers readable generated JS code
  • Kotlin/Native (C, Swift, Objective-C): compiles to native binaries using LLVM and it does not suppose to have a Virtual Machine
  • Editor or IDE: IntelliJ IDEA, Android Studio, NetBeans, Eclipse
  • Build tools: On the JVM side, the main build tools include Gradle, Maven, Ant, and Kobalt. There are also some build tools available that target client-side JavaScript.

📌Main advantages of Kotlin

Readability:

It’s already known that developers spend more time reading existing code than writing new code. And we also know that a code is clean if it is easy to understand.

Imagine you’re a part of a team developing a big project, and you need to add a new feature or fix a bug. What are your first steps? You read a lot of code to find out what you have to do. This code might have been written recently by your colleagues, or by someone who no longer works on the project, or by you, but long ago. Only after understanding the surrounding code you can make the necessary modifications.

Interoperability

Regarding interoperability, our first concern probably is, “Can I use my existing libraries?” With Kotlin, the answer is, “Yes, absolutely!”

Safety

In general, when we speak about a programming language as being safe, we mean its design prevents some specific type of errors in a program. For example, in Kotlin, the designers of the language worked to eliminate the NPE.

Tooling

Kotlin is a compiled language. This means before we can run Kotlin code, we need to compile it. And in terms of tools, we have a lot of possibilities here.

🔖 Best practices

  1. Agree on a set of conventions before you start to write code in Kotlin
  2. Don’t treat it as Java with a different syntax
  3. Use a linter (like ktlint )
  4. Don’t hide too much info
  5. Choose readable over short expressions

📚 Resources to learn Kotlin

  • Kotlinlang.org: The official Kotlin website. Includes everything from a guide to basic syntax to the Kotlin standard library reference.
  • Kotlin Koans Online: A collection of exercises in an online IDE to help you learn the Kotlin syntax.
  • Udacity course: “Kotlin Bootcamp for Programmers”. Essentials of the Kotlin programming language from Kotlin experts at Google. For programmers coming from Java or other object- oriented languages.
  • O’Reilly course: An 8-hour Kotlin course, “Introduction to Kotlin Programming,” by Hadi Hariri, a developer at JetBrains. Requires subscription; 10-day free trial available.
  • Treehouse course: “Kotlin for Java Developers” teaches Kotlin with an emphasis on Android. Requires subscription; 7-day free trial available.
  • @kotlin: The official Kotlin Twitter account.
  • Kotlin Community: A list of offline events and groups from kotlinlang.org.
  • Kotlin Slack: A Slack chat community for Kotlin users.
  • Talking Kotlin: A bi-monthly podcast on Kotlin and more.

Enjoy and feel free to leave a comment if something is not clear or if you have questions. And if you like it please 👏 and share !

Thank you for reading! 🙌🙏😍✌

Follow me on Twitter: Magda Miu

Top comments (1)

Collapse
 
krysal profile image
Krystle Salazar

Thanks for this introduction, very informative!