JavaOne 2008 - Summary & Reflection

1 day of CommunityOne and 4 days of JavaOne went by in a flash. I’ve been to a lot of great, a couple of not-so-great and some really bad sessions.

To avoid information overload on semi-interesting topics I really tried to only go to sessions about topics I’m really interested in. For this JavaOne these where (in no particular order):

  • alternative languages on the virtual machine
  • methodologies
  • the future of Java / JEE
  • cool new stuff

I tried to avoid product pitches as much as possible! Some of my personal highlights:

  • the No Fluff Just Stuff session at the g2one party
  • Both Neal Ford presentations I’ve attended (JRuby vs. Groovy / Enterprise Debugging techniques)
  • the scripting bowl
  • Taming the Leopard with Java

I’m still processing everything I’ve seen, but so far I didn’t see to much I didn’t know about before; certainly nothing shocking. Here are some of my observations:

Java 7

Sun is adding more and more annotations, the Java 7 spec-leads feel it’s a safe way of extending the language; even though it decreases readability (well, that is MY opinion). They are even planning to extend the number of targets for annotations; in the future we will probably see annotations inside generic type definitions… auch!

I also sincerely doubt that we will see a useful implementation of closures in Java 7; the spec-leads don’t want to burn their hands on it; Gafter seems the only one who dares to risk his neck…

Alternative languages on the VM

Groovy gained a lot of traction the past years. Most mayor app-servers offer out of the box support and major speakers are promoting it (Neal Ford repeatedly called it JDK 2.0).
JRuby is looking better and better. It is now even possible to just drop your Rails app in Glassfish to make it run. I do however feel that some users should stand-up and really demonstrate the virtues of Ruby on the VM to get peoples’ attention. The Jython presentation(s) where horrible; I think they did more harm to the language than good. I saw some great demonstrations of scala; but popularity seems to be at an alltime low.

As I said I’m still processing al the information and probably blog about various nice details and insights. Now I’m heading towards a restaurant and some beers!

Javaone 2008 - Warming up

Yesterday I (with two of my collegueas) travelled to San Francisco to attend JavaOne 2008 and the Community one sessions which start on May 5th. The interesting conversations began during the flight; we we’re located just in front of the David Booth (JetBrains Executive Manager) and had a nice little chat about what features we would pay for in IDE software.

After arriving we just walked through San Francisco and had some beers, good Italian Food en Coffee. The weather is just fine!

Today I’ll probably walk arround to see the Fishmens’ Wharf, Golden Gate and various other touristic attractions.

I’m uploading foto’s to my flickr account; you can browse my JavaOne related pictures here.

university_sessions_pictureIt has been a bit silent on my blog lately. This can be accounted to several reasons including some very busy projects at work and family business. I did write an article (in Dutch) for the Finalist blog about Fluent Interfaces though.

But recently I got some great work-related news which I just have to share: I get to go to JavaOne in San Francisco!

I went over the schedule and created a preliminary schedule (which proved to be quite hard with so much to choose from) of the sessions I’d like to visit. As you can see; I’ll be on a tight schedule!

