Live data from Hacker News

All New Java Language Features Since Java 21

inside.java

91–100 of 130 posts

Re: All New Java Language Features Since Java 21

#91
post #87
post #74

Earlier quoted context omitted.

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.

First, C# has much smaller ecosystem. Half the stuff I was used to have for free and a very good quality was paid and much more limited in C#. Second, the more I worked with C# and visual studio, the more I hated it. It was pretty much the opposite with Javascript, typescript and even Java.

Well the ecosystem is different than the language but you can certainly find 3+ of any library you need in Java where .NET usually has a single choice.

I use Jetbrains for both Java and C# and the experience is essentially the same.

Re: All New Java Language Features Since Java 21

#92
post #86

Earlier quoted context omitted.

`var a = Set.of(1, 2)` works just fine in Java.

Impressively simple - though there being three ways of doing something is a complexity in itself. Perhaps I’m being too critical.

I've never seen a language have a single way to do something. It's part of Python's mission statement, but it doesn't appear to even have been a consideration in practice.

Re: All New Java Language Features Since Java 21

#93
post #86

Earlier quoted context omitted.

`var a = Set.of(1, 2)` works just fine in Java.

Impressively simple - though there being three ways of doing something is a complexity in itself. Perhaps I’m being too critical.

Not if only one is the right one in all cases.

In python you can also do

  s = set()
  s.add(1)
  s.add(2)
and

  s = set(x for x in [1, 2])
But I wouldn't call that having three ways to do the same.

Disclaimer: I don't know java well, just commenting based on the comments above and my python knowledge.

Re: All New Java Language Features Since Java 21

#94
post #38

Earlier quoted context omitted.

Var can help in maintenance. Change the return type of calculateAccounts and you don't have to modify this code (assuming that it duck-types out equivalently). That isn't necessarily a huge win: it does force a compile change that isn't obvious from the source. And a refactoring tool could have performed the code change automatically so it's not as big a deal as it might have been.

I would argue that it helps me when performing maintenance to see and correct where types may have changed. Not always, and sometimes it is busy work I agree, but overall I prefer it.

Yeah I generally avoid using 'var' to elide method return types for that reason. In my early phase of var enthusiasm I even had it result in a bug that would have been caught if the type had been made explicit.

I do still really like it in the `var list = new ArrayList()` case though.

Re: All New Java Language Features Since Java 21

#95
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.

I wouldn't dare say XML is better in this regard, but a good reason to be conservative with the use of annotations is exactly that cmd+clicking them doesn't easily lead to where the behavior is implemented.

Re: All New Java Language Features Since Java 21

#96
post #86

Earlier quoted context omitted.

`var a = Set.of(1, 2)` works just fine in Java.

Impressively simple - though there being three ways of doing something is a complexity in itself. Perhaps I’m being too critical.

I think that's fair. As with good UI, I appreciate when I can navigate via intuition. The solution in Python is intuitive, readable, and memorable. When working in Java, I frequently felt compelled to read and review pages of docs in search of a straightforward solution. I'm a sucker for Python's syntactic sugar.

Re: All New Java Language Features Since Java 21

#97
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!"

[deleted]

Re: All New Java Language Features Since Java 21

#98
post #82
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…

var was introduced in Java 10 not 8.

Yep, just looked it up and you are right! I misremembered. I stand by my overall point though.

Re: All New Java Language Features Since Java 21

#99
post #72
post #36

Earlier quoted context omitted.

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.

What’s wrong with Jakarta? (Genuinely curious)

Re: All New Java Language Features Since Java 21

#100

The explanation on why Java lets you use unnamed variables to prevent accidental use during deconstruction, but those unusuable variables still getting initialized by calling accessors, is a perfect example why I dislike the way Java implements improvements. Every single, logical step that led to this hidden performance problem makes complete sense, because every improvement had to be its own tiny, contained improvem…

[deleted]
Post reply on HN