Live data from Hacker News

All New Java Language Features Since Java 21

inside.java

21–30 of 130 posts

Re: All New Java Language Features Since Java 21

#21
post #10
post #4

I am a big functional programming geek. I am one of the few people on the planet who can honestly say I have been paid to write F#, Haskell, Clojure, and Erlang. I have spoken at FP conferences like six or seven times, and I have shit on Java for most of my career. And yet, my latest talk at Lambda Days basically boiled down to “Java 21 and later don’t actually suck anymore”, and I genuinely do mean that. Java 21 is…

I don’t use Java often, but many developers at my workplace do; they universally hate the new FP features.

And then there are those of us who have used Java for a long time who feel the FP features make Java tolerable.

Re: All New Java Language Features Since Java 21

#22
post #10
post #4

I am a big functional programming geek. I am one of the few people on the planet who can honestly say I have been paid to write F#, Haskell, Clojure, and Erlang. I have spoken at FP conferences like six or seven times, and I have shit on Java for most of my career. And yet, my latest talk at Lambda Days basically boiled down to “Java 21 and later don’t actually suck anymore”, and I genuinely do mean that. Java 21 is…

I don’t use Java often, but many developers at my workplace do; they universally hate the new FP features.

This is precisely my point. For a lot of Java programmers anything that they didn’t learn in university is “bad”, as far as I can tell, purely because they don’t want to actually learn new things.

They’ll give half-hearted justifications that are usually reductive or just flat out lies [1], but ultimately it seems to boil down to new=bad.

The amount of terrible code I have had to debug because Java programmers haven’t figured out you can use queues is upsetting, because all they learned in university is how to use `synchronized` wrong.

[1] I have learned that nearly every time someone says their disgusting code is “faster”, even when they claimed they tested it, it is almost universally untrue when I write a microbenchmark to check it.

Re: All New Java Language Features Since Java 21

#23
post #8

Earlier quoted context omitted.

> You mention "var", why would we ever want in Java to hold a variable that you can't read immediately what is the type? var items = new HashMap(); Instead of HashMap items = new HashMap(); That's the point of var. It reduces noise a lot in some situations.

You should write Map items = new HashMap (); It allows you to limit `items` usage to `Map` supertype and allows you to swap implementation easily, if necessary. `var` is weird feature, because it allows people to use implementation-specific methods methods and tie code to a single implementation, essentially making it less agile. There are valid use-cases for `var`, but IMO this feature should not have been added to…

Your example isn’t good though; var is only for local variables, which should be perfectly allowed to use implementation-specific methods.

For argument types you don’t have var, so methods that take in a map can stay abstract and you can still pass in the implementation-specific version into those without casting it to the interface.

ETA:

I guess I am trying to say that if you want to be abstract, they should be at the argument or properties level. Local variables should be used locally. I agree that generally speaking you should try and prefer using Map for anything shared across different parts of code but I am not convinced it’s bad to have var be implementation-specific; if your method is big enough to where swapping out implementations like this will take a lot of time, your method is probably too big anyway.

Re: All New Java Language Features Since Java 21

#24
post #18

The only new feature I might use since 1.8 (that only had NIO stability and GC improvements over 1.7) are the virtual threads without pinning in 24.

We extensively use vars, switch expressions, collector methods, String format methods, records, instanceof narrowing. Just from the top of my head.

Re: All New Java Language Features Since Java 21

#25
post #17
post #10

Earlier quoted context omitted.

I don’t use Java often, but many developers at my workplace do; they universally hate the new FP features.

Everyone seems to love them at my workplace and in /r/java.

That's called selection bias for both of you. Reddit will expel anyone whose opinion does not correspond to the local mob bias. Workplaces select people who are similar to already working ones.

Re: All New Java Language Features Since Java 21

#26
post #15
post #12

Earlier quoted context omitted.

The new features make the code easier to read. For example var: List accounts = List.of(new Account(1), new Account(2)); var accounts = List.of(new Account(1), new Account(2)); It just reduces visual noise and boilerplate that you already know. Java 8 is also a slow and old runtime. It performs terribly in 2025. Here’s a quote from 2020 and the gap has only gotten wider [0]: > JDK 8 is an antiquated runtime. The defa…

Using Java 8 doesn't mean using the java 8 JDK. It just means not using the newer features. I don't see anything in the parents post about restricting which JDK they use.

> Java 8 was the peak of development age for the JDK.

Still glorifying it.

Re: All New Java Language Features Since Java 21

#27
post #8

Earlier quoted context omitted.

> You mention "var", why would we ever want in Java to hold a variable that you can't read immediately what is the type? var items = new HashMap(); Instead of HashMap items = new HashMap(); That's the point of var. It reduces noise a lot in some situations.

You should write Map items = new HashMap (); It allows you to limit `items` usage to `Map` supertype and allows you to swap implementation easily, if necessary. `var` is weird feature, because it allows people to use implementation-specific methods methods and tie code to a single implementation, essentially making it less agile. There are valid use-cases for `var`, but IMO this feature should not have been added to…

No, you shouldn't write that. Your variable should represent the complete implementation. Where you use it should be as generic as possible, for example, the parameter in a function call.

Re: All New Java Language Features Since Java 21

#28
post #17

Earlier quoted context omitted.

Everyone seems to love them at my workplace and in /r/java.

That's called selection bias for both of you. Reddit will expel anyone whose opinion does not correspond to the local mob bias. Workplaces select people who are similar to already working ones.

I’m well aware. I can still offer the contrary point of view.

Re: All New Java Language Features Since Java 21

#29
post #4

I am a big functional programming geek. I am one of the few people on the planet who can honestly say I have been paid to write F#, Haskell, Clojure, and Erlang. I have spoken at FP conferences like six or seven times, and I have shit on Java for most of my career. And yet, my latest talk at Lambda Days basically boiled down to “Java 21 and later don’t actually suck anymore”, and I genuinely do mean that. Java 21 is…

I view this largely as a symptom of the widescale “success” of the bloated J2EE app servers in the early 2000s to mid 2010s. Your Java version and dependencies were locked in and upgrading was a massive effort. A large group of developers stagnated on Java 1.4.2 and 5 and seemingly never updated their use of the language, even when moving to Java 8 and beyond. The legacy stuff keeps ticking along.

I kind of think thats backwards. I think the success of the abomination that we have decided to label as J2EE or Jakarta was attractive to intellectually unambitious Java engineers because it progressed so slowly.

I think people here are really underestimating how intellectually lazy most people are at their jobs. HN selection-biased for a geekier crowd so a lot of my criticisms don’t apply to readers of this forum.

Re: All New Java Language Features Since Java 21

#30
After trying out many languages at many places, I reached the conclusion that Java, as weird as it may be, is my favorite language.

There were times I hated it, but turns out I really just hated messy, over-engineered legacy code and working in a gray cubicle at aging MegaCorps.

The language itself is quite beautiful when used properly and with modern features.

It just really needs a makeover and better tools.

Post reply on HN