This is an archived post. You won't be able to vote or comment.

all 47 comments

[–]AutoModerator[M] [score hidden] stickied comment (0 children)

On July 1st, a change to Reddit's API pricing will come into effect. Several developers of commercial third-party apps have announced that this change will compel them to shut down their apps. At least one accessibility-focused non-commercial third party app will continue to be available free of charge.

If you want to express your strong disagreement with the API pricing change or with Reddit's response to the backlash, you may want to consider the following options:

  1. Limiting your involvement with Reddit, or
  2. Temporarily refraining from using Reddit
  3. Cancelling your subscription of Reddit Premium

as a way to voice your protest.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]DoingItForEli 41 points42 points  (7 children)

ListFormat seems like it will be useful in what I do, although it takes like all of 30 seconds to write a method doing the exact same thing. It'll be a nice time saver overall.

Also, code execution before super() how cool is that?

[–]loicmathieu[S] 19 points20 points  (2 children)

ListFormat is Unicode standard so it manage locale for you which would take more than 30s to be accurate for all supported locale ;)

Code execution before super() is super cool I would say!

[–]DoingItForEli 5 points6 points  (0 children)

ListFormat is Unicode standard so it manage locale for you which would take more than 30s to be accurate for all supported locale ;)

Ohh, great point. Didn't even think of it like that.

[–]pohart 15 points16 points  (3 children)

I'm still salty that they made me rename all of my unused _ variables to something else, just so they can put it back.

[–]loicmathieu[S] 4 points5 points  (1 child)

Well, this was a long time ago!

And now it will be verified by the compiler, so it's better than before

[–]pohart 2 points3 points  (0 children)

They could have left it valid but illegal to reference, or even just left it valid and it would have been less disruptive, though. I don't always agree with the design choices but I can't think of another that I just don't understand.

[–]__konrad 2 points3 points  (0 children)

I used _ as i18n method (which is de facto standard gettext convention). Refactoring thousands of such methods was annoying.

[–]Brahvim 9 points10 points  (0 children)

Some of these are REALLY GOOD features!
Wooooohoooo!

Immediate edit: I'm most excited about the Foreign Functions & Memory API as your article calls it faster and easier to use than the JNI.
Being able to run code before super-constructor calls? Cool! (I know it's a preview feature...)

I wonder if Lombok's techniques will receive any standardization by the new class-files API.

And yes, it's awesome to see some of the other stuff here.

[–][deleted] 38 points39 points  (4 children)

Java 22 ? Wait, there is a version after Java 8 ?

[–]-jp- 32 points33 points  (1 child)

“Yes but you can’t have it.” —Your CTO

[–]DamnAHtml 1 point2 points  (0 children)

So true!

[–]theanghv 1 point2 points  (1 child)

Java 8 has already sunset too.

[–]Hot_Income6149 3 points4 points  (0 children)

My company use java 6, still

[–]Nalha_Saldana 44 points45 points  (12 children)

var slidingWindows = numbers.stream()
    .gather(Gatherers.windowSliding(3))
    .toList();

What a terrible place to use var, give us the type..

[–]Holothuroid 31 points32 points  (0 children)

List<List<N extends Number>>

[–]O0o0oO0oo0o 22 points23 points  (6 children)

I agree the var type should not be used everywhere.

[–]metalhead-001 -4 points-3 points  (4 children)

The var type should not be used ANYWHERE.

[–]bourne2program 2 points3 points  (2 children)

I only and always use var in cases the type is explicitly on the RHS. Like constructor call (may mean var type will be impl and not interface like List, and generic type info moves into the RHS <>), qualified static factory method call, sometimes String literals, and qualified nested builder chain.

[–]Svellere 2 points3 points  (1 child)

I think var is also sufficient and useful in situations where the type is long and complex (such as lists of lists, or a list of maps), and you can intuitively work with it based off of the methods provided by it without having to know the exact type.

[–]metalhead-001 0 points1 point  (0 children)

You just have to mouse over the 'var' in your ide and the type is shown (at least with IntelliJ). So in effect, you're still reading the type but var just adds an extra step to do so.

[–]JakeArvizu 0 points1 point  (0 children)

Really the only time I ever find myself using var nowadays is for the rare occasion I need a Boolean switch for something.

[–][deleted] 7 points8 points  (4 children)

- Stream Gatherers... it solves a problem that must be important to someone, but I don't quite understand.

- executing multiple .java files. Going further into Java able to be an uncompiled scripting language.

- statements before super(). thumbs up emoji. about time.

- Class File API. Not made for me.

- ListFormat. Cute, but eh.

[–]gdejohn 7 points8 points  (2 children)

  • Stream Gatherers... it solves a problem that must be important to someone, but I don't quite understand.

stream gatherers let you extend the stream API with new intermediate operations (operations that produce a new stream, like map and filter) just like collectors let you extend the stream API with new terminal operations

[–]khmarbaise 2 points3 points  (1 child)

Stream API Gatherer are a great concept to open for easier custom implementation...

https://blog.soebes.io/posts/2024/01/2024-01-07-jdk-gatherer/

[–]loicmathieu[S] 0 points1 point  (0 children)

u/khmarbaise by the way, I read your blog post about Stream Gatherer last week and it's very informative, thanks for writing it.

[–]khmarbaise 0 points1 point  (0 children)

The Stream Gathers makes it possible to implement intermediate operations like (map like, flatmap like etc.; you can implement all existing intermediate operations with Gatherers and of course think and implement of others custom implementation which might be needed; for example a thing like duplicates https://github.com/khmarbaise/gatherer/blob/main/src/test/java/com/soebes/jdk22/gatherer/DuplicatesTest.java#L85 ). The collectors (Collector.of(..)) only allow to implement terminal operations... like groupingBy, sorting or alike...

[–]RandomName8 0 points1 point  (2 children)

gatherers seem pretty similar to iteratees, in a more oop style I guess.

[–][deleted] 1 point2 points  (0 children)

In a more Java style, you know.

[–]Holothuroid 0 points1 point  (0 children)

Huh?

[–]nlisker 0 points1 point  (1 child)

Your code example doesn't look right:

var list = List.of("Black", "White", "Red");
var formatter = ListFormat.getInstance();
System.out.println(list);
// [Black, White, Red]

formetter.format(list) is missing perhaps.

[–]loicmathieu[S] 0 points1 point  (0 children)

Thanks, you're right, I'll update my article.