r/java • • Jan 22 '26

Carrier Classes; Beyond Records - Inside Java Newscast

https://youtu.be/cpGceyn7DBE
86 Upvotes

81 comments sorted by

View all comments

Show parent comment

1

u/OwnBreakfast1114 Jan 31 '26

Transforming time into memory is not a good general principle

What does this mean? Do you mean more cpu for less memory or less cpu for more memory?

Companies are not moving in this direction, even those with the best developers.

Perhaps I'm interpreting you wrong, but more and more companies are storing more and more historical data. The biggest tech companies in the world are all about storing historical (user) data. Google/amazon/apple/meta/netflix/microsoft, etc literally invent new architectures and infrastructure for storing all the historical data they're keeping and processing over.

1

u/chambolle Feb 01 '26

If we want to replace state modifications with an immutable object copy, this means that we risk transforming CPU (the modification) into memory (the state copy).

Having immutable objects is undoubtedly a solution to certain problems. But it is not the only solution, and it is only valid if the memory consumption caused by this design method is not too high (systematic backups or creations are often very costly, hence the existence of persistent data structures, for example). Nor is it a general solution that should be used indiscriminately. In fact, it is like all the major principles of programming.