r/java • u/dodiehun • Nov 17 '20
New language features since Java 8 to 15
https://advancedweb.hu/new-language-features-since-java-8-to-15/20
u/8igg7e5 Nov 17 '20
Top marks for the clear demarcation between new features and preview features.
So many either ignore the distinction entirely or pay it lip-service but if you're looking to upgrade on commercial project that distinction matters a lot.
14
11
Nov 18 '20
Some applications still using Java 6 at work, and I would't be surprised if JRE 1.4 was still used in some dark corners of the datacenter...
Java 8 is the main used version, Java 11 is slowly rising. Once we adopt Java 15, version 25 will be out probably.
FML.
5
u/wastakenanyways Nov 18 '20 edited Nov 18 '20
Hardly think we will ever get there. And if we get there, hardly think anyone would update.
Years of experience in the java world have taught me that people just don't use recent versions, and like a whopping 99% of them doesn't even care. Projects are STILL being started based on Java 8. Not maintained, started!!
Java is just too late on it's life to modernize. I don't say its dead but for sure, people who wanted/needed new things already changed ecosystem, and people who love/need Java will just keep to the version they master.
All of the government of the place where I live is written in Java 6 and 8 and will never be updated. We either keep this shit and reshape it, or throw it all in the bin and make another system from zero.
6
u/kaperni Nov 19 '20 edited Nov 19 '20
Meanwhile, over at Python HQ. People are still discussing Python2 vs Python3. Python 3 was released in 2008. Java 9 was released in 2017.
If you have been in the game long enough. You will know this is perfectly normal for mature platforms. And nothing to worry about.
2
u/wastakenanyways Nov 19 '20 edited Nov 19 '20
Yeah, Python is another example. That said, it isnt even close. I mean, a LOT more people has upgraded from Python 2 to 3 than from Java 8 to any future version.
Obviously we will always have some technical debt and we will always have experimental people on the latest release or pre-release, and people stuck on out of support versions. You are right that this is common in mature ecosystems. But Java is the most noticeable, and by far.
Anyway, it isn't even java version alone. I know people in other ecosystems who try to use the latest versions of libraries supported in the language version they are stuck with. This doesn't happen so much in Java. They were always several versions behind in everything they use, even if it didn't depend at all on the language version and was another utility!! I think is just an engrained mindset of avoiding new at all cost.
Even the OS they use! The percentage of Java devs I know in windows 7 respect to those on windows 10 is absurdly huge compared to other devs.
I have worked in different teams and different ecosystems and what happens in Java is, part maturity, and part culture. And that culture part is huge. But this is just my experience and observations.
Not saying being behind some versions is bad, and as u say is normal in the field. That said, the culture of being behind just for the sake, i think is dangerous. Sometimes things have to change even if they don't seem to need it.
1
Nov 19 '20
I work for a huge enterprise and we are finally upgrading. 8-11. Probably won't upgrade to the next LTS until well into the future in that one. Upgrades are happening, just slowly.
5
u/b1ack1323 Nov 18 '20
So a list of everything since I last touched Java. Nice!
5
u/8igg7e5 Nov 18 '20
Language features. There's a small (but for some, significant) list of API changes as well.
In Java 16 (March '21) it looks likely we'll get (already merged and available in EA builds):
Records
Method-local type declarations (part of records release)
Pattern-matching for
instanceofJava 17 (Sep '21) marks the next Oracle LTS (and the next release that various OpenJDK builders are likely to support longer-term) but it's unclear at this stage which of the various incubation features might make it in by then.
3
u/dpash Nov 19 '20
The library changes shouldn't be overlooked. They're not very big in each release but together they're quite substantial. Just quality of life improvements, but also things like the http client.
2
1
u/b1ack1323 Nov 18 '20
That is pretty cool. My current job does not use Java for anything but Android dev and we only make apps occasionally
2
Nov 18 '20
I also had a presentation on Amber project. Here is its code https://github.com/sake92/java-amber
It has examples with a decompiler, it makes it easier to see what's going on under the hood!
Also screencast: https://youtu.be/DBk5xjXUAzQ
3
u/Skhmt Nov 17 '20
Some of my favorite Kotlin features making their way to Java, nice.
10
u/pjmlp Nov 17 '20
Actually ML.
6
Nov 18 '20
I don't know why you are downvoted but you are right. All the syntactic features that are coming to Java are inspired from ML.
5
u/pjmlp Nov 18 '20
I guess it is the cargo cult of guest languages on the JVM.
1
u/GhostBond Nov 19 '20
Java is turning into a bit of a mess. It's initial appeal was it's simplicity - it's a bit verbose but it's fairly clear - now it's going the same way all the other languages go at point of becoming overly complex with redundent repetitive language constructs.
3
u/pjmlp Nov 19 '20
You can always pick Go and experience Java 1.0.
2
1
u/GhostBond Nov 20 '20
Interesting, I took a look at Go, but it still seems a little strange:
_, c := vals() fmt.Println(c)Whereas Python isceasy to read:
num = float(input("Enter a number: ")) if num > 0: print("Positive number") elif num == 0: print("Zero") else: print("Negative number")Problem with python is the lack of static typing, both for maintenance, and performance. You can see it replaced java as the intro programming language at most schools - from what I've read. Only language to actually beat java in popularity, rather than just being a secondary competitor (like c#, kotlin).
3
u/pjmlp Nov 20 '20
Those two lines don't do the same, so I don't get your point.
As for my remark, it was about how bare bones Go is, basically how Java 1.0 was.
3
1
0
u/rum-n-ass Nov 18 '20
var is pretty cool but I’m not sure it would pass in code review cause of “readability” even though they wouldn’t bat an eye at JavaScript
3
u/Yithar Nov 18 '20
I've used Scala for the past few years and I'd argue var and val make code more readable.
4
u/DeeoKan Nov 18 '20
Java's var it's not the same of Javascript's var.
You can use var only when the type is clear. To me, it's very usefull without loosing readability.
4
u/nutrecht Nov 18 '20
In my experience sofar using Kotlin the last 2 years, var and val make code more readable, not less.
2
u/eled_ Nov 19 '20
Generally speaking, it helps cut out noise for the reader. Sometimes, the variable type is abundantly clear, or not important.
For instance:
MyClass myInstance = new MyClass(); //vs var myInstance = new MyClass(); //here is where I'd avoid it, I might not want MyClass's contract to leak into the rest of the code MyInterface myInstance = new MyClass(); //here, I'd avoid it too for readability MyClass myInstance = SomeUtility.createMyInstance();2
u/nutrecht Nov 19 '20
Thing is, that's generally not what code looks like, a single isolated line. More often than not, using proper names for variables is important anyway because you actually use them later on, and there you don't see the prefixed type anymore anyway.
Like I said; I've been using Kotlin for 2 years now. It's a complete non-issue in real code. If anything it forces better naming practices.
1
u/eled_ Nov 19 '20
I'm agreeing with you here.
Code is written in relationship with APIs, within methods, as part of a class definition, etc. A well-designed context goes a long way for this type of thing.
Take tech.tablesaw for instance, which provides features for working with in-memory dataframes. As could be expected their main data types are Table, Column, Row, most of the API revolve around them, and most of the time their methods perform transformative operations and return the resulting entity.
Most of the time, there is absolutely no need to reiterate that the result is a Table type, it is conveyed by how the API as a whole works, and appropriate variable naming is all you need here.
What I was saying above is that there are also situations where I would avoid var as it obfuscates important type information, like an important choice of contract, or sometimes situations where variable naming just doesn't cut it.
2
u/dpash Nov 19 '20
It only affects readability if you have bad variable and method names. Or methods so long the definition and use don't fit on the same screen. Which is to say, if you already have readability problems.
1
-6
u/Charliejfg04 Nov 17 '20
So “record” is basically Lombok’s @Data
15
u/randgalt Nov 18 '20
Boy it this argument gets tiring. Records are part of a set of features that will end with full data classes that support deconstruction and pattern matching. It's nothing like Lombok or Kotlin. If anything, it's very similar to Scala's case class.
5
u/Log2 Nov 18 '20
Scala case classes, their pattern matching and deconstruction is the best part of Scala, in my opinion. So, I'm glad they are coming this way.
8
0
u/the_other_brand Nov 18 '20
I wish. Records are just classes with immutability baked in.
They don't add features for improved syntax (@Data) or improved memory control (making value types like C# structs).
-2
u/BadMoonRosin Nov 17 '20
Only at the most superficial level.
Lombok's
@Datacreates getters and setters (among other things) at compile-time. But the end result is a standard Java class.Records are value types, and behave differently from class instance references.
7
0
u/GhostBond Nov 19 '20
If it was Lombok's @Data that would be nice. That actually works pretty well.
Instead it's a buzzword driven mess - readonly data, inconsistent changes to get/set syntax, and something else I don't remember. It's worse than @Data for some reason. Guess it's the "2015-2020 everything gets worse thing".
-2
2
u/ihatebeinganonymous Nov 18 '20
Wasn't local variable inference introduced in Java 10? (Where is Java 10 by the way?)