I am curious to find out more about this language

Hi I am completely new to this language and I had some questions in mind.

  1. Is this a compiled, statically-typed language?
  2. Does it support multithreading?
  3. Can this language be used for low level programming such as designing an operating system?
  4. Does it have reference counting or CG or it has non of that?
  5. Does Kotlin have its own native GUI application builder for both Windows, Linux and Android?
  6. Is this language easier than C++ and Rust?
  7. Is it faster, slower or about the same speeds as C++ and Rust?
  8. Is this more cross platform friendly where I can write once and run anywhere (for iOS and Android and perhaps even Linux) compared to C++ and Rust?
1 Like

Welcome to the world of Kotlin.

Please check out extensive documentation: https://kotlinlang.org/docs/reference/

No language is easier or harder, it depends on your preferences, so that’s one question down - try it out and find out!

3 Likes
  1. Yes
  2. Yes for JVM/Native, no for JavaScript (because JS environment doesn’t support it, except workers tricks)
  3. I think no, because it uses GC.
  4. JVM has difference GCs, however as I know all of them don’t use reference counting. JS as I know doesn’t use reference counting (however who knows), Kotlin Native doesn’t use reference counting, however iOS integration layers obviously use this behaviour. However all environments have optimisations such as “stack allocations for local objects”, which is looks like reference counting for some cases.
  5. You can use JavaFX for Win/Lin, Android has own UI builders. So answer is no.
  6. From my observations, C++ is much harder than than Kotlin/Rust. Because of compile-time GC in Rust, it is harder than Kotlin from my point of view. So, from my point of view, the answer is “yes”.
  7. This is incorrect question. Multithreaded allocation works faster in JVM than in C++, because it doesn’t require atomic operations (increment requires at about 1-2 processor ticks, atomic increment requires at about 72 for the latest AMD processors). However in C++ you can add more optimizations theoretically. From the another side, JVM better optimises the general code. However in C++ there aren’t array bound verification, so it should faster multiply the matrixes. But for the huge enterprise application, JVM/CLR is the one way to write it and have in workable state for 10 years. So, the right answer - it depends, please do benchmarking first.
  8. From my point of view, JVM is the most easy platform to write once and run everywhere, because of statically-typed nature, because of great backward compatibility, etc. However JVM couldn’t be executed in the Android. So, from my point of view, the answer is yes, however it depends in general case.
2 Likes

K/N uses automatic reference counting for any Kotlin object, which is kinda industry standard for any language that compiles down to machine code.

1 Like

You are right, please sorry - https://stackoverflow.com/questions/55610460/how-kotlin-native-garbage-collector-works-in-c

1 Like

Thank you :slight_smile:

Sure I will keep that in mind, thank you :slight_smile:


What if I was designing for Windows or Linux, would there be any GC or reference counting if I used Kotlin Native?

Oh wow interesting.

Oh I thought it did use JVM, how come it can’t use JVM?


Just so I am making sure I am understanding it clearly, JVM is what converts byte/interpreted code into machine code in real time?

What if I was designing for Windows or Linux, would there be any GC or reference counting if I used Kotlin Native?

I can only give a link - https://blog.jetbrains.com/kotlin/2020/07/kotlin-native-memory-management-roadmap/ . I didn’t try K/N. However in general case long-running service on JVM will be better for memory management, from my observations.

Oh I thought it did use JVM, how come it can’t use JVM?

There is OpenJDK on Windows/Linux/Mac. So you can use any modules from it, even JavaFX.
Android doesn’t use OpenJDK, they have separate virtual machines. And the set of features on Android is quite different with set of features on OpenJDK. It means, that you can use Android UI at Android and JavaFX (for example) on Windows Linux. You can write the same code for network and business logic, however UI should be implemented twice.

Therefore: you couldn’t write application on Kotlin JVM, which will be ready for Win/Lin/Mac/Android. However you can share all non-UI code between these platforms if you selected target “JVM” for Kotlin (e.g. UI is the single item which have to be written twice).

Just so I am making sure I am understanding it clearly, JVM is what converts byte/interpreted code into machine code in real time?

Yes, plus “set of API functions”. For example, class File is inside JVM, it isn’t delivered via package manager. Class Process is on JVM 9+ (part of OpenJDK), and it is missed on Android (not sure 100%). Class Intent is on Android VM, however it is missed in the OpenJDK.

1 Like