Time Session ID/Title Speaker(s)
Tuesday , May 06
8:30 AM - 10:30 AM Sun General Session
Java + YOU

 
11:30 AM - 8:00 PM Tuesday Pavilion Hours: 11:30 a.m. - 8:00 p.m.  
11:50 AM - 12:10 PM Break between sessions  
11:50 AM - 11:50 AM Lunch Served from 11:50 a.m. to 2:00 p.m.  
12:10 PM - 1:10 PM TS-6623
More “Effective Java”
Joshua Bloch
1:30 PM - 3:00 PM Sun General Session
Java-Centricity: Leveraging Java Technology at the hub of your Digital Life

 
3:20 PM - 4:20 PM TS-5581
Upcoming Java™ Programming-Language Changes
Alex Buckley; Michael Ernst; Neal Gafter
4:20 PM - 4:40 PM Break between sessions  
4:40 PM - 5:40 PM TS-5030
Building Secure Mashups with OpenAjax
Jon Ferraiolo
5:40 PM - 6:00 PM Break between sessions  
6:00 PM - 7:00 PM TS-5764
Grails in Depth
Guillaume Laforge; Graeme Rocher
7:00 PM - 7:30 PM Evening Break  
7:30 PM - 8:20 PM BOF-5031
Upcoming Java™ Programming Language Features
Alex Buckley; Maurizio Cimadomore; Jonathan Gibbons
8:30 PM - 9:20 PM BOF-5111
Scripting in GlassFish™ Project
Arun Gupta; Vivek Pandey
9:30 PM - 10:20 PM BOF-5205
All About the Sun Certified Enterprise Architect (SCEA) Exam
Mark Cade; Humphrey Sheil
Wednesday, May 07
8:30 AM - 9:15 AM Oracle General Session
Enterprise Application Platform

 
9:30 AM - 10:30 AM PAN-5435
The Script Bowl: A Rapid-Fire Comparison of Scripting Languages
Guillaume Laforge; Charles Nutter; Jorge Ortiz; Raghavan Srinivas; Frank Wierzbicki
10:30 AM - 10:50 AM Break between sessions  
10:50 AM - 11:50 AM TS-5286
Introduction to Web Beans
Gavin King
11:30 AM - 4:30 PM Wednesday Pavilion Hours: 11:30 a.m. - 4:30 p.m.  
11:50 AM - 11:50 AM Lunch Served from 11:50 a.m. to 2:00 p.m.  
1:30 PM - 2:30 PM TS-5535
Tying Java™ Technologies Together the RESTful Way
Roderico Cruz; Peter Liu
2:30 PM - 2:50 PM Break between sessions  
2:50 PM - 3:50 PM TS-7064
Future Challenges for Open Source and Java™ Technology
Patrick Finch; Simon Phipps
3:50 PM - 4:10 PM Break between sessions  
5:10 PM - 6:30 PM Evening Break  
5:30 PM - 6:15 PM AMD General Session
The Role of the Microprocessor in the Evolution of Java Technology
 
8:30 PM - 9:20 PM BOF-5102
Cooking Your Own Groovy Builder: A Step Forward into Domain-Specific Languages
Andres Almiray; Ixchel Ruiz
Thursday , May 08
8:30 AM - 9:15 AM Intel General Session
Innovations through Software

 
9:30 AM - 10:30 AM TS-5686
New I/O APIs for the Java™ Platform
Alan Bateman
10:30 AM - 10:50 AM Break between sessions  
10:50 AM - 11:50 AM TS-5415
Java™ Servlet 3.0 API: What’s New and Exciting
Rajiv Mordani; Sridatta Viswanath
11:30 AM - 4:30 PM Thurdsay Pavilion Hours: 11:30 a.m. - 4:30 p.m.  
11:50 AM - 11:50 AM Lunch Served from 11:50 a.m. to 2:00 p.m.  
1:30 PM - 2:30 PM TS-5165
Programming with Functional Objects in Scala
Martin Odersky
2:30 PM - 2:50 PM Break between sessions  
2:50 PM - 3:50 PM TS-6457
Choosing Your Java™ Technology-Based Web Framework: A Comparison
Richard Pack; Stacey Schneider
3:50 PM - 4:10 PM Break between sessions  
4:10 PM - 5:10 PM TS-5596
Pimp My Build: 10 Ways to Make Your Build Rock

Conor MacNeill; Matt Quail
5:10 PM - 6:30 PM Evening Break  
5:30 PM - 6:15 PM Motorola General Session
Dial in, Drive Deep: Using Motorola’s Platforms to Reach Consumer and Enterprise Markets
 
6:30 PM - 7:20 PM BOF-6362
LinkedIn: A Professional Social Network Built with Java™ Technologies and Agile Practices
Nick Dellamaggiore; Eishay Smith
8:30 PM - 9:20 PM BOF-5998
Meet the Java™ Posse
Tor Norbye; Dick Wall
Friday , May 09
8:30 AM - 10:30 AM Sun General Session
Extreme Innovation
 
