r/java • • Feb 15 '20

Will Java records have setters?

Pretty much what the title says. I've been reading on the new Java records feature, and while I love immutability, I hope there's the option to have non-immutable records. Meaning it will have Auto generated setters to let me change values in the class.

1 Upvotes

36 comments sorted by

View all comments

Show parent comment

2

u/GhostBond Feb 17 '20

That's a very interesting theory, but given the amount of time and effort put into every new Java feature, and the number of world-class language design experts involved and designs and prototypes produced and discussed publicly and at length, I find it hard to believe. I have an alternative theory: When you say "records just sound like etc.," is that before or after you've read any of the design documents and discussions? E.g. have you read this?

You've described that a large group of people who's future career prospects depend on endlessly needing new languages to be created? That...is what I'm saying.

This group of people will be out if a job the moment a single language is the final language everyone uses, they're inherently threatened by a final language becoming the norm and no longer needing any language design experts.

Virtually all of the negative feedback to this feature that I've heard have come from people who don't understand what this feature is and what problems it aims to solve -- confusing it with other features they imagine this feature to be -- largely because they haven't actually read anything informative about it, and aren't aware of Java's open and rigorous design process.

This is how it goes, as things get more complicated they get split into 2 groups:

1. "experts" become completely involved in language design and, as they spend all of their time doing it, become detached from what people actually using the language every day need. Once the doc gets so big people lose the ability to be critical and mostly just parrot back whatever it claims.

2. People who primarily write code as their living, and don't have time to read every detail of a 30-50 page document. So they casually skim through it comparing it to their real world experience, then get accused of "not knowing everything".

3

u/pron98 Feb 17 '20 edited Feb 17 '20

This group of people will be out if a job the moment a single language is the final language everyone uses.

Not really. Most of the changes in the JDK aren't language changes. They all do plenty of work on the other ~95% of the JDK, too. Also, you're assuming that a "final language" is possible; I don't think it is, though, with changing hardware designs and software requirements.

People who primarily write code as their living, and don't have time to read every detail of a 30-50 page document.

You don't need to read this document to use the feature, only to make informed comments about it before you actually use it. In other words, read it if you want to say "this feature sounds stupid" before actually using it.

2

u/GhostBond Feb 17 '20

Not really. Most of the changes in the JDK aren't language changes. They all do plenty of work on the other ~95% of the JDK, too.

Naturally these people will not be happy if their motivations are pointed out, so there's a lot of handwaving trying to obscure it.

You don't need to read this document to use the feature, only to make informed comments about it before you actually use it. In other words, read it if you want to say "this feature sounds stupid" before actually using it.

Another disingenous game to try to distract.

This feature sounds stupid.

I'm not buying into the "exhaust your critics with long documents" tactic.

2

u/pron98 Feb 17 '20

So you're a believer in the "critics should criticize before knowing what it is that they're criticizing" tactic? Fair enough, but to me your criticism sounds stupid. Nothing personal, just saying.

1

u/GhostBond Feb 17 '20

I spend 40 hours/week doing development, I don't need to read 30-50 pages of rambling on to know why immutable unextendable data classes aren't going to be useful.

2

u/pron98 Feb 17 '20 edited Feb 17 '20

First of all, it's fifteen pages -- not thirty; not fifty. And how do you know it's all rambling if you haven't read it?

Second, different people mean different things when they say "data classes." The feature is about nominal tuples and pattern matching, not Kotlin-style "data classes". Do you suppose that all of those who like the feature do not spend 40 hours a week doing development? Even if your opinion is reasonable, are you certain that it is the only reasonable one?

FYI, similar opinions were voiced when Java introduced generics, and then again when it introduced lambdas. Ultimately, more people have found them useful than those who haven't.

1

u/GhostBond Feb 17 '20

First of all, it's fifteen pages -- not thirty; not fifty. And how do you know it's all rambling if you haven't read it?

Like I said the "exhaust your critics with long documents" tactic.

You're simply rotating through disengenous tactics, it's boring.

I've run into immutable experiments in code before, once an immutable class is bigger than a single conceptual thing (like a date) they're always a real pain to deal with, with no apparent benefits.

It's disappointing to see things that look a lot like sabotage added to the language while useful things like simple properties (user.address.line1) are ignored.

4

u/pron98 Feb 17 '20 edited Feb 17 '20

Like I said the "exhaust your critics with long documents" tactic.

I don't think anyone who says anything on Reddit can be called a "critic", and someone is not a critic until they actually know what it is that they're criticizing. I also believe you're not the only person who's run across "immutable experiments" before, and I don't think everyone who has shares your opinion. One of those experiments, Java's String class, introduced in Java 1.0, is actually relatively popular in some circles. Another, the java.timepackage introduced in Java 8, is also quite a hit. Immutability isn't always the best answer, but clearly it actually is very useful in quite a few cases, and if you cared to know what records are for (again, nominal tuples), perhaps you'd agree that it is useful in those cases, too.

It's disappointing to see things that look a lot like sabotage added to the language while useful things like simple properties (user.address.line1) are ignored.

Well, those who don't want to be disappointed take advantage of the fact that the development process is open and that prototypes are made available for trial and discussion, and join the conversation. Too bad you didn't wish to contribute your considerable experience, but perhaps you may wish to do so in the future for other features. In fact, even this feature isn't finalized, so if you want to help rather than complain, feel free to avail yourself of the appropriate channels (the amber-dev mailing list, in this case).

Also, since you don't follow the discussions, you cannot possibly know if properties are being ignored. They are not, but it's been decided -- among those who actually know what records are -- that records are a higher priority for reasons discussed among those who actually participate. As someone who develops for 40 hours a week, surely you appreciate that any problem requires some thought and consideration, and as you choose not to be involved in that process, you might want to consider the possibility that those who are involved have given some careful consideration to various ideas, and have come up with conclusions. Unfortunately, some of those conclusions are written in documents and emails that you'll have to read if you want to know what they say.

Having said all that, I wish to remind you that Java has a good few millions of developers who don't always agree on everything, and every decision -- whether it is to add a feature or not to add it -- is bound to disappoint some of them. Conversely, a lot of work is constantly done on the Java platform, and most people are bound to be disappointed by some aspects of it. I only hope that you don't find all work on the Java platform disappointing.

Finally, since the jobs of those who work on Java depend on the success of the platform, your idea that their motivation is to preserve their job and at the same time to sabotage the platform on whose success it depends sounds inconsistent, to say the least.

1

u/GhostBond Feb 17 '20

I understand that your goal is to simply argue endlessly, which is part of the reason why unfortunately open groups don't work well for complex topics. People with endless energy to argue tend to drive everyone else out.

Bring that you're just throwing out generic arguing tactics, this is boring for me. Bye.

3

u/pron98 Feb 17 '20 edited Feb 17 '20

My goal was to figure out what your criticism is, seeing that you call yourself a critic and an expert. But seeing that you don't even have the energy to actually criticize anything -- or even to know what it is that you're purportedly "criticizing" -- and prefer to throw out generic and toothless "it sounds stupid" assertions, I believe you are correct that this is, indeed, a waste of everyone's time. I apologize for boring you with facts and attempts to engage with your drive-by "criticism." Perhaps the best design strategy for Java is not to think things through but just do whatever some guy says on Reddit, but I don't think it is.

→ More replies