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.
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:
Kotlin goes the same route, but makes it little more natural to use: Besides simply more natural syntax, get the special 'it' variable, destructuring, more operations andNow take C#, a language had something "Streams" since version 3.0 (released 7 years before Java 8):
Where you get anonymous records - you don't need to define a new type anymore.Or with LINQ:
You get a highly readable built-in query language as well.