Friday, January 19, 2007

Video Interview at Javapolis

Ted Neward interviewed me at Javapolis last month, and the video has just been posted:

  1. Who's your friend? (frog on my shoulder)
  2. Who are you and what do you do?
  3. What are you presenting at Javapolis?
  4. Why are Closures for Java important?
  5. What are the differences between the two Closures proposals?
  6. What kinds of problems is your proposal trying to solve?
  7. Is Java becoming too complex?
  8. Did Generics add complexity to the Java language?
  9. Can OpenJDK lead to a fragmentation of the Java platform?
  10. How does it feel to have your code now splashed out in the open?
  11. What should I learn to be able to change the Java compiler?

You can jump to any section of the interview, or just skip the whole thing.

6 comments:

Carl Rosenberger said...

Thank you very much for your great engagement for closures, Neal! We would really love to see them in Java 7 because they allow a much more elegant syntax for Native Queries.

I wonder if there is a best place to vote for closures to be included in Java 7. I only found this old RFE in the bug database. Is this the best place to cast a vote or is there a more current RFE? I would like to try to ask the entire db4o community for help with a vote. Where should it be cast?

Neal Gafter said...

There isn't really a single place to vote for closures, or for one proposal versus another, but you can record your vote for (or against) closures here.

Marius said...

Here is something unrelated with this particular post, but related with closures.

Here is a dumb example:

<pre>
public class Test {

public static int doIt(int val){
if (val % 2 == 0){
return 0;
}

return 1;
}

public static int doItWithClosure(int val, {int=>int} block){
int val = block.invoke(val);
System.out.println(val);
return val;
}


/**
* @param args
*/
public static void main(String[] args) {

doItWithClosure(3, {int val =>
if (val % 2 == 0){
return 0;
}

return 1;

});
}
}

</pre>

The thing is that at the begining we have the body of a method that returns an int depending on some conditions. If we take the block that contains the return and puti it in a closure and we call doItWithClosure liek above, will the return from closure return in the caller of doItWithClosure (in this case main method), or will it return in doItWithClosure method and it will print out the value of val ?

I'm asking this, because based on the spec rationale:
"A return statement always returns from the nearest enclosing method or constructor. A closure may outlive the target of control transfers appearing within it."

so if a return from a closure return actually to the nearest enclosing context, then how the method that actually invokes a closure can benefit of the closure computation.

Neal Gafter said...

marius: in your example, the return statements appear within the definition of the main method, and not within any other method. Therefore they return from main. Since main returns void and your return statements attempt to return a value, this would be a compile-time error.

Neal Gafter said...

One more thing. To produce a result from a closure, you don't use the "return" syntax. Your example should be written this way:

doItWithClosure(3,
{int val => (val % 2 == 0) ? 0 : 1 });

Marius said...

Makes sense.

Thank you.