this post was submitted on 04 Jan 2024
54 points (88.6% liked)

Programmer Humor

32557 readers
285 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 

I wanted to learn how to make an android app and it seems to be pushing to use Kotlin (official tutorial). I thought I was going to use Java (that I know). So I'm a little lost.
Is it really better with Kotlin than Java? Is it a good investment to learn Kotlin?

I just want to be able to make android app for myself and maybe it could drive me somewhere at some point professionnally. I have a web dev formation.

top 14 comments
sorted by: hot top controversial new old
[–] [email protected] 31 points 10 months ago (1 children)

Kotlin is the wave of the future. I still use Java, but I'm transitioning into using Kotlin for backend services. The devs are my work have been moving the app codebase to Kotlin for a couple of years (over a million lines) and it's pretty nice. You reduce a lot of boilerplate and the code can be a bit more dense.

[–] WilliamsStark 4 points 10 months ago (1 children)

Ok, so if it's the new standard then I should go with Kotlin. By boilerplate, do you mean a part of the code that makes java a little too heavy?

[–] Aurenkin 5 points 10 months ago

I don't know if this is the proper definition but I think of boilerplate as the code that's not directly related to business logic. An example I can think of in Java that's a lot nicer in Kotlin is setting all the instance variables in the constructor.

The names and types of the variables are important and useful for understanding the business logic but the actual constructor definition doesn't tell you anything if it's just assigning the constructor parameters.

[–] [email protected] 13 points 10 months ago

It's perfectly fine to continue to write Android apps in Java, doing that will continue to be supported for all foreseeable future and I do it myself for a hobby app that I maintain.

That said, there are good reasons for the increasing popularity of Kotlin, it's certainly a good language that has noticeable advantages over Java.

[–] [email protected] 9 points 10 months ago (1 children)

Just go ahead with the tutorial. Kotlin is basically identical to Java with only tiny changes, and you can just look those up whenever you see something new.

[–] WilliamsStark 1 points 10 months ago (1 children)

Nice, if it's not too much changes then I shouldn't be very lost.

[–] [email protected] 4 points 10 months ago

The above is pretty misleading. A typical Java program can be made into a Kotlin program with little changes, this is true. But Kotlin code, particularly when written using Kotlin best practices, bares very little resemblance to Java code. If you learn Kotlin first, you'll find some of that knowledge does transfer to Java but then there's plenty that won't and you'll have to learn the Java way of doing things too. Still, as a dev, knowing more languages never hurts. I'd still recommend proceeding with Kotlin.

[–] [email protected] 7 points 10 months ago (1 children)

Even for someone who doesn't program in java or Kotlin, I can trod my way through modifying things written in Kotlin where I'm hopelessly lost in Java.

[–] xmunk 7 points 10 months ago

Eh, Java isn't so bad... As long as you have your leather bound books detailing every single built in class at your fingertips...

... And I guess a warehouse large enough to actually store them.

[–] [email protected] 7 points 10 months ago (1 children)

I did a bootcamp for Java, and lucked into a junior Android dev role, and man, I've really grown to love Kotlin. It really does have all the things I liked about Java, like type safety, but it's so much more concise. It was pretty confusing at first, a lot of Kotlin is just syntactic sugar, and you kinda need to know what Kotlin is cutting out to make sense of things. But once I got into it, it just feels so much faster and expressive than Java.

I'm really happy when I see Kotlin being adopted outside of Android, like in backend services and such. But that rarely happens.

[–] WilliamsStark 1 points 10 months ago

Interesting. Thank you for your feedback. I should go all the way with Kotlin then.

[–] [email protected] 1 points 9 months ago

I hate that there is no tooling for kotlin outside of intellij. Decided to learn c as my first language instead. That being said kotlin is Great if you don't mind intellij

[–] [email protected] 1 points 10 months ago (1 children)

What about the Dart with Flutter?

[–] [email protected] 1 points 10 months ago

In my experience it's pretty bad. Buggy, poor support (as in responding to bug reports), hard to test, very verbose components library. Not a great experience over all. I would try react native for my next project but looks like Tauri will be getting Android support soon so I will try this first.