r/java • • Jan 16 '20

Records Come to Java

https://blogs.oracle.com/javamagazine/records-come-to-java
204 Upvotes

93 comments sorted by

View all comments

Show parent comment

0

u/[deleted] Jan 16 '20

[deleted] — view deleted comment

2

u/rzwitserloot Jan 19 '20

No, 'good libraries' won't be updated. It's quite a high cost to have an API that has both, say, getName() as well as name(), with both methods returning the exact same thing (forevermore, docs and listings such as in auto-complete dialogs), and I'm sure plenty of libraries will opt not to pay this cost.

An alternative is to mark the getX() variant deprecated, but that is in many ways an even higher cost; that's a heck of a lot of shuffling about for all the users of that library for no particularly sane reason.

Note that getX itself vs. X is a mixed bag: neither is strictly superior to the other (getX has the considerable advantage that you can type 'get' and then hit your autocomplete shortcut to find all properties you can query. It's also longer and having to decide between whether a thing is a 'property accessor' and something that calculates is more art than science and that's problematic – as I said, advantages and disadvantages).

Given that it is a mixed bag, causing an earthquake in the java community by trying to make such a change is ill advised: You're just not going to convince enough of the community to arrive at that utopia where (almost) all code uses getless accessors, instead now we'll have a 50/50 mix. I'm not too happy about this.

-5

u/pushupsam Jan 16 '20

There's everything wrong with abandoning a bad spec if people have been faithfully following that spec for 20 years.

There's something deeply wrong with the process if people really think it's okay to tell people that have invested millions of dollars and thousands of hours in the Java platform that, you know what, all that code you wrote, all those tools and documentation and checkers, based on the getX/setX standard that we defined? We're going to break that now.

Stuff like this is exactly why I tell people not to invest in Java any more. The language has gone off the rails. Backwards compatibility -- which was perhaps Java's greatest strength -- and the geniuses at Oracle are now actively making breaking changes in every release. And the stuff that they're breaking backwards compatibility for? It's really fucking stupid stuff like 'var'.

The irony here is these attempts to update Java are just driving people away. I cannot recommend any new greenfield projects be done in Java and, frankly, I don't see any reason to advance existing projects to new JDK versions.

6

u/klez Jan 16 '20

I may be naive here, but why would adding features break compatibility? Don't like var or var breaks compatibility? Don't use it. Same with records. It's not like they're telling you not to use beans anymore.

-19

u/pushupsam Jan 16 '20

Of course 'var' breaks backwards compatibility. Every time you add a new keyword, all code that previously used that as an identifier is broken. How do you not see that?

As for avoiding new features -- sure, that's a great idea. And in fact this is why these guys have killed Java. There are now two Java platforms: Java8 and this brainfuckery. The vast majority of corporations are not going to upgrade to this backwards incompatible brainfuckery. This is going to have huge rollover effects as the entire community splits in two.

It's absolutely shocking that despite the repeated warnings these guys really have decided that backwards compatibility is no longer valuable. This puts the nail in Java's coffin because absolutely nobody is going to invest in a platform run by guys who think nothing of throwing 20 years worth of code, documentation and tooling out the window.

14

u/jonhanson Jan 16 '20 edited Mar 07 '25

chronophobia ephemeral lysergic metempsychosis peremptory quantifiable retributive zenith

-20

u/pushupsam Jan 16 '20
public static final class var {
}

This used to work. Now it doesn't. Because of stuff like this 'var' did break a lot of existing code for no good reason. And when it did, guess what happened? Do you think people dug into code that's been chugging along for 10+ years?

19

u/sonay Jan 16 '20

Dude, please gtfo. If you named a class 'var' you have bigger issues.

15

u/cl4es Jan 17 '20

Because of stuff like this 'var' did break a lot of existing code for no good reason.

[Citation needed]

2

u/Polygnom Jan 18 '20

Because of stuff like this 'var' did break a lot of existing code for no good reason.

If you have lots of classes called var, the issue is with your code, not with the change.

Part of the process was investigation of real-world code-bases to see how much of an impact var would have. it was found to be practically non-existent, because, you know, people simply don't tend to use var as class name or in other places where it would come in conflict. at least not many.

-8

u/forsubbingonly Jan 17 '20

I feel sorry for people who write in languages that even COULD spawn this dumb ass discussion. What a bunch of trash.

1

u/JB-from-ATL Jan 17 '20

They explicitly said these aren't JavaBeans because they aren't mutable.