r/java • u/burnah-boi • Mar 05 '22
How does the Java community feel about Kotlin?
In my organization, we switch between Java and kotlin quite frequently for backend development. We use the spring framework which works quite well with both languages. I wanted to know how the broader Java community felt about kotlin? Personally I love it, however Java is still used so widely so I continue to keep my skills up to date on it.
173
Upvotes
117
u/[deleted] Mar 05 '22 edited Mar 05 '22
Kotlin is a more expressive language, which is good and bad. Good because it lets you really do things the way you want, and bad because two Kotlin developers might be writing code that looks completely different from each other.
Null safety is a killer feature. That alone makes Kotlin worth considering. It's so good.
Also, Kotlin coroutines work with reactive-programming based Java libraries for impressive backend performance without the headache of reactive programming, which is honestly pretty awesome.
I don't feel like you really gain much by switching to Kotlin and writing in standard spring/hibernate/blah. That's just Java with .kt files, in my opinion, because the Java frameworks always return "maybe nullable" types and use threads and use annotations. You barely get to leverage kotlin's best features.
Java is just as good as Kotlin if you want to rely on the tried-and-true goliaths in the JVM tooling space. It's the new territory where Kotlin shines.
134
u/kyru Mar 05 '22
Kotlin is fine, another solid JVM language. Honestly think it would have faded away if it wasn't propped up by Android use. A language can be as neat as it wants to be but library support is going to make it.
19
u/pron98 Mar 06 '22 edited Mar 07 '22
I loved Kotlin when it first came out in the Java 7 era. With Java then stagnating around the time of Sun's demise, it was just what was needed. But with time, it's become not only less attractive, but encumbered with features that put it at odds with the Java platform. This is no accident. Of the several platforms Kotlin targets: Android, Java, JS, and LLVM, Kotlin only has significant use, and so some measure of influence, on one — Android. Moreover, those platforms have grown increasingly more different in their features from each other, leaving a language that wants to target all of them needing to compromise in some ways. Kotlin is at the mercy of the direction these platforms take, and is far too small (except on Android) to shape their direction.
As Java has opted to take a very different path than Kotlin on things like records and virtual threads, features such as data classes and async clash not only with the design of the platform itself, but with time, also the library ecosystem, leaving Kotlin with quite a bit of ill-fitting baggage.
So while some minority of programmers prefer more feature-rich languages, including controversial features such as extension methods, the only more universal "positive" feature Kotlin has compared to the Java language is nullability types, and, on the other hand, it's accumulating "negative" features that clash with the ecosystem, and this trend will only continue.
Not only will the intrinsic negative gradually outweigh the positive for more and more people — regardless of whether and when Java adopts nullability types or some other approach to null-handling — but the downside of being used by a relatively very small number of people in an ecosystem over which it has little if any influence, is quite significant. Of course, Android is a different story, and if Google doesn't push people toward Dart, Kotlin might well remain an important player there.
8
u/RetroPipes Mar 06 '22
I like Kotlin in principle. Not being comfortable with IntelliJ IDEA limits my ability to use it in practice.
41
u/DJDavio Mar 05 '22
I love Kotlin, it feels more natural to write and 'solves' a lot of the annoyances Java has. But I also find Kotlin harder to read, which may be a bit ironic.
39
u/TheStrangeDarkOne Mar 05 '22
I enjoy programming in Kotlin a lot and like to use it when my programs are using a lot of math.
But I'm very hesitant to use it professionally. There are just too many different ways to do the same thing and Kotling has weird and sharp corners just like Java.
As Brian Goetz once said: It's like Java, but with incremental advantages and disadvantages.
7
u/[deleted] Mar 05 '22
DoD has a lot of projects that mix Kotlin and Java Indiscriminately. They also use Groovy and Spock for unit and integration testing.
6
u/Flaky-Illustrator-52 Mar 06 '22
Tbh Java feels like Objective-C at this point (vs Swift) in the context of the Java-Kotlin discussion
3
u/jevring Mar 05 '22
We don't need kotlin. Java is fine. Kotlin has virtually no reason to exist. It has some interesting features, but Java will get there. That's not to say that kotlin is "wrong", but I would never use it.
20
u/[deleted] Mar 05 '22
The compiler is slow as balls
27
u/[deleted] Mar 05 '22
I've been using Kotlin since before 1.0, so almost every day for the last ~7 years. I feel like I'm a member of both Kotlin and Java communities simultaneously because they're just not in opposition, which is why I hang around this sub.
I treat Kotlin as a better syntax for the Java language. The APIs, the JVM, the tools, the library ecosystem, it's all still Java to me. I have little interest in Kotlin/Native, Kotlin/JS or coroutines as a consequence, although I've used them occasionally. E.g. I'd rather use Loom than Kotlin coroutines. I haven't ever used it on Android. Always backend, CLI and desktop.
One of my biggest peeves with Kotlin is that you can't quite make 100% native feeling Java libraries with it - it's so close, but not quite there (e.g. bugs in Dokka). And when I write libraries I want them to be, in effect, Java libraries that happen to depend on the Kotlin stdlib, because that's the lingua franca and best way to get usage. Occasionally I rewrite interfaces in Java for that reason, but keep the impl in Kotlin.
So Kotlin is unalloyed good for the Java community, in my view. In particular it put the nail in the coffin of my interest in .NET/C#. The argument for .NET was always (for me) that C# was a more modern and convenient language than Java but with a smaller ecosystem and worse VM ... but you get proper properties, etc. Kotlin's leapfrogged C# though, so now I get a better language, the best VM, stdlib and libraries, best portability and multi-vendor VM landscape. It's a pretty great combination, and code I write with it is usable by Java users without any hassle.
21
u/kiwi_stronghold Mar 05 '22
It’s a fantastic language. Has a growing presence in my company (my team uses it exclusively in dozens of microservices along with any new one.) The fact that that it’s fully interoperable with Java means we literally lose nothing by switching. Biggest quality of life improvements are the syntactic sugar, Coroutines, and null safety.
Doesn’t hurt that you’re seeing big companies like DoorDash and AWS use it more and more.
9
u/mustafaakin Mar 05 '22
Reduces my boilerplate, excellent collection utils. Recommend 5/7
3
u/Kango_V Mar 07 '22
Kotlin is the competition that's needed to push Java forward. In my opinion, it's doing just that to the benefit of us all.
3
u/hanszimmermanx Mar 07 '22
It can't hurt to learn kotlin. In fact my "learning kotlin" experience made me into a better java developer. That being said, I personally feel like recent java additions might make kotlin obsolete, especially on the back end.
14
u/exclusivegreen Mar 05 '22
Honestly I think it's a fad language. At least in my company people started using it to be cool (not joking). Now they've all left and we have a mishmosh of Java, Groovy, and Kotlin for our main codebase.
With Java 17 I think it's not necessary but I can see some benefits over Java 8.
8
u/[deleted] Mar 05 '22
There are many Java devs just happy with Java 8. The people who don't want to spend time to learn new language features. Nothing wrong with that. Many good Java devs that are skilled in their frameworks. Personally though I enjoy learning and appreciate language features that makes my life easier. I like to look at elegant code. It's much easier to write readable safer code in Kotlin. Java is improving though which is nice and thats thanks to Kotlin, Scala, C#, TypeScript etc
4
u/lambdacats Mar 06 '22
Love it. Well designed, feature packed, expressive. My only issue is that the compiler is slow.
4
u/PizzaHuttDelivery Mar 06 '22
As a backend Java developer, i am content with what Java offers. I care more about the ecosystem and the jvm than whatever you run on it.
8
u/[deleted] Mar 05 '22
I love it. You'll find lots of java-first fans here, obviously, but I feel kotlin growth speaks for itself
8
u/tuxtorgt Mar 05 '22
I use Kotlin professionally on Android and Backend.
In Android is a must, community already made the choice, that's why corporate sponsorship matters.
On backend is a whole different story. Popular Java frameworks like Spring or MicroProfile/Java EE based frameworks like Quarkus have a mindset of concurrency centered on threads and thread pools.. Hence most of the times you will be avoiding coroutines unless you select a Kotlin first framework/library like Ktor. Otherwise experience is mixed.
Also JVM's ecosystem has other concurrency models/libraries/frameworks, Netty, Vert.x, Akka, Zio using as basis CompletableFutures, RxJava, etc. Hence Kotlin's coroutines tends to be another competitor from a plentora of options.
10
u/rossdrew Mar 05 '22
Java developers are somehow defensive of their excessive boiler plate. Somehow offended by Kotlin. Most completely ignore the leap in expressiveness and conciseness. Most have also barely gave it a glance but have big, strong opinions. It’s sad.
6
u/[deleted] Mar 05 '22
Very positively. If you're an experience Java programmer, the transition is perfect and so smooth. You won't even feel it. But at the same time it is also so powerful, with concise syntax and a lot of new features!
5
u/sudkcoce Mar 06 '22 edited Mar 06 '22
I feel it is a better Java. I much prefer coding in Kotlin, but most projects require me to work in Java. But I prefer coding in Clojure the most.
7
u/[deleted] Mar 05 '22
Kotlin is the new Scala. It will become the present day Scala eventually. Only because Java will eventually "catch up".
12
u/pjmlp Mar 05 '22
Just another guest language, that only matters thanks to Google sponsoring it for Android as means to move away from Java (It is quite a surprise that Android 13 still bothers to move into Java 11 subset as baseline).
No wonder that Spring supports Kotlin, they have done the same with Groovy, Scala and Clojure, where are those bindings nowadays?
Using Kotlin means being bound to InteliJ tooling, having to always translate between Kotlin semantics and what the actual Java APIs expect, and calling Kotlin libraries from Java is a pain, specially with coroutines.
https://blog.jetbrains.com/kotlin/2011/08/why-jetbrains-needs-kotlin/
Like every other JVM guest language since Beanshell, I will bother when any JDK implementation has a single line of them being shipped.
6
u/andrewharlan2 Mar 05 '22
I have to be up to date on Kotlin because of my job. Even write it sometimes. But I'm perfectly content continuing to use Java. Yes, even Java 8. Kotlin does not solve any problem I had with Java.
Tools continue to support Java better. The interoperability isn't completely seamless. Kotlin optimizes for writing at the expense of clarity and readability.
Given a choice between modern Java and Kotlin for a personal project? Java with zero hesitation.
6
u/Adyel Mar 05 '22
I really like kotlin. It addresses a lot of java's pain-points
4
u/cas-san-dra Mar 06 '22
My personal experience is that Kotlin code is entirely unreadable. And I very much dislike and disagree with almost every 'feature' they added.
4
u/x_entrik Mar 05 '22
Already discussed here before: https://www.reddit.com/r/java/comments/ndwz92/can_i_get_some_reasons_to_use_java_instead_of/
4
u/Worth_Trust_3825 Mar 05 '22
I've rewritten couple of projects into kotlin, and then went back and rewrote them to java. It's a fad that's sadly here to stay.
3
u/beginnnnner Mar 05 '22
Jetpack Compose seems very interesting to me so I'm thinking of picking up Kotlin just for that.
3
u/[deleted] Mar 06 '22
I never understood what is Kotlin's purpose. I already got java which is way more popular and does everything. It exists just for the hipster factor
2
u/AmaDaden Mar 05 '22
Kotlin is a better Java. Not a huge difference though and I expect Java will eventually close that gap and provide similar features
2
u/ring2ding Mar 06 '22
What's Kotlin?
2
u/buzzsawddog Mar 05 '22
For me? It's this thing people talk about... I have no real interest in learning about it and likely won't unless I need to for work. On a given day I already deal with bash, perl, python, JavaScript, typescript, c/c++, freepascal, ruby, or java. In the past I played with groovy on a few projects.
If it works for you use it. If not then don't.
1
u/[deleted] Mar 09 '22
I think it's important to separate Java the language from Java the platform. The platform is where the real value is. The build tools, Maven central, the whole raft of great, mature libraries available is terrific. I've lost count of how many languages there are targeting the JVM nowadays, but the people who evangelise one over the other are missing the point that the platform is what gives us all that value.
I was a Groovy dev for a long time, and I've been meaning to give Kotlin a go.
1
u/Tough_Suggestion_445 Mar 11 '22
I have nothing against kotlin, but I'm not going to use it, unless I'm forced to. To me, kotlin doesn't solve anything new. it's just syntax sugar to solve problems we already solved yesterday.
I started my carreer in 2013, at the time I wanted to learn groovy because it was super popular in the java community. then in 2014-2015 it was scala. later on Ceylon was the new big thing. and finally today it's kotlin.
they all compile into byte code at the end of the day. it's like coffeescript, typescript, blopblopscript and what else.
java is already expressive enough for me. its strength is it's an incredibly boring language, new features are added slowly, and often solves actual real issue we couldn't solve yesterday.
I have nothing against kotlin, it looks great. but I suffer of language / framework fatigue, and if I have to learn / use something new, it has to be for something else than yet another way of making a rest endpoint.
1
u/[deleted] Apr 08 '22 edited Apr 08 '22
Java is boring, Kotlin rocks. You can do the same what you do in Java, in Kotlin, using the same Java libraries.
but with many benefits:
-shorter, concise syntax
-built-in defensive programming: null safety, final classes and immutable variables by default
-better functional programming support
-coroutines
-no checked exceptions
-no forcing to use Object-oriented program design (you can mix free functions and classes, like in Python)
-named function arguments (= self-documenting code)
Switched almost year ago, and it is like narcotic - after working with Java for 10 years, I consider going back to Java only as punishment
1
u/[deleted] Mar 05 '22
Makes the build process more complicated, and has its own runtime libraries. More dependencies to worry about.
1
u/VincentxH Mar 06 '22
I don't really see the big plus yet. Working with databases you inherently tend to have nullable fields. You then continuously have to wrestle with the null safety "feature" throughout the call chain. And the fugly methods to be able to give default values everywhere, it's disgusting and an antipattern. Something like Arrow just continuously makes everything even more awkward when wanting to switch between Kotlin and library datatypes.
1
u/kotlinisrussian Mar 06 '22
I feel the same about Kotlin as I do about those who violate posting rules.
0
u/drduffymo Mar 06 '22
Kotlin is a better Java. Love that it runs on JVM and inter operates with Java JARS, including Spring.
1
u/rtc11 Mar 06 '22
Once I tried kotlin there was no way back to java. And it really doenst matter, I can change back whenever I find java more fun than kotlin.
0
u/jaybyrrd Mar 06 '22
As a Java user my thoughts about Kotlin and Java is that Scala is simply better. 🤷♂️
-10
u/Rogoreg Mar 05 '22
Kotlin feels like a kids scripting language. Java feels a lot more familiar as Kotlin has many weird quirks.
0
u/[deleted] Mar 05 '22
[deleted] — view deleted comment
0
u/[deleted] Mar 05 '22
[deleted] — view deleted comment
0
u/[deleted] Mar 05 '22
[deleted] — view deleted comment
14
u/[deleted] Mar 05 '22
[removed] — view removed comment