Live data from Hacker News

Java 27

mail.openjdk.org

271–280 of 424 posts

Re: Java 27

#271
post #89

Earlier quoted context omitted.

Interesting take, how is optional functionality annoying? Isn't the fact that it's just sugar a huge benefit? Us old timers can simply stick to what we're familiar with.

(GP here) > Isn't the fact that it's just sugar a huge benefit? My main gripe is that I cannot remember what is allowed and not allowed between multiple versions of the same language. On a daily basis I hop between apps versioned in .NET Framework 4.8 all the way to .NET 10. I have to constant remember, are nullable types allowed here? What about 'new(); vs. new Object();', new collection syntax, new switch syntax, n…

Some of those ways come from just plain object initialisers. Which are amazing and sorely needed in Java.

That's why you get `new List { };` Because it could be `new ComplexObject { }`.

Same for `new`.

Some come from type inference which Java also has.

That's why you can have `List foo = new List();` and `var foo = new List();`

It's not really "7 ways to assign a new empty List". It's "7 ways to create an object", and Java several of them, too.

Re: Java 27

#272
post #251

Earlier quoted context omitted.

> because of essential constraints of low-level languages that prevent them from doing certain optimisations that matter mostly in large programs Which specific optimizations are you referring to? In my experience, this is largely a myth; compared to Rust, you actually get even faster code right away. JIT is effective for languages where the source code lacks sufficient information (dynamic typing, where anything can…

> Which specific optimizations are you referring to? A JIT with speculative optimisation and a moving GC. There are two constraints in low-level languages that trump any of their performance goals, one technical and one a matter of preference. The technical limitation is that they must use stable pointers (because they need to be low-level and so having an FFI layer that separates "hardware pointers" from "language p…

Thank you for the reply.

Do you mind a reasoned discussion?

> A JIT with speculative optimisation and a moving GC.

Idiomatic Rust, through its concepts of ownership and borrowing, encourages a pattern where you receive data as an argument or create it directly, perform operations on it, and then discard it via RAII. This bears some resemblance to functional programming. This approach does not apply to buffers of unknown size, which still require heap allocation; unfortunately, Rust lacks automatic buffer reuse. However, such optimization is theoretically possible. The stack is definitely faster than anything else.

> This means that you need to translate data storage or code storage to hardware addresses, and that interferes with both moving collection and with JIT compilation.

You don't need GC if you allocate data on stack. You also do not need to dereference the pointer.

> dynamic dispatch

You mentioned templates. In Rust, traits that are monomorphized - much like templates-are the standard approach; using vtables or `dyn trait` is a relatively rare use case. This stems from the fact that all code is known at compile time and there is no dynamic loading, allowing the compiler to eliminate polymorphism from the code entirely.

> and shared heap objects

This might be considered convenient, but in my view, it also leads to code that is harder to maintain when objects can be modified from multiple places. However, I think that is outside the scope of the current discussion.

> We get around it with selective use of templates in C++ (or comptime in Zig), but it has to be selective, and it's viral.

Yes, monomorphization is the default solution in Rust. It is not always viral either, because when using it, you often define specific types, and they do not spread beyond that scope.

I suppose you could say that the programming style I am talking about is complex, inconvenient, unmaintainable, and so on. What I mean is, assuming this programming style is sufficiently convenient—and perhaps even has its own advantages - then none of the optimizations you listed offer an edge, and the Rust code will definitely be faster.

Re: Java 27

#273
post #225

Earlier quoted context omitted.

in my healthcare experience (claims processing, medtech) Java existed for sure but it was always as a "legacy" system they were moving away from.

What were they moving towards?

We embedded angular in our old Java client for hospitals. The user thinks he just opens a new window, but it's chrome in Java, which opens angular frontend, for our Java backend.

Re: Java 27

#274
post #5

C# dev here: it’s amazing how different this is from a Microsoft release. First off, Oracle are doing versions at approximately twice the cadence. But also, and I’m guessing this is a function of the much larger Java audience: things rarely get two preview versions in a proper release. Updates in beta versions, yes, all the time. It also feels like Microsoft are bundling a lot more into the platform and leaving less…

I never thought of Java being the 'move fast ~and break things~' alternative over .NET, but Java has a faster release schedule to get features out sooner.

Move fast and break things does not describe Java well at all.

Their process is still very deliberate, they go to some lengths to avoid getting it wrong when they add new features to the standard. New features have to get through their preview phase successfully before becoming final. [0]

They're also pretty committed to not breaking existing source code or bytecode.

[0] https://openjdk.org/jeps/12 JEP 12: Preview Features

Re: Java 27

#275
post #261

Earlier quoted context omitted.

While Java can outperform Go in some cases, the situation is very much the opposite when it comes to Rust. I also don't see the case for stability. Yes, if you're still on JDK 8, it would probably chug on for a couple of years. But we were talking about greenfield projects and newer JDK go EOL much faster. If you want patches, you'll have to run your app to a newer JDK, which may break a couple of things. Rust (withi…

> the situation is very much the opposite when it comes to Rust. It isn't, and the problem isn't Rust specifically, but all low-level languages. They can offer very good performance (often better than Java) when small. But as they evolve over time, or are very large to begin with, they become much harder to keep performant. This is for pretty fundamental constraints of low-level language that I mention in another com…

> Time and again we see Rust or C++ programs spend 30-50% on memory management.

30-50% of what?

Re: Java 27

#276

Earlier quoted context omitted.

One difference I think about is generics. Java and .NET bolted generics on to an existing system. Java used type erasure in such a way that a List is really just a List. Type erasure has a lot of limitations. If I am coding in Java for days I never get into trouble with it because I know how to color in the lines. But do some balls-to-the-walls metaprogramming and then it is annoying that you can't write Expression a…

This should address your example https://openjdk.org/jeps/218

That's about letting you do Expression, not about removing type erasure or otherwise allowing overloads based on type parameters.

Re: Java 27

#277
post #265

Earlier quoted context omitted.

Once it gets nullness types, hackernews is gonna explode!

Wait is this why people keep complaining about NPE? Is the nullness type thing a dog whistle for Kotlin? lol

Yes.. lol. The biggest argument now is Kotlin having nullness by default in the language. Just check around the comment section. Now java is planning to have them which will further help jvm to optimise for performance. Not sure what the next argument will be after.

Re: Java 27

#278

Earlier quoted context omitted.

Go and Rust have much worse tooling for enterprise-level collaboration

I'm not sure what enterprise-level collaboration means. In my experience, "enterprise" usually means: "Let's use tools that are 10 years behind, buggier than average, and have lots of half-baked features, none of which we need". I'm not sure what kind of tools you mean, but unless you're looking for something that just works exactly the way EJBs do for some mysterious reasons, I don't see why you can't do most "enter…

> Let's use tools that are 10 years behind

Yes and that's exactly what modern tooling is missing. Try to develop for node.js 0.2.12 on today's update of Visual Studio Code. See? No enterprise-level collaboration for ya.

Re: Java 27

#279

Earlier quoted context omitted.

We have a java monorepo of relatively large size and sophistication, driving our entire fintech, and I haven't seen a NPE for years. Use NullAway and it basically makes the problem go away. Our application won't build if it detects a potential NPE.

Congratulations. You've added another build tool and sprinkled your code with ugly annotations and ifs and Optional Optional.of(x).map(y) all over the place to get the same thing you'd get by moving to Kotlin. I get it why this seems like a less drastic change, but this saddens me. Kotlin solves more issues with the type system (smart casts, reified types, immutability by default), without sacrificing readability. Un…

I don't really think about it too much, it works fine. We don't use Optionals, I'm not sure why you brought that up. I'm not a dogmatic person in this respect, rather pragmatic. I'm sure Kotlin is great, and I'd enjoy writing it, but for now, the vast majority of the finance world runs on Java, so it's what we use. I find it easy to work with, which counts for a lot.

Re: Java 27

#280
post #26

Serious question: when should one use Java for greenfield projects in 2026?

When building boring web applications with a sizeable team that need to run for a long time. Hiring developers is easy since there are many, there is nearly no magic and the language is quite strict and type safe so it works well with a large team. And that "team" nowadays may also consist of many AI agents. In my experience Claude Code for example works very well with a typed, slightly boring language with lots of f…

Re: Java 27. I work with TON and this looks like something I can build. No pressure, but I can walk you through the approach if you want.
Post reply on HN