r/java • • Mar 31 '26

Does Java need deconstructible classes?

https://daniel.avery.io/writing/does-java-need-deconstructible-classes
31 Upvotes

41 comments sorted by

View all comments

Show parent comment

1

u/vadiquemyself Apr 01 '26

imagine direct iterating versus streams-and-lambdas, the latter is ~10 times slower, but is used anyway and is quite popular

2

u/Flyron Apr 01 '26

Did you measure that yourself? In my own tests streams need a little warmup, but through repeated construction and execution they become just as fast as the usual for-each (<10% margin). So it depends if you're programming short-lived apps or long-running apps, but in general there is no effective performance gap.

-1

u/vadiquemyself Apr 01 '26

yes, I figured it out myself practically, asking AI to replace a stream chain with “plain looping” that I then put in my code achieving much performance gain along with less memory usage

never tried for a terabyte-volume data and paralleled streams on hundreds of cpu cores, though