News for hackers. Stuff that matters.
Re:JDK 19 Release Notes by dbrgn on Tuesday September 20, 2022 @08:01AM (#32910528)
Nice new language features for Java users! sobs in Android-Java8
Re:JDK 19 Release Notes by rr888 on Tuesday September 20, 2022 @09:50AM (#32911649)
Is there a path to upgrading Java on Android? Surely new Android releases could do easily?
Re:JDK 19 Release Notes by dbrgn on Friday September 23, 2022 @11:50AM (#32953583)
No, because Dalvik (https://en.wikipedia.org/wiki/Dalvik_(software)) / ART (https://en.wikipedia.org/wiki/Android_Runtime) are forks of Java. New features need to be re-implemented due to licensing issues. And Google seems to be focussed more on Kotlin than on newer Java features.
Re:JDK 19 Release Notes by nine_k on Tuesday September 20, 2022 @08:08AM (#32910587)
Android? Why not Kotlin then?
Re:JDK 19 Release Notes by pjmlp on Tuesday September 20, 2022 @09:20AM (#32911274)
Because regardless of Kotlin, modern Java libraries won't be usable on Android, despite the marketing how "compatible" Kotlin happens to be with Java.
Re:JDK 19 Release Notes by nradov on Tuesday September 20, 2022 @08:27AM (#32910741)
Kotlin is certainly a good general purpose language. But many developers would prefer to be able to use Java for Android development including the excellent tool chain and numerous libraries. It's a shame that commercial disputes between Google and Oracle have left us with this fragmented platform.
Re:JDK 19 Release Notes by pjmlp on Tuesday September 20, 2022 @09:22AM (#32911298)
Kotlin is still heavily dependent on Java ecosystem, so this excuse is nonsense, there is hardly any Kotlin without Java.

See how sucessfull Kotlin/JS and Kotlin/Native are on the wild.

Re:JDK 19 Release Notes by Strum355 on Tuesday September 20, 2022 @08:32AM (#32910781)
> the excellent toolchain and numerous libraries

The same libraries that can be used from Kotlin?

Re:JDK 19 Release Notes by pjmlp on Tuesday September 20, 2022 @09:22AM (#32911294)
Only if they can be usable from ART capabilities, and desugared into DEX opcodes.
Re:JDK 19 Release Notes by cies on Tuesday September 20, 2022 @08:43AM (#32910880)
> the excellent toolchain and numerous libraries

The toolchain in both cases is basically IntelliJ (rebranded as Adroid Studio)

Re:JDK 19 Release Notes by Alupis on Tuesday September 20, 2022 @11:35AM (#32913193)
Give Kotlin an honest try. I think you will be impressed... and that's coming from a crusty old curmudgeon "get off my compiler" java fanboy.
Re:JDK 19 Release Notes by dbrgn on Tuesday September 20, 2022 @09:00AM (#32911045)
You're right, and I use Kotlin for all new projects. However, when working with legacy code and with teams that aren't familiar with Kotlin, introducing a newer Java version is much easier than introducing an entirely new language.
Re:JDK 19 Release Notes by tut-urut-utut on Tuesday September 20, 2022 @08:49AM (#32910939)
Why learning a whole new language just because vendor refuses to upgrade?

At that point one could also say "why Anrdoid?".

Re:JDK 19 Release Notes by wlpu on Tuesday September 20, 2022 @09:05AM (#32911110)
Because you can use the same toolchains, APIs, libraries, and even progressively migrate with both languages in the same project. Honestly, people who whine about Java 8 in Android and refuse to consider Kotlin are suffering by choice.
Re:JDK 19 Release Notes by pjmlp on Tuesday September 20, 2022 @09:24AM (#32911324)
Only those that can be desuagared into Android Java, everything else will fail to either compile or map into ART features.
Re:JDK 19 Release Notes by kuschku on Tuesday September 20, 2022 @10:18AM (#32911974)
All of Kotlin runs fine on Android, that's its point, that all of it can be desugared to run on a 1.6 or 1.8 JVM?
Re:JDK 19 Release Notes by pjmlp on Tuesday September 20, 2022 @11:25AM (#32913025)
If you don't want to use modern Java libraries as third party depedencies then all good.

Now if you plan to dynamically link to Java libraries that require JVM opcodes without counterparts on DEX, SIMD, Panama, Java Standard Library post Java 11, then thought luck.

See it as an opportunity to learn how to use the NDK (for SIMD), or write your own Kotlin versions.

Re:JDK 19 Release Notes by waynesonfire on Tuesday September 20, 2022 @08:22AM (#32910697)
Java 8 is fine and the argument to replace it with kotlin has to be very compelling.

Kotlin was designed to replace Java 1.6 and that's about all it's good for.

Re:JDK 19 Release Notes by cies on Tuesday September 20, 2022 @08:42AM (#32910868)
> Kotlin was designed to replace Java 1.6 and that's about all it's good for.

Not sure what K was designed for. But we use it to fix J's billion dollar "implicit nulls" mistake, and terse syntax (making it useful for templating: Kotlinx.html), and pass-as-value method references. We love it's hang towards immutability.

K is not Haskell, but it sure feels a lot safer that J (where a lot of strings were used to refer to methods, and strings+Groovy was used to do templates).

Bottom line: I'm too old --and life's too short-- for NPEs.

Re:JDK 19 Release Notes by flatiron on Tuesday September 20, 2022 @08:51AM (#32910956)
Have your tried static analysis? When I used Java most (if not all) of our NPE problems were pointed out by sonar qube
Re:JDK 19 Release Notes by hn_throwaway_99 on Tuesday September 20, 2022 @12:48PM (#32914406)
Ugh, to hear what hackarounds folks have to deal with in the Java ecosystem is kind of frightening.

I moved from Java to Node (then Typescript) about 8 years ago. Moving to a language that doesn't allow implicit nulls makes a world of difference, importantly, at "programmer" time, not just build time.

That is, when programming in VSCode, I immediately get feedback if I attempt to use a nullable variable in an unsafe manner. That has huge productivity benefits compared to if I only got that feedback after my build ran.

Similarly, simple things like safe optional chaining (i.e. foo?.bar?.baz) makes code so much faster and easier to write, and AFAIK this hasn't been added to Java yet (correct me if I'm wrong).

Re:JDK 19 Release Notes by cies on Tuesday September 20, 2022 @10:02AM (#32911779)
Yes. But coupled with our Groovy templates (that we're now moving to Kotlinx.html) it did not really help much. This is not Java's problem per se (though one could argue that J's verbose syntax prohibits it for in-code HTML templating)
Re:JDK 19 Release Notes by ris58h on Tuesday September 20, 2022 @09:18AM (#32911253)
What if I don't want to put @Nullable/@NotNull all over the code?
Re:JDK 19 Release Notes by seer-zig on Tuesday September 20, 2022 @02:01PM (#32915488)
Can't you setup your project to be `@NotNull` by default, and explicitly mark @Nullable fields? Those should be more rare anyway.
Re:JDK 19 Release Notes by grishka on Tuesday September 20, 2022 @09:44AM (#32911564)
You can use Java 17 on Android, except features that require new classes and/or methods, obviously.
Re:JDK 19 Release Notes by svieira on Tuesday September 20, 2022 @01:28PM (#32914976)
sobs in j2objc AND sobs in GWT/J2CL