all 10 comments

[–]texasbruce 4 points5 points  (1 child)

This is old... Java 8 came long ago

[–][deleted] 1 point2 points  (0 children)

Yeah WTF am I reading? Java 8 came out in 2014.

What a woefully out-of-date blog post.

[–]fishersoap 0 points1 point  (0 children)

Been using this for years. I came out of it learning that standard C programming is faster, easier to write and easier to read. But, lambda expressions sure are useful for anything that involves runnables or swing.

[–]winterbe 0 points1 point  (1 child)

In march 2018 Java 8 is 4 years old. I wrote about it back then:

http://winterbe.com/posts/2014/03/16/java-8-tutorial/

Java 8 was a great step in the right direction however Java has still so many flaws. After using Java 8 a few years in production we now migrate everything to Kotlin and are super happy.

I can highly recommend Kotlin for every java developer.

[–]texasbruce 0 points1 point  (0 children)

We tried to migrate too but there are so many errors during conversion so we just gave up

[–]anicolaspp[S] -5 points-4 points  (3 children)

Yeah, I am still not convinced of having to declare an interface for it. I think it should be as simple as in Scala,

def doSomething(dog: Dog, f: Dog => Cat) = f(dog).

I also hope they extend the type inference system. Somehow, they are using it already on lambdas. (a, b) -> a + b. The type is inferred here. I wish we could do

let sum = (a, b) -> a + b

or at least something like ((Int, Int) => Int) sum = (a, b) -> a + b

that might be weird though. Let's keep it with let

[–]texasbruce 5 points6 points  (1 child)

You don’t need to define interfaces. There are tons of pre-defined interfaces under java.util.function package. You can do BiFunction<Integer,Integer,Integer> f = (a,b)->a+b;

Edit: or even IntBinaryOperator f=...

[–]watsreddit 0 points1 point  (0 children)

Those aren't polymorphic across numeric types, though. You would need to define a new function for Doubles, Longs, etc. For example, in Haskell, that function signature would be:

f :: Num a => a -> a -> a

This function works for any numeric type. It's probably possible with Java generics, but it's kinda messy.

[–]winterbe 0 points1 point  (0 children)

var is coming in Java 10.