Home > devoxx > JavaPolis 2007 – Day three

JavaPolis 2007 – Day three

First day of the conference today and we all gathered in the big room number 8 to see James Gosling. The session started with Stephan Janssen announcing some facts about JavaPolis 2007. It’s actually the first JavaPolis that is sold out and people from as far as Korea, New Zealand and Brazil came to attend. It was a short but concise talk for fifteen minutes.

Bruce Eckel followed and he opened the presentation with the notion of “Unconference”. The unconference idea is based on the concept of open spaces. Researches have shown that most people enjoy two things from the conferences. The BOFs (Bird Of Feathers sessions) and the “hallway talk”, i.e. when a session finishes and people meet in the hallway outside the rooms and have a chat. So the idea is simple. There is a white board in the ground floor with a grid on it. Horizontal row is the room number and vertical column is the time. Anyone who wants to have a chat about any idea (s)he has, can go there and put a not on the grid. If people are interested they meet and have a chat about the subject. There is also the “law of two feet” in this kind of talks. If you don’t like the talk you use your two feet and go to another conversation. This is not considered bad or rude since by going away you take with you the bad energy and feeling you radiate and you only leave there the people who really want to talk about the subject. If you want to be polite and stay you are actually pulling everyone else’s energy down, so it’s better to leave than to stay and say nothing. Brilliant idea.

After Eckel James Gosling started presenting his talk. By this time three huge rooms were full of people and the talks were projected to the other rooms as well. Gosling started with some Java statistics. There are more than 5 billion devices that support java (2.1 of them are mobile devices), there are more than 6 million Java developers and Java is behind some of the most impressive systems in the world, including the robots sent to Mars, the brazilian health system, ebay, CERN and so on. Even the Oyster card in London underground (and some overground) is a Java card (I didn’t know that) and the whole back end is written in Java. Gosling is currently involved in the JavaRTS, the real time specification for Java. He explained the myth behind the Java language; that it is slow. The truth is that in some benchmarks it’s faster than C++ (the performance varies between -2% and 4% faster) and it is highly optimized.He then went on about Java 6 which has several improvements over Java 5. There is a tremendous speed improvement on the server side but not so impressive on the client side. The reason is that speed on the client depends on how fast you draw the pixels on the screen. More slides followed about JSR248- MSA (Mobile Services Architecture), JavaFX, a few slides about Applets (he mentioned that Applets are a victim of several years of litigation as well as Windows 98).

Then it was the turn for Angela to show us a nice JavaFX demo and Simon Ritter a demo with two robots running SunSpot. Simon was moving forwards and backwards and the robots were doing the same.At the end it was time for the “Ask James” session, were everyone could ask questions to James Gosling. Briefly, the questions asked were the following:

  • Q: How does the JCP work?
  • A: JCP is independent organization. Better ask the JCP people.
  • Q: Where is Swing going?
  • A: It’s strong, he doesn’t see it vanishing.
  • Q: What about androind?
  • A: He doesn’t have enough information to comment on adroid yet. We need more data in order to have a clear idea about it.
  • Q: What about JavaFX on the web?
  • A: It is there in the form of Applets.
  • Q: Why there are so many web frameworks out there?
  • A: Because there are so many smart people out there. They think that each one of them can offer something unique. It would be nice to have less but again it’s good to innovate.
  • Q: Java 6 on the mac?
  • A: This is Steve Job’s job. Apple has become an iPod company, this is their focus. Better ask Apple this question.
  • Q: Any ideas about Java 8. 9 or 10?
  • A: No
  • Q: Why use JavaFX instead of Flex?
  • A: Because JavaFX is integrated with all existing Java code and libraries out there. There is better performance and also you have all the Java 2D libraries you need.
  • Q: Java on multicore & Moore’s law?
  • A: Moore’s law was originally written for transistors, not clock cycles. Java is doing quite well in the multicore and it’s mainly the games industry that drives the computing today.

