What I would love to come over from C# is: * Auto-Properties - Get rid of all those ugle getters and setters cluttering up POJOs * Object and Collection Initialisers - https://msdn.microsoft.com/en-us/library/bb384062.aspx
If there's no logic in the getter and setters, just make the properties public.
Java: Missing Features
21–30 of 54 posts
Re: Java: Missing Features
#22Re: Java: Missing Features
#23Re: Java: Missing Features
#24- Collection and map literal.
- Value type.
- Multiple return values.
- Destructure.
- Pattern matching.
Re: Java: Missing Features
#25Earlier quoted context omitted.
That works until you want to add logic without breaking existing interfaces.
Or until you need to use them in beans and the like.
Re: Java: Missing Features
#26Earlier quoted context omitted.
might want to checkout lombok. https://projectlombok.org/
Just keep in mind that some of the features are a bit iffy. If you use their vals IntelliJ will syntax highlight it as an error in red for the simple reason that it's non-compliant with the Java language spec. Also, you'll usually need a new version on Lombok every time a new version of Java comes out, otherwise what used to compile with the previous java version will no longer compile. If you use the auto constructo…
Re: Java: Missing Features
#27Earlier quoted context omitted.
Or until you need to use them in beans and the like.
Play!Framework 2 for Java is awesome in this matter. You write public members, but at compilation it transforms them into private members with getters and setters (if not final). It means if you write the setter, it overrides the default one.
Re: Java: Missing Features
#28Re: Java: Missing Features
#29Apart from primitive specialization the biggest omission in my opinion is the lack of value types ("structs"). It's almost impossible to write code that is heap allocation free or allows reasoning about cache locality.
Re: Java: Missing Features
#30Apart from primitive specialization the biggest omission in my opinion is the lack of value types ("structs"). It's almost impossible to write code that is heap allocation free or allows reasoning about cache locality.
Long story short: keep the traditional getters and setters but have just a byte[] field to store the object state. For example If you need just the date (without the time) you can store it in 2 bytes, say 7 and 8, and in getDate() method you do
public Date getDate() {
int day = bytes[8] * 256 + bytes[9]
return new Date(day * MILLIS_PER_DAY);
}
Some of the improvements are amazing