Adam Bien's Weblog   

Sunday Apr 06, 2008

Running Netbeans 6.1 on jdk 1.6.0_u10 beta (Consumer "JDK")

I just had some trouble with JAXB and had to upgrade the JDK (JAXB 2.1 comes with > JDK 1.6u4). I went a little bit further and installed the JDK 1.6.0_u10 beta, also known as the "consumer JRE / JDK". I just launched Netbeans 6.1 on it and: 

  1. Netbeans 6.1 launches in 5 seconds (with several Java EE 5 projects). It feels faster, than on jdk 1.6u4
  2.  It seems like the font rendering was improved  - it looks clearer.
  3. ...and JAXB 2.1 just works :-).
I will work with JDK 1.6.0u10 this week - let see how stable it really is.


[This entry is based on / extends my books: Enterprise Architekturen, Leitfaden fuer effiziente Software-Entwicklung and: Java EE 5 Architekturen, Patterns und Idiome]

 Subscribe in a reader

High Level thinking about the introduction of closures in Java

The term "closure" is defined as follows:

"In computer science, a closure is a function that is evaluated in an environment containing one or more bound variables. When called, the function can access these variables. The explicit use of closures is associated with functional programming and with languages such as ML and Lisp. Constructs such as objects in other languages can also be modeled with closures"

The first paragraph is a little bit too abstract, but it is getting better:

"A closure can be used to associate a function with a set of "private" variables, which persist over several invocations of the function. The scope of the variable encompasses only the closed-over function, so it cannot be accessed from other program code. However, the variable is of indefinite extent, so a value established in one invocation remains available in the next. As a consequence, closures can be used to hide state, and thus to implement object-oriented programming.

The concept of closures was developed in the 1960s and was first fully implemented as a language feature in the programming language Scheme. Since then, many languages have been designed to support closures."

[from wikipedia]

Now it is getting clear - closure is something like a "crippled" method, which you can pass around. However this method is special - and has the access to the invocation scope - so you could access the state of the object, from which it is invoked. A closure is somehow similar to a inner class - with hopefully more straight forward syntax. Some observations:

  1. Closures are used mostly in functional languages
  2. The concepts of closures is about 50 years old
  3. Closures are especially useful for API design

Java isn't a functional language and the closure debate arised just in the recent two years. I don't think, that it would be possible to refactor big portions of e.g. the Java-libraries before Java 7. So we would have to live with the mix - legacy java.util and java.lang libraries with probably new, more concise designed Java 7 libraries. Some closure examples from Neal Gafter's blog.

Using closures can be trivial - or really complex. As every technology, they have some sideeffects - which an average developer will have to learn. The question, that remains is: How much time is an average developer willing to invest, to understand closures deeply? I personally would like too play around with closures - and I'm willing to learn the sideeffects of whatever proposal as well. However closures are already available in Groovy, Scala, JRuby and JavaScript - so it is actually already possible (all these languages are able to run at the JVM).

I'm not sure, whether it is a really good idea to push Java in the functional direction - ono the other hand - with closures you can reduce a significant amount of code - which is always a good thing. What I observer too: many developers are getting really excited about closures - it is a really nice topic for getting warm in a meeting as well:-).


[This entry is based on / extends my books: Enterprise Architekturen, Leitfaden fuer effiziente Software-Entwicklung and: Java EE 5 Architekturen, Patterns und Idiome]

 Subscribe in a reader

About,RSS / Atom

About me: www.adam-bien.com
JavaONE 2008 Interview
My Recent Books
Adverts
Search
Links
greenfire.dev.java.net
...the last 150 posts
my.netbeans.org
Visitors
License