JDK 9 release schedule
mail.openjdk.java.net
mail.openjdk.java.net
Generic Specialization
Reified Generics
Native Function Calling
Native Data Access
New Data LayoutsThis will not happen.
http://www.oracle.com/technetwork/java/javase/community/jlss...
https://www.youtube.com/watch?v=Tc9vs_HFHVo&list=PLX8CzqL3Ar...
Brian did not state they will never do it.
Also the other languages could take advantage of it anyway, even a reiffied version of Java for example.
Could you please provide a reference for this? Even a broad one like "a post on the Valhalla mailing list during the past summer" would be very welcome.
I'm eagerly awaiting for this feature and not being able to extend user-defined value types would be a bummer.
[1]: For example, if B is a subclass of the value type A, what do you think would happen when you store a value of type B in an array of type A?
* They have no identity.
* Because they have no identity == comparisons is based on their data.
* They cannot have super classes or sub classes (they can implement interfaces though.)
* They are immutable.
* They cannot be null.
https://www.youtube.com/watch?v=Tc9vs_HFHVo&list=PLX8CzqL3Ar...On my .NET projects we get a full installation from Visual Studio on the development machines. Which means C#, F#, C++ and VB.NET available.
On my Java projects those machines have usually Eclipse + JDK. JARs are either vendored or make use of an internal Maven server.
I am yet to be allowed to use anything other than Java (the language) on those kind of projects.
Most customers want replaceable consultants so they don't allow us to go outside of their standard stack.
I've got a mix of C#, Python, Kotlin and pl/pgsql code running in production right now and we've also for projects written in Node.js that are live as well. I've even got some F#!
This will happen.
Edit: It seems removing unsafe is just a rumor.
Unsafe is going to stay
Also, I don't think this falls under Valhalla (and I'm not sure if it's been committed yet), but the possibility of reasonable type inference in Java 10 would make me rather happy.
Valhalla is pretty big. Goetz described it as pulling on a very long string. It's going to touch everything in the JVM, including reifing generics, although as I understand it, erasure of Objects may be here to stay for the language.
What's broken in the JVM isn't erased generics but instead runtime reflection that is a lie due to erasure. Type erasure though is definitely an example of Java getting something very right for the wrong reasons.
Furthermore, runtime specialization (as opposed to compile-time) would seem to require reified types. So that further confuses things. But you can definitely have reified types without specialization, which I think is the point that you are trying to convey.
Either way, CLR and C# did it a long time ago, and in the same time period when Java acquired its type-erased generics.
specialized generics. this is a huge one, too, less boxing is always a win.
JEP-286 less typing.
Maybe Project Panama and maybe a even better AOT.
Compared to what JDK 9 brings, this is huge. JDK 9 brings a Module system which was already possible (and a lot of stuff around it which didn't exist), a new GC algorithm, Tiff Image I/O, jshell, ALPN, http2 client, reactive-streams. (P.S.: not everything is complete here, but this stuff will probably be used by most)
JDK9 mostly brings stuff that was already missing and provided by other libraries. JDK10 will probably change a lot of more things in the JVM ecosystem.
public class something(String name, int age) {
...
}Say you want a POJO with accessors, mutators along with equals and hashcode. Let it generate the methods by defining a class like:
@Data
public class something {
String name;
int age;
}
Lombok generates: public String getName() { ... }
public void setName(String name) { ... }
public int getAge() { ... }
public void setAge(int age) { ... }
public boolean equals(Something other) { ... }
public int hashcode() { ... }
public String toString() { ... }For lombok specifically, other languages have these types of features built in which of course people need to learn in order to use it.
I agree it isn't a perfect solution, but java is in dire need of boilerplate reduction features like this and lombok fills this need well.
https://projectlombok.org/features/val.html
I've been doing C# for while... soo nice to have this. Coming back to java was like "why am I repeating myself". They already did the diamond operator on the right hand side, this makes the left just as nice.
now let the flames begin!!!
Oh also found a use for SneakyThrows today... I'm bootstrapping a test server in my unit test, where all of the code and interfaces are designed for safety and no-crash... and this lets me short circuit right out of it when something bad happens, which in a test setup is what I want.
Getters and Setters are verbose, but usually model classes are contained in a single class anyway, and can be generated automatically with any IDE. I can glance at a typical bean and ignore the code bloat without any problem.
The real issue is that Lombok generated classes don't play well with the dozens of libraries that expect Java bean style methods for auto marshaling and serialization: json generators, commons bean utils, binding libs, etc.
The savings aren't worth the trouble.
You can argue against Lombok for other reasons but was wondering about this specific one.
Why would native be any better? I would think that as long as the implementation matches the reference it wouldn't matter.
http://openjdk.java.net/jeps/228 - Add More Diagnostic Commands. For example more insight into JIT:ed methods and the code cache.
http://openjdk.java.net/jeps/158 - Unified JVM Logging. Logging from the JVM, e.g. GC logging and classloader logging, are configured and printed uniformly.
http://openjdk.java.net/jeps/259 - Stack-Walking API. Efficient API for walking the current call stack.
Oh, nice! At any given moment in time, how many server CPUs are burning cycles to create a full StackTraceElement array, just because the logger is set up to provide the convenience of call site information with every write?
See http://download.java.net/java/jdk9/docs/api/java/util/zip/CR....
The proposed ones "F Pro 9" might just make it on 10.
I'm really glad I get to do Scala development full time. Even with all the recent improvements to Java 8, I feel the future of Java isn't the language, but the JVM and all the other languages that run on top of it (Scala, Groovy, Clojure, JRuby, etc.)
I am yet to work in a Java project where I am allowed to use any of them.
Regarding the properties I really don't get what is the big deal.
No one used to complain about C++ properties, that besides having to write accessors and mutator methods, one needs to declare them on the header files as well.
Or the first version of C# properties isn't much shorter than how it is done in Java, which is still required when extra logic needs to be implemented.
It is been a few years since I have done any Python, but don't do they require two separate functions that are then mapped to a property declaration?
I used to feel the same as you, then I dabbled with Rails. I think the deal is that in Java there is a lot of noise in the code. So, developing feels like you need to do a lot of yak shaving before you get to actually work on what you intend to build.
As a result, properties on their own isn't a big deal, but it's one more thing to slow you down and make things a little less enjoyable.
OTOH IDE-generated code is "normal" source code, adding boilerplate to your "real" code, not tracking changes in it automatically, and perfectly breakable.
What do you think Lombok is doing?
The savings in screen space and visual cortex neurons doesn't come from the one or two properties that need logic, it comes from the dozen avoided
/**
* Gets the foo
* @return the foo
*/
public Foo getFoo() {
return foo;
}
/**
* Sets the foo
* @param foo
*/
public void setFoo(final Foo foo) {
this.foo = foo;
}I used to be an advocate property syntax, but after seeing them used in C# and now in Swift I have completely changed my mind. It's an inconsistent mess that Java has avoided at the small price of some more lines of code (that are mostly auto generated and need no documentation)
In C# you do have to think about it all the time. Most types have both properties and methods and in many cases it's not obvious whether the author of that type had the same idea about whether or not something should be a property or a method as you do. Where you only have to remember a name in Java, you have to remember both a name and its syntactic category in C#. One more thing to keep in mind equals greater mental load.
In fact, the guidelines for choosing between one and the other include considerations that should be of no concern to the user of a public interface (https://msdn.microsoft.com/en-us/library/ms229054(v=vs.100)....). If any of these implementation details change, the logical conclusion would be to change the public interface from property syntax to method syntax or vice versa. That's what I call inconsistent.
If you're saying that the choice between getX() and x() in Java is also somewhat inconsistent then you are absolutely right. It's just not a problem on the same scale as in C#.
And if the implementation of a C# property changes in any of the ways that would make it a method, that probably deserves to be surfaced as a breaking change in the API. That's a feature, not a bug. eg, I would certainly want to know if the implementation of a property was changed from a field access to a network call.
And if you look at the guidelines I linked to, you'll see that the criteria that are supposed to tell us whether or not to use a property are much more subtle than making a network call vs accessing a field. Can you really justify a breaking change to a public interface because a type conversion is introduced in the implementation of property?
I think disguising a function call as a direct variable access is much more problematic than calling a function that may or may not do more than return the value of a variable.
That said, I do realize that reasonable people can absolutely disagree on this issue.
>>Can you really justify a breaking change to a public interface because a type conversion is introduced in the implementation of property?
I just quickly re-read that page, but I don't see what you're referring to here.
"The operation is a conversion, such as the Object.ToString method."
But this only pertains to the conversion of the object on which the property is defined. In other words, you should have methods like ToString or AsEnumerable, rather than properties like String or Enumerable, even though other rules would indicate property to be valid (idempotent, fast, no arguments). This rule is just an indication that properties represent conceptual attributes of an object; and the result of a conversion of an object to something else is not an attribute.
Semantically, the difference between properties and methods is the same as the difference between data and behavior. Are you saying that it's not a useful distinction to have?
They're quite a smell that you have no encapsulation, plus mutable state.
I find myself either
- Writing object oriented code with higher level operations that operate on data internally without exposing it via getters and setters.
or
- Value types that take values in constructor and provide naming and additional behaviour on that data (proper Value Types support will really help with this.)
or
- Data pipelines dealing with n-tuples. For which you might be tempted to reach for getters/setters but I'd tend to either use off the shelf tuple types. i.e. tuple(A,B,C) or classes with public fields, or interfaces with static factory to create instances. I'd love better support for tuples with named attributes (Like new c# has)
Loads of getters/setters is something that the frameworks of the last decade encouraged people to do but aren't really a thing any more.
Now you're left with something that could be fit on three lines (the "final" for the parameter is also useless and can be removed):
public Foo getFoo() { return foo; }
public void setFoo(Foo foo) { this.foo = foo; }
Even if you don't write the actual source like that, a good editor like IntelliJ can automatically display them like that (code folding).The C# version is about the same length:
public Foo Foo {
get { return foo; }
set { foo = value; }
}
Also, you don't have to write the get/set methods yourself. You hit a few keys and your editor generates them. public Foo Foo { get; set; }
and get the backing field for free.There are bigger fishes to fry in Java than how properties are defined.
Bring in properties already.
public Foo Foo { get; }
or for a computed property: public int Foo => Bar + 1;
The real savings from property come when you use them, though - the extra pair of () doesn't feel like much, but when you start chaining properties, I find that not having () there significantly improves readability. Then, of course, Java also insists on `get` prefix by convention. So you have Java: foo.getBar().getBaz().blah()
vs C#: foo.Bar.Baz.Blah()
More importantly, the latter visually emphasizes the difference between accessing data and operating on it. You can see that "Bar" and "Baz" are data members, conceptually similar to "foo", whereas "blah()" is an operation.Compare with Kotlin:
class MyFoo(val foo: Foo)
Done.That is, instead of one line of the code declaring the property, we end up with 10 lines doing the same thing, because we also need to declare getter and setter.
So, a realistic "POJO" that has 8 properties, will have 8 lines of code in C#, but 80 lines of code in Java.
Sure, your IDE will generate the getter and setter, but when you are reading the code, you have to check whether getter and setter are trivial, or perhaps they do something else, too.
It is quite common to get burned by a setter that someone made so that, after setting the value, it also does other shit like, hit Google Analytics, which is why everything is so slow.
The above problem is super easy to spot in 8 lines of code, but much harder to spot in 80 lines of monotonic, repeatable code, especially so when they are decorated with another 100 lines of code that is IDE-generated comments like 'Sets the foo'/'Gets the foo'.
My 5c.
Thing is, this is true whether your language offers syntactic sugar for them, or not. Properties already exist in Java, they just exist as a matter of convention and custom - but the expectations on how they behave are just as strong, and a misbehaving getter, say, is just as surprising and damaging.
So you don't like either of the following:
myObject.name = "Ben";
myObject.setName("Ben");
What alternative would you suggest then?The whole point of an object is that client code shouldn't be concerned with such details as maintaining the state of each internal field. Try and think of an object as a single thing you send high level messages to you, instead of a struct, or a bag, or a hashtable.
Says who?
For example, there is a business requirement that we know the on-hand quantity of some item in the warehouse.
It's a busy warehouse, and we keep picking that item for delivery, and replenishing it from our suppliers.
So, the quantity of the item keeps mutating.
How do you propose to deal with the above? Tell the warehouse people that they should only do their thing "rarely"? Seriously.
What is the point here?
Point - say you have a database with 300 tables and ~3,000 columns.
You do not want to play the game of "hide the method to change the value". That is a big waste of time for everyone involved.
Yeah I want to say that for us developers, "rare" is not something that we can code, without some serious sophistication.
More likely we code "if" and it is either "yes" or no".
To capture "rare", we need some serious tools - statistics, analytics etc etc. That is way beyond the regular developer toolset.
For me a better question is - why is the name being changed? What high level goal are you trying to accomplish that truly needs you to to directly mutate internal fields, after the object has already been created? Could the object - or system of objects - have been designed with a higher level interface, so that the outside world didn't have to concern itself with such things?
As an aside, I'd probably make a method called "rename" that does this, as opposed to something like "setName".
Consider a trivial to-do list. You can click on the 'completed' checkbox. So the 'completed' field has chaged.
Or, you can say ooops I mistyped the label. So you change the label.
Is there anything wrong with that?
I don't know if it's worth the overhead of having unthinking developers writing { get; set } for every field in every class because it makes things "easier".
I don't know if it's worth the overhead of having unthinking developers writing { get; set } for every field in every class because it makes things "easier".
I do not understand your point. First you claim that we should not mutate the field, then you claim that we should mutate the field.
Which one is it? Mutate or not?
We should generally not use goto or local variables either. Avoid reaching for these constructs first. But if it's by far the cleanest, and simplest way of solving the problem - which it usually isn't - go ahead and do it.
class Circle
{
public Circle(int radius) { Radius = radius; }
public int Radius { get; }
public int Diameter => Radius * 2;
} public int Radius; public final int radius;I still see projects using Java 5...
The speed at which they stop freely supporting older versions feels much like a way to squeeze big, slow moving organizations for support contracts.
What do you think those medium sized business apps are built off of if not things with JVM dependencies? It's not so simple.
Some things like Guava got more or less obsolete in JDK8.. so seeing it targeting JDK5.. doesn't really matter.
Also JDK5 stuff will work on JDK8.. so you can suck in all the JDK5 libraries you want, but still run a JDK8 project.
Are you serious? Even the worst shops I've been at have at least moved their JVMs to Java7 back around 2014. I mean you can take all your existing JARs from Java4 and run them on Java8 and nothing should break. Recompiling them might be another issue, but still not a huge one.
Having said that being on and old supported version of these products means you are at least enjoying Java 6.
My last contact with Websphere was in 2014 and the customer was still using 6.1 on their production servers.
In addition to benefiting from the new features, being up-to-date is good for recruiting. You tell someone they'll be working with Java 6 and (in the absence of other evidence) they'll assume it's a legacy product suffering from chronic under-investment. Not exactly the impression you want to give job seekers!
Or Android.
Also I don't have any issue with Java as I do like the language and use it since JDK 1.0.1.
My issue is with Android Java, a forked version of Java with cherry picked features of Java 6, 7 and now 8, just because Google didn't want to pay Sun.
A version that will be even harder to write portable code when Java 9 and 10 come out.
I believe Google is running out of solutions to further optimize Android because they keep running into self inflicted Java roadblocks. If Fuchsia is any indication of their future efforts their next major overhaul will support multiple first class languages.
As for Fuchsia and Brillo, it remains to be seen if they will ever be productified.
Also I don't believe that Dart is a better option than Java in regards to performance.
Some ideas that would bring people back:
* Wildly new, terse, and clear syntax and a great library of built-in tools that are briefly and intuitively named.
* Easily write and design interfaces that generate both/either back-end or matching integrated front-end code which is off in its own directory and can easily be used by existing JavaScript and HTML.
* Similarly be able to generate the JavaScript front-end code that use those JS client libraries with easily writable/pluggable generators so that it can generate Angular 1.x, 2, ReactJS, Bootstrap, etc. in "best-practice" ways that can be updated frequently as the community changes.
* Simultaneously provide the option to serve very similar pages using straight HTML, degrading even to the point that a text only browser could use the site easily.
* Easily define responsiveness of pages.
* Support multiple 3D, 4D, etc. interfaces with customizable inputs to be forward-compatible without overdoing complexity (i.e. it's really pluggable).
* Similarly support generation of almost any kind of service integration, with easy pluggable authN/R.
* Easily scalable.
* Relational, noSQL, versioning DB (noms) support.
* Make fun books for kids and a site where they can share what they've written, write games, build things, etc.
* Make it integrate with every browser, even some older versions, operating systems.
* Make it compile low-level vs. byte code so it's fast as shit.
Java's going to be around a long time. Those that stick with it will be fine. COBOL programmers made a lot of money in 1999, and some people still use Fortran.
But, Java's original big mantra was "write once, run anywhere." Such idealism then. Cool things have been done in the past few years, but can't we do more?
In particular: - curated and tested open source library dependencies to the point that you can generate a single JAR for anything you might want to build on the server: http://start.spring.io/
- Annotations and APIs to make REST service development a breeze
- native support to build apps that use SQL, NoSQL and other Data systems without plumbing: http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/refe...
- SSH shell/CLI into your JVM to manage your JVM
- Actuator to provide production metrics for your system
- declarative security that allows you to build Oauth2 enabled apps in maybe 20 lines of code/annotations
- great symbiosis with modern JavaScript for responsive sites, eg https://spring.io/blog/2015/01/12/spring-and-angular-js-a-se...
- Cloud connectors to make it easy to run your app on Heroku, Kubernetes, Mesos or Cloud Foundry, or to leverage NetflixOSS components, or to build stream processing applications (Spring cloud stream / data flow)
It is being downloaded and used at a very high rate (a couple million a month).
Kotlin
> great library of built-in tools that are briefly and intuitively named.
I dunno, guess this depends on what you need. The Java class library has so much in it, but I guess it's not overly intuitive due to the age of a lot of the packages. Personally, I don't think I'd have a hard time getting my .Net-loving colleagues accustomed to everything as is.
Java EE is another matter entirely, I gave up on it after the Java EE 8 clusterfuck that's going on and have just decided to use Spring for everything.
> Easily write and design interfaces that generate both/either back-end or matching integrated front-end code which is off in its own directory and can easily be used by existing JavaScript and HTML.
What are you looking for here? Automagic API's? spring-data-rest says hello. I still find it's better to write my own, but if you need something for a quick prototype there you go.
> Easily scalable.
How are you wanting to scale? Where is your bottleneck? This isn't on the language to solve, it's how you design your application. I can throw up 2,000 instances of an application, but whether the database behind it can handle 100K/tx/sec is another story entirely.
> Relational, noSQL, versioning DB (noms) support.
We've had JDBC, JPA, jOOQ, QueryDSL, etc, forever for the relational story. There's plenty of support out there for various NoSQL databases (Spring even has spring-data-cassandra which I am looking at using right now for an ES/CQRS design).
> Make it integrate with every browser, even some older versions, operating systems.
Why? Java in the browser is dead. If you want to write client-side stuff just use JavaFX and package using WebStart or an installer that bundles your JRE and dependencies.
> Make it compile low-level vs. byte code so it's fast as shit.
Java is already "fast as shit". The warmup time for HotSpot and initializing the JVM is probably the big complaint everyone has, but unless you are writing small command line tools it is a complete non-issue.
With that said, Java 9 will support limited AOT compilation of modules to reduce the time to get basic compiled versions of your classes - HotSpot will still profile the compiled modules, and if finds it is required it will deoptimize, re-profile through bytecode interpretation and reoptimize - just like it does with normal .class files (which are still required to run).
AOT compilation is not automatically faster than JIT compilation. Java already is fast as shit. If you're worried about that first 100 milliseconds, works is being done on AOT compilation.
Of course without runtime profiling the AOT built code may not be optimized for the hot path correctly, HotSpot will still deoptimize in this case and begin profiling again - so it's not going to be suitable for everything until they allow you to capture profiling details and feed it into the AOT compiler.
I don't think Java needs any help in that department given how crazy popular it is.
And Android has made it even more popular than it ever was these past eight years.
Java has a few issues but the learning curve is not one of them.
I see no JSON, I have to use a 3rd party lib. And ... no word on fixing logging divergence.
https://docs.oracle.com/javaee/7/api/javax/json/package-summ...
http://paste.debian.net/883460/
( May be incredibly unsafe, only just thought of it now. )