Live data from Hacker News

Java: Missing Features

infoq.com

31–40 of 54 posts

Re: Java: Missing Features

#32
post #14

> The issue of primitive specialisation of generics is only tangentially related to type erasure, and run-time visible generics are actually much less useful than Java folk wisdom insists. Run-time visible generics are pretty important because it lets us avoid boxing everything. In .NET, they don't have this problem, and as a result primitive dictionaries are ~17x faster [0]. Java folk wisdom seems pretty accurate to…

Did you read any of the comments? I did and I am certainly not qualified enough to know if the 17x faster claim holds up at all.

Re: Java: Missing Features

#33
post #3

Some of these, like reified generics, would be great, and it's sad it's too late to add them to the JVM. Some of these, like more expressive imports, seem pretty pointless given that we use IDE's. But some of these are quite un-Javaish. Structural typing would really go against the grain of the language, and i have a very hard time believing it would actually be useful. What method name is currently widely used with…

FYI Guava gives you those constructors, the map is:

ImmutableMap.of(Key, Value, Key, Value...);

For ones with more than 4 values you will need:

ImmutableMap WORD_TO_INT = new ImmutableMap.Builder() .put("one", 1) .put("two", 2) .put("three", 3) .build();

Re: Java: Missing Features

#34
Some of those missing features are being worked on for Java 10 and can be tested already from the early prototype that is available.

JVMLS 2015:

https://www.youtube.com/playlist?list=PLX8CzqL3ArzUo2dtMurvp...

Technical Keynote at JavaOne 2015

https://www.oracle.com/javaone/on-demand/index.html

Of course, first we still need to get Java 9.

And then when Java 10 with value types, reiffed generics, new FFI API, long Arrays is available, one can write blog posts about being forced to use Java 7 with these missing features on Android.

Re: Java: Missing Features

#35
post #24

Things that would be good to add in Java are: - Collection and map literal. - Value type. - Multiple return values. - Destructure. - Pattern matching.

that multiple return values got me interested. I can see this exploding complexity/unreadability of the code at first glance.

honest question - what would be real added value compared to dedicated wrapper type holding all you need for return?

Re: Java: Missing Features

#36

Apart 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.

http://objectlayout.org/ is a possible solution. But currently it and panama and JEP 169 are still forming into a hopefully coherent gestalt :(

Re: Java: Missing Features

#37
post #27
post #25

Earlier quoted context omitted.

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.

Lombok does the same ;)

But then you're using Lombok...

Re: Java: Missing Features

#38

The author of the article seems to be essentially looking for Kotlin (except for the structural typing part, which is a terrible idea and which Kotin thankfully ignored).

Structural typing is actually very useful when you need it occasionally, which is one of the reasons I've largely ignored Kotlin so far. The jury is still out on that one.

Re: Java: Missing Features

#39
post #4

Earlier 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…

We use Lombok heavily where I work, on > 5 projects and have yet to run into any problems like you describe. Everyone use IntelliJ apart from myself and haven't heard any issues with using 'val'. We started off just using it in tests but it's now spread throughout the code base, I can't imagine going back to pre Java 8 sans Lombok.

Re: Java: Missing Features

#40
post #24

Things that would be good to add in Java are: - Collection and map literal. - Value type. - Multiple return values. - Destructure. - Pattern matching.

that multiple return values got me interested. I can see this exploding complexity/unreadability of the code at first glance. honest question - what would be real added value compared to dedicated wrapper type holding all you need for return?

1. Not having to declare a pointless wrapper class.

2. Tuples support pattern matching.

3. For simple cases the return type is clearer, no need to dig up another class declartion to figure out what the field types are.

Post reply on HN