10:50 AM - 11:50 AM TS-6391
Using Java™ Technology at the World’s Largest Web Site
Joshua Blatt; Dean Yu
11:50 AM - 12:10 PM Break between sessions  
11:50 AM - 11:50 AM Lunch Served from 11:50 a.m. to 2:00 p.m.  
12:10 PM - 1:10 PM TS-6658
GlassFish™ Project Web Services Stack “Metro”: Easy to Use, Robust, and High-Performance
Jitendra Kotamraju; Marek Potociar
1:10 PM - 1:30 PM Break between sessions  
1:30 PM - 2:30 PM TS-4883
Advanced Java™ NIO Technology-Based Applications Using the Grizzly Framework
Jean-François Arcand; Oleksiy Stashok
2:30 PM - 2:50 PM Break between sessions  
2:50 PM - 3:50 PM TS-5358
Detecting and Defending Against Security Vulnerabilities for Web 2.0 Applications
Barry AuYeung; Ray Lai
3:50 PM - 4:10 PM Break between sessions  
4:10 PM - 5:10 PM TS-5349
So Many Faces: Web 2.0 XD Experience with JavaServer™ Faces and JavaFX™ Technology, Flex, and Windows Presentation Foundation
Ray Lai; George Mount

Maaike

I’ve been a bit silent on my blog lately. This is primarily caused by the birth of my second child Maaike. She is everything we could have hoped for!

What are you looking at?

I’m mostly running around with diapers, towels and video/photo camera’s if I’m not entertaining visitors or my son Sjoerd or posting to the family blog!

I was experimenting with transactions in Rails/ActiveRecord to see what they can and what they can't do. At first it seemed I couldn't get transactions to work at all. I made sure I was using the InnoDB storage engine. I rechecked my code. But the test kept failing.

This, by the way, is the test:

RUBY:
  1. require File.dirname(__FILE__) + '/../test_helper'
  2.  
  3. class BlogTest <ActiveSupport::TestCase
  4.  
  5.   def test_transaction_rollback
  6.     b = Blog.find(2);
  7.     assert_equal(b.title, "Title 2")
  8.    
  9.     assert_raise RuntimeError do
  10.       Blog.transaction do
  11.         b.title = "changed title"
  12.         b.save
  13.         raise "forced error" # force exception
  14.       end
  15.     end
  16.     b.reload # get the current state from the database
  17.  
  18.     assert_equal(b.title, "Title 2")
  19.   end
  20. end

Luckily a colleague pointed out that it was probably related to Rails' limited support for nested transactions; tests run within a transaction for performance reasons... which makes it impossible to roll back a transaction within a test.

Consider the following code:

RUBY:
  1. Account.transaction do
  2.   User.transaction do
  3.     # do some stuff
  4.   end
  5.  
  6.   # the previous transaction has already been committed, if we
  7.   # raise an exception now it can not be rolled back
  8.   raise
  9. end

The inner transaction won't be rolled back if the outer transaction fails after it's execution!

Googling around I found a simple fix for my test. Turn off the transactional behavior of the fixtures in the test:

RUBY:
  1. class BlogTest <ActiveSupport::TestCase
  2.   self.use_transactional_fixtures = false
  3.   ...
  4. end

Which works, but will slow down the execution of all tests. And it actually doesn't really solve the problem, it is a work-around.

I decided to see why nested transactions where such a big issue, and how it could be solved and found the ActiveRecord NestedTransactions (ARNE) pluging. ARNE is a plugin which makes ActiveRecord use SAVEPOINTS to achieve nested transactions functionality.

Savepoints save the state within a transaction to provide the ability to jump back to this state when something goes wrong later on. In SQL it looks something like this:

