5 ms·
I am quite disappointed - if Java is supposed to compete with Kotlin, they should not just provide an inferior clone of Kotlin features, but push it a step furt
by llcoolv 7y ago
I am quite disappointed - if Java is supposed to compete with Kotlin, they should not just provide an inferior clone of Kotlin features, but push it a step further. Here, it is not the case as those records are basically Kotlin data classes, but not really well thought out.
Unfortunately since Oracle took over, Java as a language went in a very dull direction.
- kasperni 7y agoYou do know that the concept of records/data classes goes back long before Kotlin? And what exactly are you missing?
- llcoolv 7y agoWhen it comes to popular languages on the JVM, it doesn't go before Kotlin as Scala was never a popular language to begin with. One thing I and a lot of people are missing is annotations, with them data classes in Kotlin are useful for JPA/REST/AMQP/etc DTOs. Another convenience would be the ability to add at least mapping methods like in Kotlin or implement interfaces (Serializable anyone?) Java records are going to be yet another barely used feature.
- _old_dude_ 7y agoRecord are product types, with union types (sealed types in Java speak) you get algebraic data type, you can take a look to SML to understand why there will be used a lot. Record have an automatic way to propagate annotations from the record component to the generated methods/fields and comes with native support of serialization (like enums).
- llcoolv 7y agoCould you show an example of it? In none of the materials published so far there is anything even remotely similar to what you are suggesting.
- krzyk 7y agohttp://cr.openjdk.java.net/~briangoetz/amber/datum.html http://cr.openjdk.java.net/~briangoetz/amber/datum.html There you can read about algebraic data types in java, in Java 14 you get preview for records in Java 15 probably you'll get preview for sealed types - they were developed together for some time, only recently there was a split.
- dtech 7y agoI highly doubt they are going to be an unused feature, as Java is full of POJO's I expect the current annotation-based libraries will start supporting record classes too.
- angus_gh 7y agoWhere did you get the idea that records can't use annotations, have methods, or implement interfaces?: "Beyond the restrictions above, records behave like normal classes: they can be declared top level or nested, they can be generic, they can implement interfaces, and they are instantiated via the new keyword. The record's body may declare static methods, static fields, static initializers, constructors, instance methods, and nested types. The record, and the individual components in a state description, may be annotated." https://openjdk.java.net/jeps/359 https://openjdk.java.net/jeps/359
- AnimalMuppet 7y agoAre you saying that Scala isn't popular, but Kotlin is? If so, what threshold are you using for "popular", that you think Kotlin exceeds but Scala doesn't?
- lokedhs 7y agoI think being the recommended language for Android development makes it pretty popular.
- AnimalMuppet 7y agoReplying late, so you probably won't see this. Replying anyway, so I look less stupid in the future. The survey SureshG put forward (in a post parallel to yours) shows Kotlin twice the size of Scala (which surprised me), and Java something like 15 times the size of Kotlin. So to say that Kotlin is popular, but Scala isn't, seems to me to be drawing the line in a fairly arbitrary place. It seems more reasonable to say that neither is popular, or that both are. "But Android" you say. Well, that will make Kotlin pretty popular, but it hasn't yet. In the future, you'll be right. That's why I added this. In the future, my post is going to look pretty silly without this context.
- SureshG 7y agoMore recent JVM ecosystem survey - https://snyk.io/blog/kotlin-overtakes-scala-and-clojure-to-become-the-2nd-most-popular-language-on-the-jvm/ https://snyk.io/blog/kotlin-overtakes-scala-and-clojure-to-b...
- fulafel 7y agoInteresting survey, any ideas about what the audience of the survey was? (For trying to understand what kind of biases it might have in regards to non-Java languages)
- pkolaczk 7y agoScala is still far more more popular than Kotlin. https://redmonk.com/sogrady/2019/07/18/language-rankings-6-19/ https://redmonk.com/sogrady/2019/07/18/language-rankings-6-1... Scala 13th, Kotlin 20th.
- SureshG 7y agoI know Redmonk has reasonably believable language rankings, but a recent JVM ecosystem survey says otherwise - https://snyk.io/blog/kotlin-overtakes-scala-and-clojure-to-become-the-2nd-most-popular-language-on-the-jvm/ https://snyk.io/blog/kotlin-overtakes-scala-and-clojure-to-b...
- pjmlp 7y agoKotlin fans keep forgetting that without the Java platform, meaning the JVM, standard library and Maven central, Kotlin would be a non-starter. No guest language ever took over a platform.