Second talk I attended was Google’s Guice by Bob Lee. Guice is a framework that helps you do dependency injection using annotations. Annotations are easier to maintain and understand than XML. It is using @Inject to do the injection (thing about Inject as the new “new”. Instead of calling new you have the type injected). Bob also mentioned a few things about injections:

  • It is preferable to use @Inject Foo foo instead of using injector.getInstance(Foo.class) since the latter is using a service locator to locate the class.
  • It is better to prefer constructor injection rather than method injection since the developer might forget to call the method while (s)he will never forget to call the constructor.
  • You should use method injection in parent classes.
  • You can inject static methods.
  • Guice can invoke private methods. The @Inject annotation tells Guice that it’s ok to override accessibility restrictions.
  • There is a Guice plugin for Eclipse.
  • You can hide packages with package-private annotations, @Inject @MyPackage MyClass
  • It’s good to avoid binding using toInstance()because
    • It forces instantiation inside of modules.
    • Precludes construction injection.
    • Inhibits scoping.
  • Use the @Singleton annotation.
  • Use eager singleton for startup logic.

Handling exceptions with Guice is pretty simple, all you need to do is to pass the exception to a Binder.addError() call:

try {...}catch(Exception e) {binder.addError(e);}

Another advice is to prefer the creation of a Provider and use the getProvider() method call instead of the getInstance() and also to inject the provider instead of the injector since if we inject a provider Guice can see what’s injected and if a dependency is missing. Also it’s better to use Binder.getProvider() instead of injector.getProvider() since with the former Guice fails in startup if something is missing.What happens in cases when you want to inject something manually but you have already provided the @Inject annotation? Guice has the solution by providing the @New annotation which lets the developer to manually create something. In a few words Guice will treat it exactly as we were using the new keyword.A few more tipes I managed to write down:

  • Do not use Guice in unit testing, prefer mock objects instead.
  • There is a Guice Enterprise Edition (GEE) of guice
  • Prefer injection to JNDI lookup since with injection we have information about the type of the object we are injecting.
  • When using Guice avoid HTTPSession scope since there are concurrency and fail-over issues.
  • Let Guice convert values since it also does up front checking of the type of the value.

Next session I attended was Filthy Makeover by Chet Haase (co-author of the book “Filthy Rich Clients”). Chet’s talk was about how to create compelling and dynamic client applications using Swing. He went through explaining some very nice tricks you can do by using Swing. He talked about Gradients (an interpolation between two colours), composites, animations and a few other techniques and showed us an e-mail client that was using all the techniques to make it richer and more user-friendly.Some tips about the cool features he used

  • Gradients
    • If you want to have lighting effects it’s a good idea to use radial gradient.
    • Cache gradient in images.
    • Use stretched images.
    • Use cyclic gradients.
  • Composites
    • Use translucency.
    • Graphics2D is the class that understands composites.
    • You can have nice effects if you increment/decrement the alpha value of an image.
  • GlassPane
    • It’s a component that sits on top of everything else in a JFrame.
    • Allows painting over the entire window area.
    • It’s not visible by default.
  • Blur
    • Use ConvolveOp to do blurring.
    • Perform a convolution from source to destination.
    • A box blur is a blur that is done on a kernel of equal pixel weight.
    • A Gaussian blur is one that is done in normal distribution of weight.
    • Use upscale for cheap blur effects.
    • It might be cheaper to use smaller/separate filters that one larger one.
  • Shadows
    • They simulate lighting.
    • They make GUI more realistic.
    • Realistic shadows require blur.
    • Use SwingLabs classes DropShadowBorder, DropShadowPanel, ShadowFactory.
  • Animation
    • It’s all about varying properties over time.
    • Use the Timing framework
      • It has a simple declaration model.
      • It’s an easy specification of timing behaviours.
      • To do fade out effects simply decrement the alpha value of an image. Start from alpha 1 and go to alpha 0 while repainting.
        (at this point Chet showed a very cool demo of an image with some moving cogs painting slowly when an exception occurs in the application)
  • Animated transitions
    • They can be used in order to show the user how (s)he got from one part of the application to the other.
    • Show short animations on when changing components.
      • Use fade in/out
      • Move/resize
    • Use the Animated Transitions framework.
      • It simplifies transition.
      • It figures out the component deltas and runs the default animation effects (fades, moves, resizes).

Next talk was IRIS – a RIA Swing Applet by Richard Bair. The talk was about how to mix applets and HTML and the update “N” which provides several new features regarding applets (and not only applets). The biggest are the consistent cross browser plug in and the fact there there are no more browser lockup or crashes. Prior to update “N” a Java applet was running under the same process as the browser but now it is running on its own process. Furthermore the Java 6 plugin is completely rewritten in order to provide the new features.

