I appreciate changes that make it easier to monitor and debug applications. Looking forward to some small goodies that I haven't heard much about before:
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.
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?
Am I missing properties? Dear god it's 2016, with Java8, and we still don't have real, language-defined properties? I mean you can use Lombok (and if you're not, you should be!), but that's something that really need to be built into the language. C# has them, Python has them, Ruby has them .. even other JVM languages like Scala have them!
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 really don't understand why people love properties so much. Getters and setters are elements of bad style to me - like global variables or gotos. A language like Java (or indeed C#) - specifically designed for huge teams and enterprise programs - shouldn't provide syntax sugar for writing getters and setters.
Probably a rethink of the design. Why are you creating an object, then mutating its name from client code?
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.
I agree that setter properties are often a code smell, but getter properties are nice for calculated fields. As a very simple example, consider the following (C#):
class Circle
{
public Circle(int radius) { Radius = radius; }
public int Radius { get; }
public int Diameter => Radius * 2;
}
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?
Thing is you don't really need to write getters and setters in modern Java.
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.
Adding 8 comment lines doesn't help your argument. More importantly though, you need to consider the mental load of constantly thinking about and remembering whether something is a property or a method.
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)
Can you clarify what's inconsistent about properties in C# (seeing how this is the most obvious counterpart), and how it doesn't apply to Java's properties-by-convention?
> Regarding the properties I really don't get what is the big deal.
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.
Properties are not a huge deal, I agree, but they sure are annoyance in Java (compared to e.g. C#).
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'.
Properties mean a lot of things to different people, and C#'s can do stuff that you don't expect so I would guess won't make it into Java as they tend to prioritise reading code over writing it. Having said that if you look at https://www.oracle.com/javaone/on-demand/index.html?bcid=513... about 30 minutes in you might see Brian talking about something that may be close enough to what most people want from properties to satisfy them.
> Properties mean a lot of things to different people
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.
Does anyone have a list of smaller gems that are not on that list? For example JDK 9 contains an implementation of the CRC32C-algorithm which can be used by web developers to create compact entity tags. I read somewhere that there is even hardware support for it but I'm unsure whether it's being utilized by the JRE.
http://openjdk.java.net/projects/jdk9/