I disagree that the passing of values vs references is 100% hidden in Kotlin. But I do agree that everything that’s hidden by the JVM won’t be necessary for beginning or even intermediate coders doing normal app development.
So, yeah, I would also recommend to start with Kotlin, why not? Just, as stated, don’t try to do Android at the same time, as it’s a very complicated environment.
Errr… no? Why would they be the same? So I think you should really start learning by first reading what is a programming language and what is an operating system, because it is surprising to mix one with another.
No, Kotlin is a general purpose language. You can write desktop applications (Windows, Linux, MacOS), web applications (both server-side and client-side) and also mobile applications (Android, but I believe also iOS, at least to some degree). But you are right - currently, Android is probably its most common use.
You can start by writing some console/terminal applications, because this is the easiest, it doesn’t require any additional knowledge or skills. Although, somehow contrary to what @serandel said, I would suggest to switch to either web or Android applications as soon as you get Kotlin basics. The reason is: it is much more fun and exciting if we see some real action, if the application displays something, if it reacts to our actions, etc. Yes, learning Kotlin + web or Kotlin + Android will be more complicated, but on the other hand learning Kotlin alone, without any graphical interface, may be essentially boring and you lose motivation for learning.
@broot is absolutely right there. Making something that you can see in your phone is inherently fun. But it’s also the most difficult path, it’s a very complicated environment.
Learn a bit of the language and know that you can use it for everything Java is used, i.e., practically everything (except for systems-programming, I’d say, top of my mind). The easiest way is to do some command line programs. And I’d empathically suggest to create some fun command line programs along the way, so you don’t get discouraged.
Any simple game that you can think of that’s based on options shown on screen would be magnificient, for example.
I’ve been coding for over 30 years now, and I’m still fighting with Gradle every time I want to add a new plug-in to my Kotlin Multiplatform pet project.
Yes, I agree. Android isn’t that hard as long as everything works fine, but it’s a very complex beast, so if anything goes wrong, it may be very hard to investigate. Web server-side (Ktor + HTML) could be easier, because it only requires basics of HTML and Ktor is super easy. JavaFX may be not that bad choice, although it is not very popular, so any learnt skills for JavaFX itself may be not that useful in the feature. Web client-side would be nice, although it has similar problems as Android - complex setup, risk that something goes wrong. But definitely the best to start are console applications.
If he’s so inclined there’s also a couple of game engines he could use. LibKTX looked nice at first, but I wasn’t very happy when I tried to use it more or less seriously. Korge is cool and makes good use of coroutines, but the surface area is huge.
Kotlin is not Java. It’s based in the same virtual machine, but if you’re a beginner that has absolutely no impact on you (it only becomes relevant when you’re benchmarking code, etc, which you should definitely not worry about for now).
Keep in mind that Kotlin, whilst having its roots in the Java world, has far outgrown it. For the past 6 months I’ve been mostly writing Kotlin/JS (websites in Kotlin) which don’t use the Java machinery at all.
Many people think that learning Java first is important because many people learned Java before Kotlin existed. When they started to learn Kotlin, they feel like they only need half the work than when learning something completely different, because the ‘hard parts’ are similar. If you’re a beginner and do not know Java, learning a full language plus Kotlin is just 50% more work than just learning Kotlin.
Also, Java is missing a lot of what makes Kotlin good. Kotlin is not a clone of Java, it’s a reboot that adds a lot of things. In particular, suspending functions are miles better. Why start with a language with less features if your goal is Kotlin in the end?
My only concern is that there are still a few corner cases where knowing Java may help to explain what’s going on. (For example: interoperability issues with libraries written in Java — such as where the Kotlin compiler makes unhelpful assumptions about nullability; why generics are implemented the way they are; the split between Class and KClass; the unexpected performance differences between Int and Int?; the unexplained differences between Array<Int> and IntArray; why some properties and methods in the standard library need backquotes; why properties and getXxx()/setXxx() methods clash…)
Of course, understanding those things may well not justify learning the whole of Java, when they might be easily explained away without it. Those of us who know Java well can’t really judge that!
(I had it doubly easy: not only had I been using Java almost since it was released, but I’d also gained a good understanding of Scala, and so most of the ideas in Kotlin were already very familiar. So I’m highly unqualified to judge how easy Kotlin is to learn as a first language, nor whether it teaches you good habits! But I expect it probably scores well on both counts.)
What you’re saying is true, but I’m not convinced it has any relevance to a beginner.
Library interop is not really a beginner topic, reflection definitely isn’t, I guess generics could be but generics being erased is just a concept among others (Java is the most well-known language to do it, but learning generics has nothing to do with learning Java). The performance difference is, again, an advanced-user topic, it’s very rare that you should prioritize speed over having a clean API and beginners definitely don’t have the experience to decide if it is the case or not. Same with the difference between IntArray and Array.
I guess the get/set example is the most convincing and I agree the error message is not great, but I don’t think it’s a major issue either.
I think the problem with arrays is that for someone who don’t know Java, it is pretty confusing that we have: IntArray, Array<Int> and List<Int> in Kotlin.
It is more or less the same in other languages as well. In numpy it is even more confusing because ndarray does have types, whereas python does not “have” them.