Sunday, December 23, 2007

Java closures one more time

There is a heating debate on proposed language extensions, but the most debated is closures of course. Most people agree that the idea is great, but they cannot agree on the proposed implementations. I think the question is more conceptional. Java is not designed to be a functional language, so I doubt that these constructs can seamlessly be integrated into the language. So first we should discuss the benefits of this extension and if the benefits are much bigger than the drawbacks (increased complexity, more possibilities for code obfuscation and subtle mistakes) then we can talk about the implementation details. And if there are more drawbacks, we should throw the idea away and use a functional programming language (like Scala) for the appropriate tasks.
Personally, I do not think that Java has to follow the same path as C++. Using multiple languages on the same platform (JVM) is much more painless today as it has been in the past. Just think about the multi-language IDEs like Eclipse or NetBeans.

Saturday, December 22, 2007

Equinox with Spring-DM

I've just tried to deploy an Equinox framework with Spring-DM first time. I thought it will be much more difficult (Spring-DM is only RC1), but in reality it is very easy. First I set up a basic Equinox. Then I copied the JARs belonging to the Spring-DM into the plugins/ directory and created a config.ini that contains the following:

eclipse.ignoreApp=true
eclipse.consoleLog=true
osgi.clean=true
osgi.console=
osgi.bundles=org.eclipse.equinox.common@2:start,\
org.eclipse.equinox.registry_3.4.0.v20071203.jar@3:start,\
org.eclipse.osgi.services_3.1.200.v20071203.jar@3:start,\
org.eclipse.equinox.log_1.1.0.v20071203.jar@3:start,\
org.eclipse.osgi.util_3.1.200.v20071203.jar@3:start,\
jcl104-over-slf4j-1.4.3.jar@start,\
slf4j-simple-1.4.3.jar@start,\
slf4j-api-1.4.3.jar@start,\
aopalliance.osgi-1.0-SNAPSHOT.jar@start,\
cglib-nodep.osgi-2.1.3-SNAPSHOT.jar@start,\
spring-aop-2.5.jar:start,\
spring-beans-2.5.jar:start,\
spring-context-2.5.jar:start,\
spring-core-2.5.jar:start,\
spring-osgi-io-1.0-rc1.jar:start,\
spring-osgi-core-1.0-rc1.jar:start,\
spring-osgi-extender-1.0-rc1.jar:start

and voilĂ !

Saturday, December 15, 2007

JavaPolis - CBD

Component-Based Software Development is going to mainstream, finally. This is my conclusion based on my experiences from JavaPolis. I've seen good presentations from Bob Lee (author of Guice) and Peter Kriens who talked about OSGi. Moreover, Spring, EJB3 and component-based web development were mentioned in many presentations.

JavaPolis - closures

In the second conference day, Josh Bloch talked about closures. He provided an overview about the BGGA specification then he talked about his opinion. He basically thinks the same as me. Closures are nice (I really love declarative constructs!), if they are integrated seamlessly to the language, but the changes proposed by this spec are too intrusive. The most important concept behind the Java language is readability and closures will have a negative impact on it if they will be implemented this way.
He also talked about his proposal. It is more lightweight compared to BGGA, but far from seamless as it breaks the existing rules of the language (e.g. allows writing code blocks without enclosing methods - OK, I know, it is only a syntactic sugar).

Monday, December 3, 2007

Use the right level of abstraction

We are humans (most of us, I think), so we have our limits. To deal with them, we created a world of abstractions. Abstractions are so important we cannot live without them. We use them in our daily routine, they help us communicate things effectively or to do a wide variety of things.
However, humans make mistakes. Every time. Not using abstractions to solve or to communicate complex things is one of them, but a more severe mistake is to mix concepts from different levels of abstraction.
In my work, I am often facing this kind of problems. People describe a conceptual architecture and use technology-specific terms like web services, JavaEE, AJAX, for example. It is not only disturbing, it takes precious time and effort to clarify our concepts unless they lead to wrong architectural and business decisions.
Abstractions are our friends. Use them appropriately.