DEV Community

dzh
dzh

Posted on

Kotlin vs Python Why Kotlin may be better than Java and Python as the first programming language?

On the 3rd Day of the 3rd Trivago Camp at about 3 PM I had a small discussion with one of our mentors Matthias Endler about the programming languages. The question was is it still relevant today in the world where each year hundreds of programming languages appear to stick with one language, being the “Die Hard Fan” of it, praying to it and using it whenever and wherever you can.

Nowadays I use more and more Kotlin on a daily basis and no surprise that I come from the Java background. On the contrary, Matthias had a great experience as a Backend Developer in Python.

Based on my personal learning experience, I was in mind that if you learned Java then you would not have a big problem with understanding other languages and the programming itself in general. So I proposed to Matthias that “It would be better to learn Java rather than Python as the first programming language” but Matthias did not agree with that thesis. More than that, almost 10 years ago he wrote the article exactly on the contrary proposal Overkill – Java as a First Programming Language.
I mean…. Come on, guys… It is Java! Who does not like Java?! :D

So I read his article and I would agree with some of his points. For example, I would agree with the point about the simple “Hello world” example, when you as a newbie may be horrified with so many unknown things in that small code snippet at once. I remember the discouraging and sleepless times in my last year of school because we started learning Java in the Doctor Java IDE, and the Doctor prefix itself already scared me at that time. There were times when I just was losing hours and hours of “debugging” just because I missed semicolons on some lines or miss-typed variable names.

However, looking back I am grateful to Doctor Java, for showing me from the first day that “Programming is not the fancy thing with smoothies and brownies. 99.99% is nothing. The program either works or not”.

So I think it would not be quite correct from my side to claim now that “Java is better than Python” because I do not have enough experience with Python so I came up with another proposal “Why Kotlin may be better than Java and Python as the first programming language?”.

Comparing with Java, in order to show to the newbies the simple “Hello world” you literally do not need to say something like this: “for now we do not care about class, about that new keyword, about that args, about String[], about that public, about that void, etc. (The list is really long). Just look it prints!”. So all you need to show is:

Alt Text

Another good example may be plain classes:

Alt Text

The great thing about Kotlin is that you still have more or less the same concepts as in Java, but at the end of the day you may have a less steep learning curve with almost the same amount of information provided. You do not need to know anything about OOP just to start to write some code. On the other hand, if you are starting to learn programming without using advanced IDEs like Eclipse or Intellij IDEA it would be probably less frustrating for you to write the code in Kotlin because you will not have to hunt for missed semicolons.

At the same time, when we compare Kotlin with Python, one of the big advantages of Kotlin may be the fact that it is hugely used for mobile development. As a student, you may ask yourself "Why do I need that? Where can I implement this knowledge?" and for many students the "Mobile Development" may be much more feasible and motivating rather than magical "Machine Learning with Python", where you basically have tons and tons of mathematics.

Another interesting aspect may be that majority of Computer Science “Programming” classes are either based on Java or C++ (declining trend). I have never heard someone saying "At University we started learning programming concepts with Python".With the intercompatibility and similarity between Java and Kotlin it would much more easier to adapt the university curriculums to Kotlin rather than to Python. So if universities do not want to be stuck in the technological past, then Kotlin may be an optimal and unradical solution for them.

In the conclusion I want to wish all students to be brave and not giving up after starting learning programming , because sometimes it may look discouraging and frustrating, but I believe we all went through that. Give a chance to Kotlin and I am sure you would not regret about that.

Top comments (5)

Collapse
 
trackrunner profile image
Laszlo Toth

When first time ever I saw Java code at university, I felt it's so complicated, so much to learn and I hesitate how I am going to learn this. I was ok with it because many of my classmate felt the same and we went through this. together.

Probably Java is not the easiest way to write a "Hello World" or other basic code, test it and understand it but definitely a good point to learn and understand Object Oriented programming.

I wonder what is the difference between these 3 programming languages in practice.

I started to learn Android development with Java because I had a little experience with it years ago. I hesitate by now it would be better if I switch to Kotlin, but because so many fundamental lessons left from my course, I will keep going in Java and maybe I will try Kotlin as soon as I created some apps for practice.

Collapse
 
tobiassn profile image
Tobias SN • Edited

You never went into depth about why Kotlin would be better than Python.

Collapse
 
fronkan profile image
Fredrik Sjöstrand

I graduated last year and our first programming course actually was in Python.

Collapse
 
avxkim profile image
Alexander Kim

Have you tried Kotlin to write backend apps?

Collapse
 
paulod79 profile image
Paul O'Donoghue

I have. You can use it wherever you use Java. I've been using it to write new code for existing Spring projects (and other frameworks best forgotten) and new projects as well.