News for hackers. Stuff that matters.
Re:Java 8: New features in ConcurrentHashMap by lmm on Wednesday January 18, 2017 @11:04AM (#13427317)
Case classes, default arguments, type inference, Spark, an ecosystem that's already moved off null and off exceptions, unified type hierarchy with value types, much nicer async API, higher-kinded types. Just generally replacing all the magic annotations and XML with plain code. I mean if most of the good stuff in Java 8 is taken from Scala then why not get a head start on the kind of stuff that will be in Java 9/10/11?
Re:Java 8: New features in ConcurrentHashMap by kentosi on Wednesday January 18, 2017 @02:17PM (#13429378)
Yes, case classes!

I currently use Java for work and I cry a little inside every time I see big hashCode() methods, toString() methods and a chain of getXXX()/setXXX() methods when I know that a simple case class statement would have been all that was needed.

Re:Java 8: New features in ConcurrentHashMap by merb on Wednesday January 18, 2017 @02:27PM (#13429495)
well if you don't need hashCode, copy, toString etc you can use:

    final class Data() {
      final int id;
      final String name;
      public Data(int id, String name) {
          this.id = id;
          this.name = name;
      } 
    }
No need for getter/setter. Still not as good as the scala one tought, but probably a little bit faster since it does not use accessor methods.

P.S.: I'm a scala user.

Re:Java 8: New features in ConcurrentHashMap by lmm on Thursday January 19, 2017 @07:26AM (#13435212)
For the sake of comparison the Scala equivalent of those 8 lines is:

    case class Data(id: Int, name: String)
and comes with all the other things merb mentioned. And it's unlikely to be any slower in practice since the JIT can inline the access (not that method calls are ever likely to be a noticeable overhead anyway).
Re:Java 8: New features in ConcurrentHashMap by jermo on Thursday January 19, 2017 @10:20AM (#13436412)
I've found that Project Lombok solves this problem for me. Simply add a @Data or @Value annotation and it will generate getters/setters/hashCode/toString etc. https://projectlombok.org/features/Value.html
Re:Java 8: New features in ConcurrentHashMap by lmm on Thursday January 19, 2017 @11:30AM (#13437036)
I started with Lombok but found that you're effectivly writing a different language from Java anyway - all your tools (IDEs, code coverage, binary compatibility checking, build infrastructure... ) need to support it. So it's just as much effort as Scala, and gives you a lot less in return.