Live data from Hacker News

Java 20 / JDK 20: General Availability

mail.openjdk.org

321–330 of 356 posts

Re: Java 20 / JDK 20: General Availability

#321

Earlier quoted context omitted.

C#, owned by the most ethical company in software. Java is very different and much improved from when c# branched off, but many people haven’t been following along and still think it’s the same as in 2002.

This is 2023 and you are saying that Microsoft is less ethical than Oracle. A lot of things have happened since the 90s, you know?

Sure things changed. But some things will stay the same 'till end of time. Like Oracle and M$.

Re: Java 20 / JDK 20: General Availability

#322
post #182
post #74

Earlier quoted context omitted.

Java 8 is an antiquated runtime. You're doing a disservice to your customers and developers by continuing to use it.

Java 8 is working runtime. Whats wrong in using runtime that works?

Do you drive an old-timer, with the same justification?

Re: Java 20 / JDK 20: General Availability

#323

Earlier quoted context omitted.

I haven't looked into CLR in a long time, but it feels like it has a fraction of JVM's adoption and community size. Microsoft also seems to be prioritizing Typescript and Node internally with its recent moves.

> Microsoft also seems to be prioritizing Typescript and Node internally with its recent moves. You may want to look at Blazor Webassembly ( https://dotnet.microsoft.com/en-us/apps/aspnet/web-apps/blaz... ) and Blazor United ( https://devblogs.microsoft.com/dotnet/asp-net-core-updates-i... ) They scrapped the old CLR and started over with a new "CLR Core". Then they ported the new CLR Core along with the framework BC…

[deleted]

Re: Java 20 / JDK 20: General Availability

#324

Earlier quoted context omitted.

When I’ve asked chatgpt to explain something to me that I’m very knowledgeable about, distributed systems, it was flat out wrong about many fundamentals in a way that would have seemed completely plausible to a novice. It was making up algorithms, complete with fake but believable names, to solve problems that are provably unsolvable. My wife, a physician, reported similar errors when I got her to ask it medical ques…

You have to provide more context, so that it has something to bridge in the high dimensional space. > The Byzantine Generals Problem is a more difficult problem than the Two Generals Problem because it requires a consensus algorithm that can tolerate the presence of faulty actors. There are many solutions to the Byzantine Generals Problem, including Byzantine Fault Tolerance, which is a common technique used in distr…

You're supporting their point. You can't go to ChatGPT for knowledge you don't already have because it will confidently spout garbage, which is what was being suggested "whats new in java X". If you can build that bridge yourself then you aren't asking it for knowledge, you're asking it to format things for you.

Re: Java 20 / JDK 20: General Availability

#325

Earlier quoted context omitted.

Yes. And with "records" (record classes, something with the characteristics of a tuple or struct) you can get further away from getter/setter boilerplate code.

I just wish records had an easy way to facilitate and/or associate a builder with them. Wishful thinking, out of scope for what they are. And of course, it's not hard to write a FooBuilder that's defined to help construct a Foo record. If Java records could be told to have a private constructor, I'd be completely satisfied with them. I just don't like the ability for callers to be able to directly instantiate a recor…

> I want to completely enforce that my record is instantiated with all its invariants dealt with properly

Such validation logic can be enforced in the record's compact constructor.

Re: Java 20 / JDK 20: General Availability

#326
post #297
post #145

Structured concurrency looks a lot like C#'s Task library without the async/await sugar but with the exact same footguns. Joining into a synchronous function is an anti-pattern in C# because you consume threads. This seems to be the same, except with the assumption that virtual threads are fine.... But that's not an assumption that can be made by the method writer, right?

Tasks aren't threads in TPL.

[deleted]

Re: Java 20 / JDK 20: General Availability

#327
post #297
post #145

Structured concurrency looks a lot like C#'s Task library without the async/await sugar but with the exact same footguns. Joining into a synchronous function is an anti-pattern in C# because you consume threads. This seems to be the same, except with the assumption that virtual threads are fine.... But that's not an assumption that can be made by the method writer, right?

Tasks aren't threads in TPL.

What are you trying to say? They still run on threads and can consume them.

Re: Java 20 / JDK 20: General Availability

#328
post #276

Earlier quoted context omitted.

This is impossible because of *gasp function coloring. You can't just make a sync function async without dealing with the fallout explicitly in c#.

You can make an async function contain an await at more places than it previously had. When writing code in colored languages your code tends towards lots of stuff being marked async, so more 'await' points being introduced can change behavior.

You're saying something is bad because it could affect a race condition you had? Doesn't everything fall under that issue? That's not changing from invariant to variant.

Re: Java 20 / JDK 20: General Availability

#329

Earlier quoted context omitted.

> low resource usage of async/await Will calling a coroutine do zero heap allocations like async in Rust? > with the ease-of-use experience of threads That's highly subjective. Threads usually require locking which is often hard to get performant and correct at the same time. Async/await allows to write concurrent code with no synchronization.

> Async/await allows to write concurrent code with no synchronization. Hmm,I don't see how async/awaits makes a difference. Care to explain? Like, if you have multiple sources that can add or read from a queue, unless there is a single thread running all your async loops (ala python), you still need some synchronization. At least that's my experience using coroutines heavily in kotlin.

I'm talking from perspective of Rust's async/await implementation, I'm not sure if the same holds for other languages with async like C# or Kotlin. Nevertheless I can do a loop like this:

    let mut buffer = ... // create buffer for holding data
    let mut input: TcpStream = ... // connect to remote endpoint
    let mut output: TcpStream = ... // connect to remote endpoint
    loop {
       select! {
          _ = input.readable() => {
              input.try_read(&mut buffer)?;
          }
          _ = output.writable(), if !buffer.is_empty() {
              output.try_write(&mut buffer)?;
          }
       }
    }
The mutable buffer is shared between the part that reads from input and the part that writes to output, and reads/writes happen concurrently and independently. Yet there is no explicit locking anywhere!

Synchronization is achieved implicitly by the fact that sequential code executes in only one place at once, so when it executes the reading branch, it does not execute the writing branch. You can apply exactly same reasoning as with any single-threaded, sequential code.

You cannot model this easily with threads. If it was a single thread with blocking I/O, then it could block forever in one branch and stop reacting to events on other branches. If it were multiple threads, then they would somehow need to synchronize accesses explicitly to the shared buffer.

Re: Java 20 / JDK 20: General Availability

#330
post #201

Earlier quoted context omitted.

GNU Pth had "automagically turning blocking operations into non-blocking" ages ago, and it wasn't the first. I think what you probably had in mind is that C libraries of the 90s that did M:N threading didn't turn blocking operations into non-blocking? Using blocking operations to switch contexts is really nothing new. Heck, the cooperative multi-tasking systems of the 80s (Mac, Amiga) all essentially did that for pro…

> I think what you probably had in mind is that C libraries of the 90s that did M:N threading didn't turn blocking operations into non-blocking Yes, mostly, though my history knowledge is definitely lacking so do correct me if I’m wrong. But you are right, there was nothing fundamentally missing, probably just no good OS support for non-blocking IO calls in the early days? Though probably the IO-CPU ratio was also di…

There were bad experiences with the M:N threading of the 90s in Solaris' and others' C libraries. Making those libraries make every file descriptor non-blocking behind the programmer's back was a tricky thing. Think about inheritance of file descriptors via fork() and exec() -- you could have one threaded process sharing an FD with a non-threaded process, and now even non-threaded processes' C library would have to poll(), and now add static linking with older C libraries to the mix and it just couldn't be done. So it wasn't done.
Post reply on HN