DEV Community

Java or kotlin?

Fulton Browne on January 24, 2020

Which do you prefer?

Collapse
 
ashokgelal profile image
Ashok Gelal

I prefer Kotlin (heck, I even wrote a web framework in it: alpas.dev).

Kotlin is more expressive and is more modern. Java is now trying to catch up, which is good for everyone.

At first I wasn't sure about Kotlin having full interoperability with Java. I thought that would make the language more rigid and may not be able to get away from some limitations (like type-erasure generics). But after writing a full web framework, I've realized that it was a brilliant move as it allowys you to use any Java libraries without any issue.

Collapse
 
s_aitchison profile image
Suzanne Aitchison

Kotlin for me πŸ™Œ

Gotta love that optional chaining and not having to write if(myVar != null) over and over again 😁

Collapse
 
_hs_ profile image
HS

After looking at Groovy and Scala I didn't see the point of Kotlin. I'm trying to write an API in it just check will it grow on me but I don't see the benefit in many cases for now. I'm using Java 11 and hopefully switching to Java 14 soon so a lot will be gone from the pro side of Kotlin. If you write anemic classes than Kotlin. Simple to deliver CRUD fast. If you want real domain things it's just to much to get used to how to overide those getters and setters. Too confusing so I end up writting privats with custom getter and setter just to override something like add parameter to setter or such. It's just my current style of development.

Collapse
 
rawtoast profile image
RawToast

For backend development, I would also prefer Scala; however, Kotlin is very popular for Android development. Last time I checked it wasn't possible to use Scala on Android (or you had to use an old version).

Collapse
 
_hs_ profile image
HS

Yup. Anyways I'm pointing out that if I wanted faster development for backend it's hard to skip Groovy and use Kotlin, I just don't see it. On the other hand, Scala is also great and had val, var, pattern matching, reactive features, way before anyone heard of Kotlin so why switch to it? Java 14 has a lot of good stuff, maybe immutability is not there yet but I don't use it that much. You can achive it if you do good domain models. Example, I avoid getter/setter in domain part if I know what should domian do. Dtos are generated by IDE anyways huehue. If Java records get copy featute I think that's it for me. For now it looks like simple class

Collapse
 
twittdifu profile image
Diego

I think Kotlin will rise in the next years, as Python today. But today Java is very important. I program in android and in many courses, its instructors says that learn Java first.

Collapse
 
wrldwzrd89 profile image
Eric Ahnell

Perhaps I will love it more after I take some time to learn what it offers and practice with it. The Android benefits don't really impact me as I'd be using the NDK.

Collapse
 
fultonbrowne profile image
Fulton Browne

That's what I did and it is kinda why I love Kotlin so much.

Collapse
 
twittdifu profile image
Diego

Ohhh yes. I believe I will love it, too.

Collapse
 
jmfayard profile image
Jean-Michel πŸ•΅πŸ»β€β™‚οΈ Fayard • Edited

@fultonbrowne I love Kotlin, it's my default language for everything.

I wrote here how to learn it

On the other hand, Java is better than people think,
and especially, it's much better than Android developers think,
because Android "Java" is stuck in the past.

I keep refering people to this article from Roman Elizarov,
maestro ex Kotlin coroutines at JetBrains

and if you know only Java 8 from Android, read @awwsmm

Collapse
 
adityamitra profile image
Aditya Mitra

I think it's Kotlin.

Actually, it's because Kotlin is more dynamic than Java (no semicolons for example).

Even, your code gets shorter and more understandable in Kotlin. Try it! ;)

Collapse
 
armiedema profile image
Adam Miedema

Yisssss!

Collapse
 
galoiswannabe profile image
galoisWannaBe

Kotlin. It's faster to type, easier to read, and still compiles to Java Bytecode... As well as native code, while transpiring to JavaScript!

I'm definitely glad I know Java, though... That allows me to figure out some of the documentation for Spring, etc...

Collapse
 
darkes profile image
Victor Darkes

Kotlin! I think the ability for more concise code is the biggest advantage, no need to "new" objects or use semi-colons, allows for you to turn your thoughts into code quicker. Null safety and immutability is great too.

Collapse
 
wrldwzrd89 profile image
Eric Ahnell

I don’t have enough practice with Kotlin to honestly evaluate it against Java. I was turned off by it only compiling to Java 6 or 8 last time I tried, as I heavily leverage modules in Java 9+ for my own code.

Collapse
 
jouo profile image
Jashua

I personally prefer Java, I will move to Kotlin whenever it outshines Java for enterprise (if ever) in terms of employment, since that's my goal :D

Collapse
 
mehdico profile image
Mehdi Mousavi

Java.

Collapse
 
wplj profile image
wplj

clojure

Collapse
 
siy profile image
Sergiy Yevtushenko

Java. It is still better engineered and far more consistent than Kotlin. IDE support is also better.

Collapse
 
mjpasx profile image
mj πŸ‘©πŸ»β€πŸ’»βœ¨ • Edited

I'm an android developer and have done work in both Java and Kotlin, definitely prefer kotlin more and am glad my team is transitioning to using kotlin for our application :)

Collapse
 
toxel profile image
Timo

Kotlin :)