A few more features that will be coming soon are JNLP support, client side pack200 (reduces jar size considerably. At first the plug in asks for a pack200 file. If it is not found then it tries to load up the normal jar file) and auto-detect & install Java plug in. It seems there will be a revival regarding applets since they provide advanced features that other client side technologies do not like security, multi-threading, full screen mode, 3D graphics and so on.

Then the IRIS applet itself was demonstrated which connects to flickr and loads up photos. The applet communicates with javaScript. JavaScript calls the applet, the applet talks to flickr and then calls back the JavaScript to update the HTML code. The flickr photos are displayed in a 3d view using JOGL.

Again some tips when using applets (with or without JavaScript)

  • Make calls to JavaScript in a separate thread.
  • You can treat element like any other element in the DOM tree using JavaScript.
  • You cannot set its z-order.
  • Use invokeLater() when doing drag and drop in order to avoid deadlocks.
  • Use DataFlavor to determine the data type of the dnd object.
  • You will probably need to create a custom dnd component

Next presentation was Practical JRuby on Rails by Ola Bini and Charles Oliver Nutter. The went through a demo of using the Ruby language and explained a few facts about Ruby. They explained that Ruby is good because it’s having blocks, modules and meta-programming.

Blocks are blocks of code that can be attached to any method invocations. By using blocks you avoid iteration since there is no need for repetition.

Modules provide name spaces and allows behaviour to be mixed in. There are several modules such as the Enumerable module, the Comparable module etc. It seems to me that modules in Ruby are used like classes in Java, you define them and then you use them (like you import Java classes).

Meta programming allows the use of dynamic classes, for example we can tell a string during run time to define a new method in itself (this sounds similar to cglib I guess).

Ruby is using a malleable syntax which means that there are several ways to do things and you can also override most operators.

Then they speakers showed us some slides about JRuby. JRuby is basically a Ruby for the JVM. It is based on the version 1.8.5 of Ruby and started in 2001. JRuby supports native threads, unicode, it has better performance than Ruby, uses the Java garbage collection and there are different compilation modes, interpreted and compiled.

Rails is an MVC web framework. It is an agile framework since you can be up and running from day zero, support REST services, “convention over configuration”, AJAX and Web 2.0 and has changed how people view web development. In a few words it uses the strengths of the Ruby language (code generation, build in testing, reasonable defaults etc).

A Rails web application can be deployed to any server that supports Java (it’s just a WAR file -using Goldspike- that you copy paste to the server). It can use any Java library and integrate with existing infrastructure (like EJB, JMS, legacy systems).

The presentation ended with a demo of a Rails application.

Last talk was about the Future of Computing with James Gosling, Neal Gafter, Joshua Bloch and Martin Ordesky. The session opened with a question of “what will be the computer in the future”. In a few words it would literally be everywhere, anything you see and does something will be a computer.

Question about where Java will be. Again, James Gosling said that it would be everywhere, any device (small or big) will have a JVM installed on it and be able to run a Java application.

Will there be any problems implementing software on computers with multi cores? Thinking with todays data there will be but the computing will evolve to overcome these problems.

How much future does the Java platform have? If the platform stagnates then we have no future. They will make sure that the platform will not stagnate.

How can we evolve the platform without breaking existing stuff? Good analysis, good design and good testing. It’s the cycle of birth-grow-death.

Is there a chance of making the current APIs optional? No. The APIs are there, but you can use them only if you want. There are people who think that if you are not in rt.jar then you don’t count, bu the fact that J2EE is not in the rt.jar is actually a victory.

What about the software development process? Now it’s more community based, do you see it changing in the future? It wouldn’t change in the future. Software developers are citizens of the world, they can work from where-ever they are for what-ever company they want. A doctor or a lawyer cannot do this. Also they cannot learn from the internet, developers can. The developers profession is not fractured by geography or national boundaries.

What kind of new problems computing will bring? It will be harder and harder to test application 100%.

What language features are missing in order to make programming easier? In their opinion mutability should be minimized as much as possible. Java is the first language that gave immutability to the masses. But a key point in order to have immutable objects is to have a garbage collector.

Advertisements
Categories: devoxx
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: