The golden age of Kotlin and its uncertain future
shiftmag.dev
shiftmag.dev
Kotlin needed to succeed on the native front to live beyond Java. It didn't and that puts it in a perilous long-term spot.
Oh and I wish Java would support „it“ in lambdas, very useful.
The Java version instead looks like this, where you add an exclamation mark to mark it as non-nullable:
class Cursor {
private Point! position;
}
[0] https://bugs.openjdk.org/browse/JDK-8251554As mentioned in the relevant JEP[1]:
"A null-restricted type is a reference type expressed with the name of a value class followed by the ! symbol."
Goals: "Allow a value class to "opt in" to the automatic creation of an appropriate default value used to initialize fields and arrays that don't store null."
Non-goals: "It is not a goal to support null-restricted types for identity classes or classes that do not provide a default value."
So, I don't see how that's in any way going to threaten Kotlin's position as a null-safe language - Java will almost certainly always have "unsafe" `null`, removing it from Java seems simply impossible at this point (notice that Dart managed to do it, but it had a much, much smaller ecosystem than Java, and even then, it required multiple years of migration of every single Dart package in Pub - and the ones that were unmaintained were simply abandoned and no longer work with the latest versions of Dart which is fully null-safe).
The data that flows through the app at runtime is the big issue, and even just documenting null-safety at the API interfaces goes a long way in making refactorings safer and maintenance less of a pain. Those are usually records nowadays (DTOs, VOs, Entities).
These days Java isn't slow to develop on at all. There are plenty of very good frameworks where you can get going with developing a web app or rest service in next to no time with far better tooling support, sophistication etc.
.NET is a serious contender though.
Node isn't really on the same ballpark in terms of maturity.
It the other way around. Java has barely caught up with C#. C# team is typically introducing more features, faster.
I prefer Java's more thoughtful approach to introducing new features.
In addition, green threads approach is a strictly worse and a more limited solution that only solves thread blocking without unlocking the variety of terse concurrency patterns enabled by the way the tasks are handled in .NET. They also add significant overhead to interop with native code due to thread pinning/stack switching (also applies to Go).
I think you're onto something. Maybe some Java-by-default workplaces lack technically interesting problems that engineers want to solve, so those engineers instead overfocus on the frictions of the parts they can control. Maybe those engineers desire expressiveness in their working programming language to compensate for the restrictions on the rest of their work.
Just a hunch though.
In my startup we also use a "boring" stack, but the problems we solve are innovative and motivation in itself. The developers work closely with customers and can see the impact that the product has. They are no longer working in a Jira-factory and while they are still interested in technology they also find motivation in the product itself.
We got to upgrade from Java 8 to Java 17 in 2023.
I have over two decades of experience and there has always been room for trying out the "new" technologies and keeping up with the latest best practices, even in enterprise. I know that not everyone has this experience, but there are actually a lot that happens outside slow big American legacy companies...
In my current startup we use the latest JVM and have a mix of Java and Kotlin. It works really well and we have never experienced any problems with development speed that was related to code or language syntax. JVM + Spring boot + Postgres may be the "boring" choice, but it has enabled us to focus on getting things done and focusing on the product. It didn't take long for juniors to be productive in our stack either. Spring itself looks a bit scary at first sight, but once you learned the basic philosophy you have less issues than a Node project in my experience.
I know that my experience may not match your experience, so I recognize that I can't make a generic statement. It's just a bit frustrating to see similar statements made by people with bad experiences.
- Not all Java development happens in enterprise. There is a thriving eco system of small to middle sized companies and startups using Java
- Not all enterprises are the same. I've actually noticed a shift to the other extreme, where enterprise uses the latest technologies to attract new employees. Nobody who has a choice wants to work with factory patterns on an old version of Java
- Old Java patterns like factories and extreme use of inheritance is out of fashion. There is of course a lag like in any trends, but remember that Java is so widely used so you will always find companies that are slow to adopt, or have legacy software that is in maintenance mode.
I have to keep alternating between startup and enterprise so that I can keep sane but also get pension contributions, so I do know there is a great world out there. Just not always great paid (am in UK).
Yes. Kotlin fans need to understand that Kotlin is not competing with the old Java ways and stop mentioning bloody enterprise as an argument against Java, because bloody enterprise is largely ignorant to Kotlin‘s cause. EnterpriseStrategyAdapter anti-pattern is not a language problem, it is a management problem. It won’t be solved neither by new features of Java nor by new features of Kotlin. The real competition is in the new code in startups and Java has one big advantage there: faster recruiting, more reliability in tooling, better quality of business code for the money. Kotlin is a good perk for developers in late stage startups, where the teams are big, delivery timelines more relaxed and you can afford fancy but less mature language or tool to consume resources instead of delivering more business value.
Also, it's hard to find Java programmers who haven't been tainted by that enterprise mentality, so in a way it makes hiring hard if you don't have the resources to filter the junk. When you see Clojure or Scala on a resume you know they're above that.
Looking at TIOBE and PYPL, it comes that for backend Java and .NET are huge, followed by .Node.js, followed by Python and then PHP.
And when it comes to concurrency Rust is the worst language I've ever used by far. The type checker makes dealing with objects between threads extremely painful. With the JVM it's all just handed for you.
Rust is great when you want a tiny binary with minimal memory consumption.
Remember that "Systems Programming", which is what Golang was designed for, isn't necessarily just Kernel and device drivers, but everything that isn't "Application Programming", and that includes the whole K8S networking and container stuff where it is very successful.
The proof being?
You're delusional if you really think any of this is true. There are, proportionally to "enterprise", extremely few startups using java. For good reasons.
As an average company what you want from a language is: your team already knows it or is fast to learn, it is arguably better in a measurable way (development is faster, codebase is easier to maintain), developers like it more, it has a large support and audience.
How many of these does Kotlin check?
Speak for yourself there good buddy. It's pretty important to me!
But I do agree with your broader point. From one perspective, Kotlin has been a great success if we define its mission as a test-bed and laboratory for improving Java proper. Unfortunately, while it has arguably succeeded in that mission, in doing so it might unavoidably fail in another mission, which is to thrive as an independent language.
I'd liken it to yarn and npm. Yarn was a huge success.. at forcing npm to massively improve and thus basically rendering itself irrelevant. A bittersweet success, but a success nonetheless..
I wonder if there's a term for this kind of self-sacrificial project which makes the world better for having existed but doesn't survive the process..
The only one who might like the article is self-conscious Java developer who wants to feel good by bashing on competing language.
Wish it wasn’t morning so I could elaborate on every point. Might reply later to this comment.
That doesn't make sense at all! Why should one do it without a need? To have NullPointerException with "primitive" types, too?
> Kotlin ecosystem is severely lacking compared to Java. FAANG has first-class support and commitments to Java, like providing JDK with multi-year support commitments.
It is not really needed to provide JDKs or something else especially for Kotlin, because Kotlin basically just uses the JVM (at least if you use the JVM as a target).
> To this day, there are significantly fewer Kotlin developers than Java developers.
Yes, that is probably true. Although almost every Android developer should know Kotlin these days and there are quite a few them. But even if a developer doesn't know Kotlin at all, it is relatively easy for a Java developer to learn it. In my experience it a takes a few days to a few weeks to be at least as productive as with Java (even not all Kotlin features are learnt in this time).
> Lack of progress: Compared to Java lately (e.g., records two years ago, pattern matching, and VT release this year), Kotlin has been stagnating in delivering the big features that would bring us (Infobip) value over alternatives.
Here, I agree. Some years ago I was super excited about Kotlin and couldn't wait for a new release. These days new releases are mostly boring. Maybe the most important stuff is simply done, but then there are enough interesting ideas to improve it (real pattern matching, meta programming, union types, ...). But JetBrains and Google decided that it is more important to improve the fundamental infrastructure first and decided to create a new, faster compiler (K2). As boring at it is feature-wise, I think it is a wise decision, because every project would benefit from it. The plan is to add new features, once the compiler is ready.
Scala.js has excellent front-end frameworks like Slinky React [1], Laminar [2] and Scala has industry-leading concurrency libraries like ZIO [3]. I've yet to find anything that comes close for end to end web apps.
[1] https://slinky.dev [2] https://laminar.dev [3] https://zio.dev
Scala isn't dead. It went to play between the stars with Pearl and Ruby.
i love the integrated null safety / handling at a syntax level with the ? operator; optional felt clunky in comparison. lambdas plus everthing's an expression allows for concise, readable code. and i love the scope functions. i agree that extension methods may have turned out to be a footgun, but i feel like it hasn't been a huge issue in the field. it's doubtful java is able to integrate most of those ideas in a way that feels as natural.
i don't understand why the author chose to ignore android, it's an elephant in this room. as long as android doesn't drop kotlin for something else as the lingua franca of the platform it's got certain guarantees.
- Jetbrains has built a nice reactive js wrapper with them. - The gradle configuration is written in a kotlin dsl.
They can be used to specify configuration and add meta information and thus replace Java annotations.
That is my kotlin "killer" feature because I personally don't like annotations.
Java's language design has always been "pedagogical" (or patronizing) to not give the developer to much power to create to much abstractions and complexity. So it's not just its age but also this philosophy that has made Java a rather inelegant language ( compared with e.g. kotlin)
Here’s an old post discussing the real troubles Kotlin Lang might face due to the inevitable divergence of Java/JVM.
https://np.reddit.com/r/java/comments/ndwz92/can_i_get_some_...
Kotlin has better syntax and is less verbose. That matters for a lot of developers. Kotlin deals with null in a better way. Kotlin has better types.
I have seen several companies that use Kotlin as a backend language (often with Spring). I personally don't find the differences enough to bother switching from Java, but I also don't mind working with Kotlin in existing projects.
Not sure how they could get there but that would be amazing.
Also Kotlin has a pretty good JavaScript and Native support story now.
Nobody told Apple that.
Support on Mac is admittedly not the best though.
I'm biased of course having used Kotlin extensively for the last six years and having made the switch from Java. From my perspective It's simply a much better Java. And I have 25 years experience with that, mostly server side.
And the way I'm using it, it's also a better Typescript for me. If you have trouble parsing that last bit, I'm using kotlin-js to develop frontend code. It's actually really nice for that even though not many people do this. Well worth a look if you are getting tired of dealing with Javascript's idiosyncrasies (which typescript inherits) and a bit jealous of what all the cool kids doing mobile applications are using. Which would be using fancy Kotlin and Swift UI frameworks mainly.
Kotlin-js being nice to use should not be that surprising because of course a lot of Android developers use and love it and a lot of the libraries and practices port over very well to the web if you use kotlin-js. E.g. I use dependency injection (koin); which as it turns out is equally useful and nice to have in a browser as it is on Android and in Spring or other places.
There are a few changes happening this year with Kotlin that are exciting for Kotlin users and interesting for people not yet using it:
- Kotlin native is stabilizing. It now works well on IOs, Android, Linux, Windows, and MacOS. It's not "just another jvm language" anymore. The multiplatform library ecosystem is really starting to thrive. Lots of growth there. Especially in the last year. And I maintain a few myself.
- The web assembly compiler is now available in an alpha version and browser support for garbage collection in WASM just rolled out in Firefox and Chrome a few months ago. This is required by Kotlin's wasm support as it does not bundle its own garbage collector. Safari should follow soon/eventually. This means you can now use kotlin-wasm in a browser without having to fiddle with feature flags in your browser. Multiplatform library support for this is still a bit a work in progress but most kotlin multi platform libraries should start having wasm targets in the next few months. Wasm works in servers and on servers, lambda functions, and edge networking. So, first class Kotlin support for wasm is a big deal and the whole kotlin multi platform library ecosystem is coming along.
- Kotlin 2.0 is in Beta currently and should release in a few months (spring?). Kotlin native and wasm support and that are all happening at the same time and come on the tail end of a years long effort to re-engineer the compiler and IDE toolchain. Work on Kotlin 2.0 actually started about three or so years ago and it has included a gradual rewrite of the compiler through the 1.6-1.9 releases.
- Building on all this is Compose multiplatform, which brings Google's Jetpack Compose to other platforms. That's currently stable for a few platforms, in alpha versions on others (like IOS and web). That's something that should stabilize towards the end of the year. We'll have a cross platform, natively compiling UI framework that is usable across web (wasm), IOS (native), Android (native) and the three Desktop platforms (jvm, for now). So, that could end up being a nice alternative to things like flutter and react-native. Or indeed to packaging up web applications as PWAs or using things like electron.
It might not be everybody's cup of tea but that's a lot of progress that came together in the last year. I use other languages besides Kotlin. So, I can appreciate other languages as well. But Kotlin is just really nice.