SQL:
  1. BEGIN; # start transaction
  2. SAVEPOINT my_first_savepoint # capture the current state
  3.  
  4. # do some work here
  5.  
  6. ROLLBACK TO SAVEPOINT my_first_savepoint  # optionally roll back to the specified state.
  7. RELEASE SAVEPOINT my_first_savepoint # clean up
  8. END; # end the transaction

The ARNE plugin wraps transaction blocks in savepoints to provide nesting functionality and actually works beautifully; my test succeeded. I did however find a small bug for which I've submitted a patch. The name of a safepoint must be unique for nesting to work without problems. If a name is used twice the initial savepoint is overwritten. Since the name was originally generated using a random generator this was in no way guaranteed:

RUBY:
  1. # method to generate savepoint name
  2. def generate_savepoint_name
  3.   # name must start with letters
  4.   "SP#{MD5.md5(rand.to_s)}"
  5. end

A better solution would (IMHO) be to use a UUID generator:

RUBY:
  1. # method to generate savepoint name
  2. def generate_savepoint_name
  3.   # name must start with letters
  4.   "SP#{UUID.random_create.to_s.gsub('-','_')}"
  5. end

I used the UUID generator from the uuidtools Gem. Note the random_create (a random generator is used to seeded the UUID algoritm) this guarantees that the above will also work when there is no standard MAC address (I heard about VPS solutions with this problem).

I learned a lot by looking at the way transaction handling is implemented in ActiveRecord. The code is clean, compact and readable. It made me like Ruby even more; although some people will probably say (and I tend to agree) that nesting should have been part of ActiveRecord all along.

Did you pass math

Some people complained about the fact that they had to register to add comments on this blog. Requiring people to login was the easiest way to get rid of spam after problems I had with SpamKarma.

While waiting for eclipse/subversion to finish its' tasks I decided to install Did You Pass Math? (DYPM). DYPM asks the person making the comment to answer a simple math question; you've seen it on other blogs.

So... let's see if it works for me!

amsterdam.rb

logo123Januari 28 will be the day of the first gathering of the Amsterdam's Ruby User Group. I'd like to be there but due to the fact that at that time my wife will be over 40 weeks pregnant... I just wont...

Still, I think it's a great idea and will certainly be joining future gatherings! For those of you without pregnant wives, come and talk Ruby at De bekeerde suster near the Nieuwmarkt in Amsterdam (Duh!!) arround 20:00.

A couple of weeks ago a I read about the free online Ruby course by Satish Talim. The course is aimed at people who want to start learning Ruby. I've probably passed the 'starting stage' a while ago, but was intrigued and registerd (as did over 2000 enthousiasts from all over the globe).

At the beginning of this week the course started. The training system is based on moodle; a free, open source course management system for online learning. If you are used to fancy looking websites like Javablackbelt the format feels a bit harsh; but it offers everything needed (forums, pols, wiki, exams, rating systems, schedules etc.).

I made this weeks' exam before I actually followed the course, and answered all questions correctly (as I hoped).

Afterwards I skipped through the training materials. They contain some Google ads (which is understandable), and most of the images are of horrible quality but does however cover the basics fairly well. Mr. Talim also offers audio versions; but I prefer to read.

I think this is a great resource for people who don't have access to all resources I (or the company I work for) have at my disposal and applaude the initiative! Kudos to mr. Talim!

I attended Joshua Blochs' presentation on closures at JavaPolis last week (watch the video here). This slides about return not return from what you'd expect kept me wondering: how do other languages solve this 'problem'.

The example from Bloch, taken from Slide 38 of Blochs' closures controversy presentation:

JAVA:
  1. static <E> Boolean contains(Iterable<E> seq, {E => Boolean} p) {
  2.     for (E e : seq)
  3.         if (p.invoke(e))
  4.             return true;
  5.     return false;
  6. }
  7.  
  8. static Boolean test() {
  9.     List<Character> list = Arrays.asList(
  10.             'h', 'e', 'l', 'l', 'o');
  11.     return contains(list, { Character c => return c> 'j'; } );
  12. }

