Live data from Hacker News

All New Java Language Features Since Java 21

inside.java

71–80 of 130 posts

Re: All New Java Language Features Since Java 21

#71
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…

> The biggest issue, though, is that Java programmers won’t use the new features. My old CTO boss swore he wouldn't ever use annotations because they were too much magic for him. "No! Writing out gobs of XML to configure Spring DI is the only way!"

I generally hate when people use the “magic” excuse for not doing things. Most of these tools are open source and/or can be readily viewed in IntelliJ. It really isn’t hard…cmd+click on what you want to look at.

If you’re an engineer you should be able to easily read the code to see what’s going on. Most of the time the “magic” can be understood in less than 30 minutes and then it’s not magic anymore.

Re: All New Java Language Features Since Java 21

#72
post #36

Earlier quoted context omitted.

This is amazing news! Two questions for you: - how’s the environment? Build tools, dependency management, etc. it used to be a PitA back then. - how has the typing system and generics evolved to support this? Have they introduced any type of variance?

Maven still sucks. IntelliJ IDEA is genuinely great. It helps that they were the ones who developed Kotlin, and a fair bit of the actual language changes were gacked from Kotlin. (Or you could say "prototyped and shown valuable in Kotlin".) They are still hampered by lousy nullable support. You didn't ask, but Spring still sucks. It's not part of the language but it's a ubiquitous framework.

It’s amazing that Java has access to really great, high performing web toolkits like Vert.x and even Play, and yet the entire enterprise Java world has converged on Jakarta and Spring. I don’t like Spring but in my mind there is a special place in hell for Jakarta/JavaEE.

Re: All New Java Language Features Since Java 21

#73
post #71

Earlier quoted context omitted.

> The biggest issue, though, is that Java programmers won’t use the new features. My old CTO boss swore he wouldn't ever use annotations because they were too much magic for him. "No! Writing out gobs of XML to configure Spring DI is the only way!"

I generally hate when people use the “magic” excuse for not doing things. Most of these tools are open source and/or can be readily viewed in IntelliJ. It really isn’t hard…cmd+click on what you want to look at. If you’re an engineer you should be able to easily read the code to see what’s going on. Most of the time the “magic” can be understood in less than 30 minutes and then it’s not magic anymore.

You're right, "magic" is generally when someone doesn't take the time to understand things. A busy CTO may not have time, so more things seem like magic to them.

What's inexcusable is to inflict the rest of your team with your nonsense.

Re: All New Java Language Features Since Java 21

#74
post #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.

I can't see why you'd pick Java over C#. IMO its basically all the same preferences with slightly more consistent syntax choices. That said, Java is great too. It's underrated considering what a workhorse it is.

Re: All New Java Language Features Since Java 21

#75
post #64

I’ve worked in Java for over 20 years. Being the “lingua franca” of the enterprise is its biggest strength IMO, but it is also perplexing to me that it was able to do that in the first place. The language itself is not bad. The tooling around it is very good. But the codebases you encounter written in it, particularly in the enterprise, are often horrible.

Mind sharing why do you consider Java tooling to be good (and largely, what is good here)? The reason I ask is that I recently had to join a Java project at my company, and having a background in Node/Rust/Perl/Lua and some C++, I found the Java tooling to be extremely unsuitable for my taste. A simple example: there is no standard LSP server, and the amount of jumps required to have a working setup with FOSS tools a…

Tooling goes way beyond the editor/IDE. Eclipse is a very good free option. As is IntelliJ CE. I personally have the all products pack and use the ultimate version.

Beyond the IDE you also have to consider the build tools, package management, debuggers, profilers, static analysis tools, etc.

It’s honestly too much for an HN comment. But as an example, if I do open one of these awful projects at work and it uses gradle for example, intellij will understand that, import the project, get all dependencies, let me run any target with debugging or profiling, give me code coverage, etc.

Re: All New Java Language Features Since Java 21

#76
post #64

