Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

While lambdas and streams (along with default methods, or traits) are certainly the most important features of Java 8, I'm particularly interested in the pluggable type systems[1].

These are pluggable, orthogonal (intersection?) types, that can even be introduced or inferred for code that has already been compiled without them. I'm not a type systems expert by any means, but I haven't seen anything like it in any other language, certainly not a mainstream one.

There are currently Java 8 type systems for nullability, immutability and more.

[1]: http://types.cs.washington.edu/checker-framework/



[deleted]


That was introduced back in Java 7.


try-with-resources actually came in with Java 7


Isn't that what the loan pattern does and is easily accomplished with lambdas? Doesn't seem like a special case that needs to be supported by changing the language.


You can not modified a variable declared in the outer scope inside a lambda.

int a = 0; list.forEach(element -> { a++; // no way ! });

That's why it's a lambda and not a closure BTW.


Can always make:

   final int[] a = {0};
   list.forEach(element -> { a[0]++; });


It's still a closure, just a closure with immutable capture, just like Python. Also like Python, you can get around it by boxing the variable you would like to modify (or using nonlocal in Python 3).

IMO the lack of exception transparency is going to be more of an issue with Java's lambdas.


For most of the used programming languages, a lambda captures values (like in Java or Python), and closure capture variables or scope (like in Scheme or Ruby), hence the name, a closure close (bind) the free variable of the closure to the ones of the lexical scope.

The lack of checked exception transparency is for me something that goes in the right direction. The hidden message is 'Use checked exception only for IOs and please don't create your own exceptions, use already existing ones !'


A lambda doesn't capture anything, it's just an anonymous function. A lambda can be a closure, but it doesn't have to be.

Closures come in two primary flavors, bind by value or bind by reference. Some languages implement only one of these, some implement both, some bind in completely different ways (e.g. lazy binding in Haskell).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: