If you can already program in a perfectly adequate programming language in python, would need to learn Kotlin? There are use cases where Python is virtually unmatched, but there also times Python is just not a match!
TL;DR: 1. If you know Python, then learning Kotlin will teach you more about coding, even for when still coding in Python. Plus, while Python is unmatched when writing small programs you will run yourself, most types of programs for end users (webservers excepted- but including mobile apps, web pages, native code apps, windows.exe, macOS.app and embedded software) are problematic to write and package up for an end user with Python. Kotlin provides a better solution.
2. Python is the best dymanic language, but it is also worth learning a statically typed language. There is an argument that large projects need the rigour of a static typed language as they mature, and kotlin can provide that rigour without the traditional drawbacks such as verbose syntax. So why wait for your project to grow up to have the benefits of static types?
Python is a great and much loved language, but it doesn’t give you a full ‘quiver’ to tackle everything. In one step, Kotlin is even more loved by developers, and covers all the bases missed by Python(native code, mobile apps, web pages, strongly typed). No other language covers all these bases, and only Rust compares for coding enjoyment (although, don’t forget Python also highly rated coding enjoyment).
It is not like everyone need stop coding with Python tomorrow. Having Kotlin as an additional language will provide the best combination tools to be able to also target more solutions, including all cases where python is not at its best. While in theory kotlin could substitute for Python in every use case, there are some cases where Python may still be a better choice, cases where either language is a good choice, but also cases where Kotlin is a far more viable and/or practical solution than python. This third group, which included mobile apps etc, make logical first targets to use Kotlin. There are still times it is worth staying with Python, but even if always staying with Python, adding a second language will even improve Python skills. Although it is true the Python Language is now adding features from Kotlin, there is no substitute for at least experiencing a static type based language.
Further, consider the argument that ‘grown up’ projects move to using static typed languages. Kotlin provides the concise syntax normally associated with dynamic languages, together with the stability and performance of a static language. Is staying in Python just delaying the day your project will move, and making the task bigger and bigger?
I suggest for python programmers looking for an additional language, kotlin best covers a wide range of uses (and particularly those where python is weakest). When a python programmer considers an additional language, Kotlin is currently the strongest contender.
Nine potential reasons to choose Kotlin:
- You wish to write a mobile app and enjoy the best in training, support, and development tools
- You plan that your project will scale and the benefits of a static typed language will best provide for the future, and now Kotlin allows early adoption of static types while still keeping concise code
- You have large scale projects and follow DSL Methodology, and Kotlin DSL capabilities increase how far you can simplify complex code
- A Kotlin program can offer greater performance than python, and be suitable for applications where python is a poor performance choice (note Kotlin native)
- Kotlin programs can be easier to package for distribution without sharing the program source code itself (for example as a commercial product)
- Embedded software, compilers, ‘system code’ and several other uses that require ‘native code’
- Kotlin programs can call java code and use java libraries
- You may simply prefer Kotlin. Kotlin does have language features not available in python which some people feel are very valuable (better lambda, better OOP, better functional programming, and DSL capabilities).
Python Ecosystem, Battery Limitations?
Many of these points come down to the fact that the core python language only provides a strategy to support programmers within a quite restrictive set of environments.
Python is at is best in an open source environment, and for development of programs where the developer is also the end user. This is one of the most significant growth areas for programming, but there are needs that do not fit this profile.
The python ecosystem prides itself of ‘batteries included’, and the library catalogue is phenomenal, but the java libraries available to Kotlin are catalogues that are the very least at a similar level. But beyond libraries, support for many things, from mobile apps to programs in the web browser or native apps are supported only at the fringe of the python ecosystem and not by the python core community, while these same capabilities are supported at the core of Kotlin. A core solution means better support, better tools, and better training available, together with solutions that are easier to deploy.
Reviewing the above points in more depth:
- You can actually write a mobile app using Kivy, but the Kivy project is not really embraced by ‘python.org’ as addressing a core direction for the python language. As impressive as the Kivy project is, the result of lack of core python backing is that deploying a mobile Kivy app is ‘fringe’ rather than mainstream, and this means the community providing support is small and deploying such apps requires more expertise than more mainstream solutions.By contrast, using Kotlin for mobile apps has unrivalled ecosystem support. Google officially endorses the language for Android apps and JetBrains, provides of software development tools of the highest level, is a key supporter.
- Prior to Kotlin, static typed languages were very verbose (Java, C++, Objective C), complex to code with or just too different (Scala, Clojure) or seen as vendor specific (C#, and while only also very new Swift). Kotlin addresses each of these issues and potentially provides a single language for almost every need.
- moving to ‘pypy’, again not part of the core python project, can bring more performance, but still not the ultimate performance available for the core Kotlin project. For most projects this performance is irrelevant, but not for all.
- python is at its best for open source applications. There is no support from the core project for distributing applications without distributing the source code. Distribution of the program without source code where needed is intrinsically available with Kotlin
- for python there is ‘rpython’, but use outside ‘pypy’ is not even encouraged. Kotlin has Kotlin native, and again this is a core part of the ecosystem it has core support. Kotlin native is new, but it is part of the core direction for the language
- while python plays perfectly well with ‘c’ programs (as does Kotlin ) which provides an interface to many languages, Kotlin can also combine with Java or any other JVM code. With java having been the most popular language by most measures for over 15 year, there are many java programs and libraries out there and if you have a need to work with either java program or library, Kotlin perfect. Working with java from Kotlin is as good as working with java from java. Some would even say it is better than java even for working with other java.
- Powerful lambda, extension methods, or DSL capability anyone? As a language, Kotlin offers type safety, null safety and immutable variables. There are also features python has, particularly in reflection, that if Kotlin will ever match, it has not achieved yet.
Lots of reason to learn Kotlin . Consider the changes happening in the industry, and if you are a python programmer considering learning a new language, then Kotlin is a strong contender. If any of the applications above is relevant to you and causes you to consider an alternate language, then Kotlin is likely the best choice to provide the most robust code as soon as possible without the penalties.
There are also reasons to pause before moving to Kotlin . There will be a specific page, but the information can be found from the contents page.
Adopting Kotlin is not a process of everything is in python one day, and then suddenly everything is in Kotlin. Step by step. The implementation section has our findings of steps to add, and these (as are the other pages) are updated over time.
4 thoughts on “Why program in Kotlin instead of Python?”
[…] The origins of kotlin are that is started life with a ‘we need something better than java’ brief back in 20 and is influenced by the need for the language to produce code that runs on the JVM (java virtual machine). Version 1.0 was released in February 2016. Jetbrains, the team behind kotlin, had a huge codebase that could really benefit from a better language. After trying Scala, they then “cherry picked’ the best language features they could find. Java was named after a large tropical island half way around the workd from the Java developers, famous for growing coffee. To follow that the kotlin team decided to also choose and island and they chose a cold island in the Baltic sea, famous for a class of warship being named after it, and the closest island to their offices. They may lack humour and imagination, or perhaps they love irony. Which, only time will tell. Perhaps it is a good time to review the page ‘why kotlin?‘ […]
I am impressed with this website , real I am a big fan .
Hello, I see that you are using WordPress free, I want to wish you good luck with it. I had a lot trouble on hi, good luck.
If translation is strange, sorry I’m using Google Translator
Refreshed my mind.
Thanks for sharing !!