Live data from Hacker News

All New Java Language Features Since Java 21

inside.java

81–90 of 130 posts

Re: All New Java Language Features Since Java 21

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

Re: All New Java Language Features Since Java 21

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

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

I respect your opinion but I wouldn't call Java beautiful (of course it depends on your definition of beautiful). It takes so much ceremony to do things you would do without any thought in other languages .

Initiating a mutable set

Python

`a = {1,2}`

What most Java programmers do

``` var a = new HashSet(); a.add(1); a.add(2); ```

Shorter one but requires more ceremony, and hence knowledge of more language semantics

``` var a = new HashSet(new Arraylist(List.of(1,2)) ```

I don't know if the above works but the Idea is to initiate a list and pass it into a HashSet constructor.

Similarly Java 21 allows you to model union types but doing so requires you to define N+1 classes where N is the number of union cases whereas in other languages it's as simple as `type A = C |D`

Re: All New Java Language Features Since Java 21

#85
post #71

Earlier quoted context omitted.

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.

Yep, completely agree.

I got in a bit of a disagreement with teammates at a previous job. I liked these teammates, they were very smart and nice people, but for a specific project I wanted to use LMAX Disruptor, and the excuse for not using it was very literally “we don’t want to make people learn anything”.

That stuff blows my mind; aren’t we engineers? If we’re not willing to learn new things and adapt, what exactly are we offering that a high school kid who bought an “Intro to Java” and “Intro to Spring” book can’t?

Re: All New Java Language Features Since Java 21

#86
post #83
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.

> The language itself is quite beautiful when used properly and with modern features. I respect your opinion but I wouldn't call Java beautiful (of course it depends on your definition of beautiful). It takes so much ceremony to do things you would do without any thought in other languages . Initiating a mutable set Python `a = {1,2}` What most Java programmers do ``` var a = new HashSet (); a.add(1); a.add(2); ``` S…

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

Re: All New Java Language Features Since Java 21

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

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.

Re: All New Java Language Features Since Java 21

#88
post #86
post #83

Earlier quoted context omitted.

> The language itself is quite beautiful when used properly and with modern features. I respect your opinion but I wouldn't call Java beautiful (of course it depends on your definition of beautiful). It takes so much ceremony to do things you would do without any thought in other languages . Initiating a mutable set Python `a = {1,2}` What most Java programmers do ``` var a = new HashSet (); a.add(1); a.add(2); ``` S…

`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.

Re: All New Java Language Features Since Java 21

#89
post #38
post #35

Earlier quoted context omitted.

There is about zero difference in readability of your two statements, rending var not useful. And 'var accounts = calculateAccounts(something)' is literally less readable, because now you dont see what exactly accounts is. Var statement speed up writing, then are either irrelevant or gets rewritten to types for better readability.

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.

Modify it when? If the interface renames? IDE does that. If the actual return type changes? They you do have to check that place whether it is still valid.

Maintenance involves a lot of reading of unknown code. That is literally the situation where you are rewiting var to specific types to figure out what is going on.

Re: All New Java Language Features Since Java 21

#90
post #64

Earlier quoted context omitted.

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 gradl…

Thanks for sharing your experience.

It's a fair note about tooling in general, I started with the code editing because it's the first thing before you can taste and judge the rest.

I think my frustration comes from the fact that in most other ecosystem I can use the tools I like, but in Java I have to use things like Intellij.

Intellij CE may be open source, but it is entirely owned by a private business whose primary goal is to sell their product - which affects how well are the integrated, open to accept community feedback, etc.

Post reply on HN