News for hackers. Stuff that matters.
Re:Love It or Hate It, Java Continues to Evolve by unscaled on Monday June 17, 2019 @06:42AM (#20201597)
Java 11 is obviously much better than Java 8, which is still leaps and bounds ahed of Java 6, itself an improvement over Java 4. You'd see the same in every language.

Java's problem is that for many years it used to be the slowest car around. Maybe this was one of the things that helped Java become the undisputed ruler Enterprise Inc. but now it's got a lot to catch up with, and even though the pace has picked up since Java 9, it's far behind its competitors.

Everything you mention (var, lambdas, streams) and everything you might mention when Java 13 comes out (switch expressions, text blocks) is just too little, too late.

Yeah, var is a lifesaver if you have to use Java, but compare the limited type inference it brings to the table with almost any other competing language (Kotlin, C#, Scala or Swift) which at the very least can do a return value inference.

Likewise, streams are long due, but the syntax is horrible and the repertoire of built-in operations is meager, and since Java does not support extension functions like the rest of the languages mentioned here you can't extend them gracefully.

If you take one of the examples given here:

  var grades = school.students()
                 .stream()
                 .flatMap(student -> student.grades()
                    .stream()
                    .map(grade -> new NamedGrade(student.name(), student.grades())
                 .filter(x -> x.grade() > 60)
                 .collect(Collectors.toList());
Kotlin goes the same route, but makes it little more natural to use:

  val grades = school.students
                 .flatMap { (name, grades) -> grades.map {
                              NamedGrade(name, it) 
                  }}
                 .filter { it.grade() > 60 }
                 .toList()
Besides simply more natural syntax, get the special 'it' variable, destructuring, more operations and

Now take C#, a language had something "Streams" since version 3.0 (released 7 years before Java 8):

  var result = students
                  .SelectMany(student => student.Grades.Select(grade => new { Name = student.Name, Grade = grade }))
                  .Where(record => record.Grade > 60);
Where you get anonymous records - you don't need to define a new type anymore.

Or with LINQ:

  var result = from student in students select
      from grade in student.Grades 
      where grade > 60
      select new { Name = student.Name, Grade = grade };
You get a highly readable built-in query language as well.
Re:Love It or Hate It, Java Continues to Evolve by rjbwork on Monday June 17, 2019 @07:08AM (#20201744)
Quick nitpick. Both of the C# examples are called LINQ. The first is called the "method syntax", the latter is called the "query syntax". The query syntax is transpiled into the method syntax before compilation.
Re:Love It or Hate It, Java Continues to Evolve by pjmlp on Tuesday June 18, 2019 @04:09AM (#20210608)
The slowest car still gets you down to the city center.

And neither Java nor C# have anything to brag about Streams or LINQ.

I could already writen those code examples in Lisp, Scheme, Caml Light or Smalltalk.

What we have is mainstream computing catching up, or as Erik Meyer has stated, selling Haskell to VB programmers.

Re:Love It or Hate It, Java Continues to Evolve by floriol on Monday June 17, 2019 @05:18PM (#20207491)
You have Clazz::someMethod in java so no need to write out the whole lambda expression
Re:Love It or Hate It, Java Continues to Evolve by anextomp on Monday June 17, 2019 @03:51PM (#20206654)
With kotlin, the final .toList() call can be removed