45
u/stronghup Sep 15 '20
I get it that now Java is updated more frequently, with fewer new features in every release. That is good.
But looking at release notes it would be helpful if they had a section for 1 - 3 MAIN (new) FEATURES. What is essential about this release. Why should I consider using it.
I don't really care that there is no isEmpty Default Method for CharSequence . It's good to have of course, but I'd like it see the forest from the trees.
30
u/pron98 Sep 15 '20 edited Sep 16 '20
A good reason to use every new JDK release is lower footprint and higher performance that will save you real money. Savings of 10-40% in hardware/hosting costs from 8 to 15 are common.
10
u/v1akvark Sep 16 '20
Oh Reddit, downvoting useful comments.
You should be paying attention to what this guy posts, pretty sure he either works on the JDK or is very closely involved.
23
-1
u/gnus-migrate Sep 16 '20
Unless you're paying for LTS or using another JDK distribution like Coretto, you have to upgrade anyway if you want security updates.
44
u/BoyRobot777 Sep 15 '20 edited Sep 15 '20
Here's the list of new JEPs:
371: Hidden Classes
378: Text Blocks
12
u/BoyRobot777 Sep 15 '20
Also, records with withers will be quite nice.
24
u/MrDOS Sep 15 '20
381: Remove the Solaris and SPARC Ports
Not with a bang, but with a whimper. RIP.
6
Sep 16 '20
Somewhere there is someone who is running Solaris in QEMU to keep a legacy Java application with arcane dependencies running. Now the person is solemnly weeping.
1
u/DoListening2 Sep 15 '20 edited Sep 15 '20
Reminds me a bit of immer https://immerjs.github.io/immer/docs/introduction from the JS world, which is pretty nice to use in practice.
Although this doesn't seem to address deep/nested updates in any way (those aren't nearly as important though), so I guess it's more akin to the JS pattern of doing
const newObject = { ...oldObject, field: value, field2: value2 }in that sense.
3
u/caninerosie Sep 16 '20
what's the difference between Shenandoah and ZGC?
3
Sep 16 '20
They're both after the same goal of GC without large stop the world pauses, but they have different implementations. Anecdotally I've heard Shenandoah is supposed to be better, we've tried with ZGC a little bit but CPU went through the roof.
5
u/renatoathaydes Sep 15 '20
Didn't Project Loom's preview make the cut?
12
5
u/BoyRobot777 Sep 15 '20
Add to what TheCountRushmore said, Ron, lead of Loom project, has stated that:
Loom has been in the works for three years, and I believe you won't need to wait for Preview too long.
50
Sep 15 '20
I don't use it anymore, but boy am I happy because it finally got multiline strings (text blocks). Writing a raw SQL will be so much easier and readable.
-5
u/x6060x Sep 15 '20
I'm not sure if you are joking. Especially without the /s tag.
7
u/pavelrappo Sep 15 '20
In Text Blocks sarcasm is marked with "\s".
1
u/s888marks Sep 16 '20
No, in Text Blocks "\s" is just a space. Sarcasm is denoted by "\\s".
1
u/pavelrappo Sep 17 '20
I stand by my original reply.
"foo bar".replaceAll(""" \s """, "");Perfection!
1
u/Prod_Is_For_Testing Sep 16 '20
Very useful for database generation and automation.
-1
u/x6060x Sep 16 '20
When I hear "raw sql query" the first question that pops in my mind is sql injection. How do you handle it? I am not saying there shouldn't be sql in the code, I was surprised of the 'raw" part
7
Sep 16 '20
There are two options, the sql query is static and doesn't change. Or it's a prepared statement and they use bind parameters correctly. Either way, I'm not sure why raw sql immediately means sql injection to you.
6
u/nutrecht Sep 16 '20
He means
"SELECT * FROM foo WHERE id =?"That's raw SQL. But still uses prepared statement. SQL injection was never really a 'thing' in the Java world (unless you really don't know about it obviously) because even the earliest versions had prepared statements.
0
3
u/Prod_Is_For_Testing Sep 16 '20
The other guy made good points: static queries and argument bindings.
There’s another that many people don’t consider depending on their line of work. Sql injection doesn’t always matter. If you’re making a web facing user portal, then yes it matters. If you’re making a dev tool for sys admins, it doesn’t because they already have the rights to nuke a DB
0
Sep 16 '20
[deleted]
4
u/Atulin Sep 16 '20
While ORMs are great for simple CRUD with joins and stuff, they don't really support things like stored procedures, or even views all that wall. And if you have a code-first approach and want to have a procedure in your migration, you have to hand-write it.
3
u/nutrecht Sep 16 '20
While ORMs are great for simple CRUD with joins and stuff
So is plain SQL. Whenever stuff gets complex you hand-written SQL that is checked with the query planner is almost always better and easier to maintain than an ORM.
Secondly; ORMs get used as an excuse to not even look at the generated SQL anymore. In my 20 years experience as a Java dev, pretty much every implementation I came across suffered from thge N + 1
You're much better off using a simple object mapper togeter with plan SQL, or something like JOOQ IMHO.
0
Sep 16 '20
[deleted]
2
u/Prod_Is_For_Testing Sep 16 '20
Most companies build systems around the database, not the code. So it’s very common, and even encouraged, to integrate existing procs in the code
1
u/Prod_Is_For_Testing Sep 16 '20
ORMs are not designed to build a database at runtime. For that, you need custom scripts in the code
3
u/TheIncorrigible1 Sep 16 '20
Have you never used a migration toolset within an ORM? Your opinions sound ancient.
36
u/renatoathaydes Sep 15 '20
RIP Nashorn... anyone that used that for JS scripting on the JVM should now use the GraalVM's JS engine (which works on normal JVMs, not only Graal's) as a library...
The new engine is fully compatible with ECMAScript 2020 (supports even native node modules) and has a compatibility flag for Nashorn-based scripts! We might need to use that at work as we have custom scripts that probably will never be upgraded.
5
u/avwie Sep 15 '20
Interesting. So, to be clear, that could be used to include JS scripting in your Java app or am I missing something. Can you give an example of why I’d be interested in Nashorn/GraalJS?
22
u/renatoathaydes Sep 15 '20
Java has had for a long time a scripting feature that allowed scripting engines to implement multiple languages, including JS (first with Rhino, then with Nashorn which replaced Rhino in Java 8), Jython (Python), Groovy, JRuby, Clojure and many others.
You may be interested in scripting if you want to let users extend/modify your application without re-compiling it (e.g. Jenkins lets you write pipelines in Groovy scripts, Minecraft lets users write "mods" to add game features, SoapUI lets you run Groovy functions before/after tests to modify/inspect requests/responses, and so on..).
Now, with graaljs, Java can run basically any Node/JS code - it's just an evolution of the JS engine (Nashorn was not truly compatible with Node and most JS code wouldn't run out-of-the-box) so it's much more useful as it opens up the whole JS ecosystem to Java developers.
2
u/mirkoteran Sep 15 '20
We use it to allow users to create custom expressions/functionality inside 'excel-like' grids.
4
u/syjer Sep 15 '20
the only downside is it's size, 20+mb of jars vs 3~mb of nashorn is kinda hard to justify for enabling some scripting in a application :(.
1
u/renatoathaydes Sep 16 '20
You can also use Groovy, it's only a couple MB.
1
u/syjer Sep 16 '20
If by couple you mean ~8mb [0], it still quite the heavy weight ;(
[0] https://repo1.maven.org/maven2/org/codehaus/groovy/groovy/3.0.5/
1
u/renatoathaydes Sep 17 '20
Oh, it has grown a lot in the 3.x release!! It used to be around 4 or 5MB: https://repo1.maven.org/maven2/org/codehaus/groovy/groovy/2.4.19/
7
u/pure_x01 Sep 15 '20
Thanks to AWS i can probably not use this for another 2+ years but im happy for you other guys and gals. Yes i could use containers but my org doesn't believe in releases of java that isnt cornetto
11
u/nyrangers30 Sep 15 '20
Lucky you can even use docker at work.
My company doesn’t want us using it because we can download whatever software from docker hub, although the flaw in their logic is that we can pretty much download any library we want with NuGet, so same shit.
1
u/brcolow Sep 16 '20
You could always implement a custom runtime. Here is an example I made: https://github.com/brcolow/lambda-java-runtime
12
u/Determinant Sep 15 '20
As a Kotlin developer, I'm really excited about this release because it makes ZGC production ready so that will benefit the backend applications that I work on.
2
u/DevGuides Sep 30 '20
Pretty good features. The ones which interest me more as a developer are Sealed classes, text blocks, and Records.
2
u/DetriusXii Sep 15 '20
Are inline classes still going to be coming to Java? From what I understand, inline classes are like Haskell's newtype, where a type can become boxed to make it distinct from its original type, but the compiler then erases the boxing class so that there's not any additional memory allocations for the boxing type.
9
u/BoyRobot777 Sep 15 '20
Yes. Here's Sergey, one of project Valhalla devs, saying that "soon" it will be merge to master branch. Video made 6 months ago. So I am hopeful for Java 16/17.
As far as I remember, they have already solved inline types. They are currently working on specialized generics.
3
1
u/flatfinger Sep 16 '20
While I think value types are a good thing, I would think Java could have reaped many of the benefits aeons ago if the Thread class had included a few fields of various types that functions could use to pass back multiple return values. If e.g. one wants a function that accepts an angle and makes both the sine and cosine available to the caller, that could have been handled easily by specifying that any function may store arbitrary values in the
DoubleRet0andDoubleRead1fields of the current thread object, and having the sine/cosine function document that it uses those to return the sine and cosine. If the caller is interested in those values, the caller would be expected to copy them to local variables before calling any other function.Functions' ability to return structures would be limited to those with few enough fields to fit in the indicated fields, but the relative benefits of returning multi-value types versus passing or returning class object references are greatest when the number of values is greater than one, but still relatively small. The more values need to be returned, the smaller the relative downside to passing or returning a class object.
0
-7
215
u/Ravoos Sep 15 '20 edited Sep 15 '20
Java devs: Cool.....I'm still using Java 8 tough.
Edit: Okay, I got a lot of interesting comments here when I just made a joke. Still, it is fun to read it all and to see just bow dedicated the Java guys are to their language