Live data from Hacker News

Java 21 makes me like Java again

wscp.dev

491–500 of 777 posts

Re: Java 21 makes me like Java again

#491
post #477
post #278

Earlier quoted context omitted.

> not so great if you want to distribute software for people who are not software savvy, who typically just wants to download one file, install and start using it. i think it's a flaw that wasn't considered properly in the standard java toolchain to not produce an embedded java runtime into a final packaged artifact that is self-executable. You end up with third party tooling like: https://www.ej-technologies.com/res…

There is jpackage and jlink, which don't do single files but make single directory apps. These days there's also GraalVM native image which does produce Go-like results. But with everyone using Docker on the server anyway it doesn't matter anymore. People who talk about single binaries are confusing to me. What are you doing where shipping one file is so much simpler than shipping a container?

> What are you doing where shipping one file is so much simpler than shipping a container?

Desktop applications.

Java would be a more popular desktop application platform if it weren't for the difficulty in this area (which, to be fair, isn't the only difficulty - cross platform is difficult inherently).

Re: Java 21 makes me like Java again

#492
post #366

The biggest feature in Java 21 is the release of Virtual Threads: https://openjdk.org/jeps/444 For some reason, this is missing from the article. If there was any feature that would sway existing Golang developers to switch to Java, it would be this. It would perhaps also convince the haters of the reactive-style concurrency patterns.

> The biggest feature in Java 21 is the release of Virtual Threads Is there a good honest writeup on why is this interesting? Very curious. The earliest JVMs had this, green threads. Performance was terrible so it was eventually dropped. I want to fully utilize every CPU and every core I have, why do I want green/virtual threads again?

It's not the same. The earliest JVMs weren't really thread safe at all but machines were single core so it didn't matter, you could just cooperatively multi-task.

Later HotSpot became thread safe (and fast - a rare achievement), so started using real OS threads so it could go multi-core.

Virtual threads are M:N threading. There are multiple native threads so you can exploit all the cores, and also user-space runtime managed stacks so you can pack way more threads into a process.

Re: Java 21 makes me like Java again

#493
post #482
post #329

Earlier quoted context omitted.

Java's build times are very fast. Java's build tools are anything but. And I'm surprised no one is doing anything about it.

Gradle, when the daemon is runnning is very fast, people just often fck up their build scripts to include config-time run functionality, which is just all around a stupid thing to do. It only ever runs tasks that actually have to be run, has integration with javac, can work in parallel, and even has cross-company build caches if needed. Also don't forget that Java can do hot reloads with the debugger, or with tools l…

I've never seen Gradle run fast, even with the daemon running. Gradle itself can take multiple seconds to startup. God knows what it's doing.

Re: Java 21 makes me like Java again

#494

Earlier quoted context omitted.

As a Kotlin dev you should still be excited by virtual threads in Java 21. You'll never have to use coroutines again.

I'm very curious to see how this works out in the Kotlin ecosystem, given the amount of async code out there (and the associated function coloring issues).

You can easily combine the two, just use a virtual thread and when you hit a `suspend` function use `runBlocking` to get rid of the suspension.

Re: Java 21 makes me like Java again

#495
post #480

Earlier quoted context omitted.

There isn't all that many plus in their type systems that is not expressible in Java. OCaml and Haskell has Monads, sure. There is Scala for that on the JVM.

> There isn't all that many plus in their type systems that is not expressible in Java. Thanks to Turing, anything that is Turing-complete can duplicate any other thing that is Turing-complete. So, yes, you can do all of Haskell's types in Java. That is not a flex. The flex is doing them in a non-horrific way.

The kind of Turing completeness certain type systems have is useless beside academic curiosity - look at the vavr library, that’s what I’m talking about. You can have plenty Haskell types without any hacks, except for Monads in Java.

Re: Java 21 makes me like Java again

#497
post #40

Earlier quoted context omitted.

Please ELI5 what is wrong with inheritance and/or how Java have it wrong. Do we need to go back to a new object oriented undegraduate course? Genuinely asking.

With compositions A uses B but B can never use A. With inheritance Child can use the Parent, but Parent will also call the Child (virtual methods) which in turn can call the Parent again etc.., so the code can become difficult to follow. It can become very complicated with multiple inheritance and multiple levels.

Such code would be difficult to follow regardless of whether you use inheritance or not. Sometimes, two pieces of code developed independently just need to interact very closely with each other.

Remember that OOP and inheritance to some extent came out of the need to develop GUI systems. Inheritance is still heavily used in GUI toolkits because it's a good fit for that problem space. You have graphs of objects that need to be treated at different levels of abstraction, and controls often need to customize (override) or implement some behavior that shouldn't itself be a part of the public API.

Attempts to get rid of inheritance and OOP in UIs end up looking like Compose or React. I found very quickly when working with these that pure composition just wasn't sufficient and these approaches have their own issues; problems that OOP trivially solves become difficult to impossible to solve cleanly without it.

Re: Java 21 makes me like Java again

#498
post #495

Earlier quoted context omitted.

> There isn't all that many plus in their type systems that is not expressible in Java. Thanks to Turing, anything that is Turing-complete can duplicate any other thing that is Turing-complete. So, yes, you can do all of Haskell's types in Java. That is not a flex. The flex is doing them in a non-horrific way.

The kind of Turing completeness certain type systems have is useless beside academic curiosity - look at the vavr library, that’s what I’m talking about. You can have plenty Haskell types without any hacks, except for Monads in Java.

> vavr - turns java™ upside down

"turn X upside down" are different words for "use X contrary to its original intention and design".

You will find very few people willing to let go what people undestand as Java so as to be able to do Haskell-in-Java.

Re: Java 21 makes me like Java again

#499
post #495

Earlier quoted context omitted.

The kind of Turing completeness certain type systems have is useless beside academic curiosity - look at the vavr library, that’s what I’m talking about. You can have plenty Haskell types without any hacks, except for Monads in Java.

> vavr - turns java™ upside down "turn X upside down" are different words for "use X contrary to its original intention and design". You will find very few people willing to let go what people undestand as Java so as to be able to do Haskell-in-Java.

It’s goddamn immutable collections and Optionals, not brain surgery come on.

It’s not like Java hasn’t been going in the same direction, see records, sum types, pattern matching.

Re: Java 21 makes me like Java again

#500
post #429

Earlier quoted context omitted.

Read David Fowler's guidelines.

Do you have link to any specific article of his (on virtual threads vs async)?

Here,

https://github.com/davidfowl/AspNetCoreDiagnosticScenarios/b...

https://github.com/dotnet/runtimelab/issues/2398

Post reply on HN