r/programming • • Sep 21 '17

Java 9 Released

http://mail.openjdk.java.net/pipermail/announce/2017-September/000230.html
504 Upvotes

154 comments sorted by

View all comments

151

u/throwawayco111 Sep 21 '17

Percentage of Java developers that will be able to use it for commercial development in the next 5 years: 9%

102

u/thesystemx Sep 21 '17

JDK 8 had a very high adoption rate. Within a year many ordinary Java developers were using it for commercial development.

I'm afraid JDK 9 may take a bit longer...

101

u/caagr98 Sep 21 '17

That's probably because Java 8 had lambdas. I didn't see anything particularly exciting in the feature list for Java 9.

0

u/[deleted] Sep 22 '17

[deleted]

12

u/apemanzilla Sep 22 '17

There's Jigsaw, but existing building tools already do a good job of managing dependencies and things.

30

u/sammy8306 Sep 22 '17

And they will keep doing that. However, Java modules now enable you to strongly encapsulate internal implementation details of modules in your application, while only sharing APIs. This is a pretty big deal if you're developing (moderately) large applications in a team-setting. In fact, this is one of the main reasons the JDK is now modularized.

Also, Maven/Gradle etc. don't have a role beyond build-time. Java modules carry their meta-data to run-time, where you can now rely on module resolution to tease out any dependency problems. What's more, a new tool called jlink allows you to leverage this explicit dependency information to create custom runtime images. These images contain only the modules your application needs (incl. modules from the JDK).

So all in all having modules as part of the platform will be a big step forward. It will take time, for sure.

(full disclaimer: I'm author of Java 9 Modularity, O'Reilly, see https://javamodularity.com)

→ More replies (6)

4

u/tetroxid Sep 22 '17

What exactly will modules do for me in my daily life? How is it an improvement over maven already automatically downloading the "modules" I depend on when building?

7

u/Linvael Sep 22 '17

One thing I heard that is neat is that libraries you use will be able to hide their internal APIs resulting in less clutter when searching for right import.

5

u/tetroxid Sep 22 '17

Isn't that what private and package-only methods are for?

10

u/duhace Sep 22 '17 edited Sep 22 '17

They aren't enough. Take for example the factory pattern. Perhaps you want some implementation classes of interface A that are only available to users through the AFactory class, and perhaps you want all those classes to be passed out as A, completely hiding their implementation details

You could make these impl classes private inner classes of the factory, but that can cause an unwieldy mess. JPMS modules let you hide them while structuring your code better by saying "this module only makes interface A and the AFactory class visible outside the module". It's much stronger encapsulation than private public and protected provided

Edit: a very good instance of what jpms solves is the sun.misc problem. The java.* classes are the API, sun.* is the implementation. You're explicitly warned not to use sun.* packages cause they could change from release to release (or not even exist in future releases or on other JVMs). But people still dip into them for many reasons. This creates two problems. It makes changing the implementation harder, and it removes an important impetus to improve the API. With modules, those classes can be hidden away from everyone but those working on the JVM itself, causing less headaches from upgrading the JVM than before. It also drives the Java devs to implement into the standard API what users were reaching for in the implementation(for example, sun.misc.Unsafe should have a java.* analogue in java 9)

edit2: I'll fix this post when I get to my laptop, thanks Reddit phone app for making code snippet markdown near impossible

4

u/tetroxid Sep 22 '17

I see. Thank you for taking the time to explain that to me, I appreciate it!

→ More replies (3)
→ More replies (2)

5

u/Fenris_uy Sep 22 '17

Jshell and the module system.

I want to try both of them, but none are needed for running your code, just for building it, so I might not change production to it.

When wildfly switchs I might switch.

0

u/[deleted] Sep 22 '17

[deleted]

3

u/renatoathaydes Sep 22 '17

The latest Java 8.x version is *8u144, so, no.

4

u/[deleted] Sep 22 '17

Collection Factories might be cool

4

u/pkulak Sep 22 '17

Yeah, kinda. But we've all been using the Guava ones forever now anyway.

→ More replies (1)

13

u/mscheifer Sep 21 '17

We're still on Java 7 here. :-/

39

u/Sun_Kami Sep 21 '17

Why? I don't understand why any company would do this. We upgraded from Java 6 to Java 8 a few years ago and hardly had to change anything... And at that point we were using Struts 1.4 or some nonsense which was so deprecated (no longer on that stack, thankfully)

12

u/langebangen Sep 22 '17

We still use Java 7 and the reason for this is because of our IT department. We use Debian and Java 8 was not introduced in a stable release until Debian Stretch which was released in June this year. Sure, it is possible to add a backport to get Java 8 but this is where the IT problem comes in. We (the developers) are not allowed to upgrade the machines were our Java applications are running (not even our own workstations), and IT has never prioritized our demands so unfortunately we have no choice but to wait until IT has time to upgrade the machines to the latest Debian release.

We are thinking of including the JRE with all the java applications we develop to be able to upgrade to Java 8.

4

u/Fenris_uy Sep 22 '17

Look at jlink to be able to do that with java 9.

→ More replies (1)

13

u/Dreamtrain Sep 22 '17

You're probably thinking for internal use to make coding better, but if you're giving maintenance to a client's already robust application, upgrading the web server's environment and testing everything is a cost your client may not want.

→ More replies (1)
→ More replies (1)

10

u/thesystemx Sep 21 '17

I feel for you

6

u/tetroxid Sep 22 '17

You should upgrade. Java 8 is a massive improvement over 7.

→ More replies (1)
→ More replies (1)
→ More replies (1)

19

u/GuiSim Sep 22 '17

You underestimate the number of SaaS that runs on Java. When you control everything you can easily update to the latest version.

→ More replies (11)