Can kotlin script replace python?

Are there any chances that JetBrains or someone else will create distributions for platforms with a kotlin script environment?

Kotlin script could have a minimal enviroment with ability to install modules/libraries somewhere on machine, that will be available in any script file.

May be there is already exists some projects or plans to implement this?

Or maybe there is some problems/limitations?

Also what is performance difference between kotlin script and python?

2 Likes

JetBrains Is actively working on a Kotlin environment for notebooks and scripting! Check out the data science page on the official website!

I also wish to see Python gone, let’s hope soon!

7 Likes

In some fields kotlin already surpasses Python. As @lamba92 mentioned, kotlin jupyter kernel is an excellent tool that easily rivals Python already. Still, there is one field, where Kotlin won’t compete for now - it is interoperability. Kotlin has a superb platform interoperability (with Java on JVM, with JS in browser and with C on native target). But it is not quite easy to call C/C++ code from Kotlin-JVM. Python has this ability because it is done that way, and we won’t be able to do exactly that in kotlin without sacrificing static typing and JIT performance. So Python is still the best glue language. Something could change in future, of course. For example interop between kotlin native and kotlin-jvm could solve that problem.

1 Like

Forgot to say about performance. Performance is a tricky thing. If you compare compiled Kotlin against interpeted python, Kotlin will be an order of magnitude faster, but if you use numpy in pythons, the performance of numpy operations will be of the same order of magnitude. Also, Kotlin needs time to startup JVM and compile the script. So for very short-lived task, it could be slower.

5 Likes

Kotlin is statically typed, there are many statically typed languages as well mimic Python’s nature, among them: nim, crystall
There are also dynamic languages mimic the behavior of statically typed languages but providing similar flexibility as Python, e.g. Julia.

As it seems, no one of this language will replace Python, but they will rival Python in many areas and I think this is the case for Kotlin, too.

The main reason is Python’s simplicity, it has an easy data model + syntax, you have mostly one way to solve problems reducing development time.
Because Python isn’t that fast you don’t either have to think much about performance issues further reducing development time except for the cases you are required to think about it.

I think Kotlin will be faster in this case, too. Isn’t there already the option to interpret Kotlin from source, then Kotlin is also a scripting language too.

However, generating pyc Python bytecode may be faster than JVM byte code generation as Python delay its type checking to runtime reducing development- but not bugfixing time.

I think Kotlin has one remarkable advantage over Python: dependency management.
Downloading Jars and execute them is lot easier than compiling packages over pip.
Compiling C/C++ Code for performance reasons has the same risk as trading on a stock exchange market.

1 Like