I’ve worked in Java for over 20 years. Being the “lingua franca” of the enterprise is its biggest strength IMO, but it is also perplexing to me that it was able to do that in the first place. The language itself is not bad. The tooling around it is very good. But the codebases you encounter written in it, particularly in the enterprise, are often horrible.

Mind sharing why do you consider Java tooling to be good (and largely, what is good here)? The reason I ask is that I recently had to join a Java project at my company, and having a background in Node/Rust/Perl/Lua and some C++, I found the Java tooling to be extremely unsuitable for my taste. A simple example: there is no standard LSP server, and the amount of jumps required to have a working setup with FOSS tools a…

I guess it's just a given that everyone uses IntelliJ Ultimate. If you don't, I guess you're right, the tooling is lacking outside of that. But it's so worth it...

Re: All New Java Language Features Since Java 21

#77
post #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.

it consistently works and has a huge ecosystem, but "beautiful" is never a word I would use to describe java. off the top of my head: * no type level concept of a const object (ie, you can have a const reference to a List, but never a reference to a const list). this makes const-ness an implementation detail of the class itself! so frustrating that List:add() can throw depending on the underlying class. * lack of tup…

> [Java] has a huge ecosystem

But does it though?

I've just taken a new job writing primarily Java whereas I was previously writing mainly python and typescript.

One of the first things I've noticed is how dead Java's ecosystem (Maven central) seems in comparison to other ecosystems like PyPI, NPM or Cargo.

(Also side note: I've published packages on each of these registries and the publishing process for Maven central is comically terrible! This has to be discouraging people from contributing to the ecosystem.)

Re: All New Java Language Features Since Java 21

#78

Earlier quoted context omitted.

> But the codebases you encounter written in it, particularly in the enterprise, are often horrible. Not sure they are worse than other languages?

Having now experienced such Java codebases for the first time in my 15 year career… no, the Java code is much, much worse. Over engineered and otherwise poorly written Java code is SO much worse than other over engineered code I have worked with.

Honestly for the limited projects I've had to work with... I can attest to that. It's the over engineered abstractions that get me. Traditional Java EE users use WAY too many abstractions and interfaces, it's absolutely horrible to debug.

Re: All New Java Language Features Since Java 21

#79

Earlier quoted context omitted.

it consistently works and has a huge ecosystem, but "beautiful" is never a word I would use to describe java. off the top of my head: * no type level concept of a const object (ie, you can have a const reference to a List, but never a reference to a const list). this makes const-ness an implementation detail of the class itself! so frustrating that List:add() can throw depending on the underlying class. * lack of tup…

> [Java] has a huge ecosystem But does it though? I've just taken a new job writing primarily Java whereas I was previously writing mainly python and typescript. One of the first things I've noticed is how dead Java's ecosystem (Maven central) seems in comparison to other ecosystems like PyPI, NPM or Cargo. (Also side note: I've published packages on each of these registries and the publishing process for Maven centr…

probably depends on what kind of stuff you're working on. I mostly build web services and data pipelines on AWS, where java is still the best supported language (even if others have joined the list of officially recommended).

java might not see the same brisk pace in library development as other languages, but it's also 30 years old. aside from core issues with the language that can't be papered over by 3P libs, what's missing?

Re: All New Java Language Features Since Java 21

#80
post #50

Earlier quoted context omitted.

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

Same here, plus sealed classes - a very powerful feature. What I actually haven’t used up to this point are VTs. I got a service that implements a job queue and it currently works flawlessly with scheduled executor pool. I’m reluctant to go with VTs before evaluating what implications that may have.

I think VT's are only going to be interesting if you need 1000s of them doing tiny amount of small work often.

For me I have been waiting for them for 20 years, as the blocking IO made MMO development impossible.

In the meantime we got NIO in 1.4 that only became performant and stable around 1.7 so it's been a slow progress.

I dug out my old blocking server code from back then and with a fresh coat of paint I'm ready to let the non pinned VT's rip and compare them to the NIO backend!

Post reply on HN