The point Josh tried to make was that due to this 'copy and paste' error the contains method would return on the first invocation of the passed block. Auch....

It asked around at Morning coffee but nobody really knew what this would actually do in Ruby.

So, let's just try it. In Ruby this might look a bit like this:

RUBY:
  1. def contains(enumerable, &test)
  2.   enumerable.each do |e|
  3.     return true if test.call(e)
  4.   end
  5.   false
  6. end
  7.  
  8. puts contains(['h','e','l','l','o']){|v| return v == "z"}

In the Ruby a return statement in a block returns from the enclosing function as well. However, if the return statement is part of a closure passed to a function returning is not allowed:

closure_return.rb:9: unexpected return (LocalJumpError)
from closure_return.rb:4:in `call'
from closure_return.rb:4:in `contains'
from closure_return.rb:3:in `each'
from closure_return.rb:3:in `contains'
from closure_return.rb:9

Throwing an error might be considered a better solution. The problem in this case is the fact that the error is thrown at the first invocation of the block; code before the invocation of the block will be called... but code after the invocation won't. Of coarse this is 'just' a matter of taking this into account:

RUBY:
  1. def contains(enumerable, &test)
  2.   begin
  3.     puts "a"
  4.     enumerable.each do |e|
  5.       return true if test.call(e)
  6.     end
  7.   rescue
  8.     puts "Error in passed test-block: #{$!}"
  9.   ensure   
  10.     puts "b"
  11.   end 
  12.    
  13.   false
  14. end
  15.  
  16. puts contains(['h','e','l','l','o']){|v| return v == "z"}

In this case the ensure statement will always be called. I'm not really in favor of adding closures to Java; just go to Ruby/Groovy/Scala if you want them). I do however think that the 'return' argument Josh made isn't to strong; a solution similar to the way it works in Ruby could probably be found for Java.

Recently the Groovy team introduced a new operator to the Groovy language. It is called the Elvis operator. There is one thing I particularly like about this operator. It's name.

To bad the Elvis operator is only a shortening of Java's ternary operator, written like ?:. One use-case for the operator is returning a 'sensible default' value if an expression resolves to false or null. A simple example might look like this:

GROOVY:
  1. groovy:000> name = null
  2. groovy:000> displayName = name ?: "anonymous"
  3. ===> anonymous

I had a good laugh about it with some people at JavaPolis, and forgot about it. Until I noticed something while reading the expressions chapter in the PickAxe (I'm trying to boost my Ruby knowledge).

In Ruby anything which isn't nil is true in an expression. Due to this behavior the result of a shortcut expression doesn't have to be a boolean but is actually the value which evaluated to true (in Groovy the result is a boolean). This means Ruby implicitly has a 'Elvis' operator.

RUBY:
  1. irb(main):069:0> name = nil
  2. irb(main):070:0> displayName = name || "anonymous"
  3. => "anonymous"

Even better, Ruby allows you to use the shortcut OR in combination with the assignment operator:

RUBY:
  1. irb(main):072:0> name = nil
  2. irb(main):073:0> name ||= "anonymous"
  3. => "anonymous"
  4. irb(main):074:0> name = "peter"
  5. irb(main):075:0> name ||= "anonymous"
  6. => "peter"

Funny to see how a slightly different behavior of something like to or operator makes it even more useful!




About

Welcome to the weblog of Peter Maas. Here you'll find various posts related to stuff I like (like my kids and espresso) and stuff I do (like developing software).

JavaOne 2008 Pictures


Okke en Rudie alcatraz Scribbled Sun Logo Rudie Tim Bray introducing the (J)Ruby panel javaone2008 keynote Cable Car line Greenland Joshua Bloch at JavaOne2008 Java + You on a cab Moscone Center - JavaOne Community One Keynote smashmouth Golden Gate sea_lion Stretched Limo pub Hotel room nearby hotel golden_gate_warning_sign
View more photos >

Categories



Meld u aan voor PayPal en begin direct met het accepteren van creditcardbetalingen.