26 November 2010

Devoxx 2010

From 17th to 19th of November 2010 was the Devoxx in Antwerp. Here are some random notes about the sessions that I attended. I should have tweeted them right away, but I didn't, so a post will have to do.

Devoxx 2010 NotebookDay 1
At the beginning Stephan gave us a warm welcome. He was motivated as ever. :-) The following keynote on SE 7 by Mark Reinhold was nice but he was telling the same story what would be shipped in Java 7. I'm tired of hearing it. Cut the crap! Ship it! Just ship anything!

The first session was held by Heinz Kabutz about mad reflection. After years of reading his newsletters it was nice to see him in person. The title of his talk was very proper: madness! Thank you Heinz for this "mad" talk. It was very informative.

Joshua Bloch's performance talk was so full that the organisers closed the room 15 minutes before the session started. I did not make it in :-( So I had to change my plans and went for the "new stuff in Scala 2.8" presentation. Bill Venners gave many real code examples, but I didn't comprehend most of them. That's probably my fault. It's been some time since I had a look in their book. (@Devoxx Team: Maybe you could organise some kind of dynamic overflow room for sessions of well known speakers the next time, just to be safe?)

In the evening I wanted to attend the BOF about the state of Java SE 7. But the room was totally full and there was no fresh air. I started growing a headache and had to leave. Later that evening I did my first steps in Android development during the Visage BOF. Visage turned out to be cool stuff. Unfortunately the setup of the development environment took too much time. In the end Stephen Chin went through a working example in only a few minutes.

Day 2
The second day started with a presentation about the future of Java EE: "Bla bla cloud bla bla virtualisation bla bla service lookup bla bla more flexible bla bla specification bla bla". Hell this talk was boring! Fortunately the following talk by Kito Mann about GTD made it all up.

Later George Reese talked about how to operate at the cloud scale. His talk was a bit abstract, but contained nice slides. Just my style of presentation :-)

During lunch break I listened to a quickie by Costin Leau about @inject. He made it very fast paced. It was a good overview when one already knew dependency injection. I wish more presentations about technologies would be that compact. Well done!

Devoxx 2010 crowded main hall
After lunch Kirk Pepperdine showed how to extend visual VM. It seemed easy. It would be great to use it for a combined view of all our monitored applications. Maybe I will give it a try.

Then there was the JavaPosse. It was horribly boring. I've never listened to them before. It's just not my style of humour. So I left the room to hear a presentation about HBase at Facebook by Jonathan Gray, who gave insights into a very large system. Especially the questions (in fact the answers) revealed interesting details: Distribution using bit torrent and deploying to a cluster of self-made app servers which are all monitored with JMX. Cool, cool, cool.

William Pugh, the creator of Findbugs presented some valid points about defects, e.g. "finding defects in code is so easy". He told interesting war stories about bugs at Google making it a practical presentation.

I had not made it into Joshua Bloch's first talk but at least managed to get a decent seat for his puzzler talk. And I got the first puzzler right! Oops, I hadn't known that EnumMap's entrySet() is that weird. Again, I hadn't anticipated the regular expression backtracking, although the pattern had looked weird to me. No - 1:3 for the puzzler brothers. Finally I got one right, well, most people did. And I got the last one right, too. Only few people noticed the lowercase el. Final score 3:3!

In the evening I attended the NoSQL BOF, my first real BOF. Everybody was very friendly and it I enjoyed listening to real world users of NoSQL. But in my opinion the committers and heavy users were unfair complaining about JVM memory management problems. It's obvious that data stores need a lot of memory. Thank you guys for sharing some thoughts with me NoSQL newbie.

Day 3
The third day started with a discussion panel about the future of Java. It was quite informative. The Paris JUG leader said that Java user groups are in fact JVM user groups That is true and it indicates the change in the Java ecosystem. Another interesting bit was the notion of comprehending <? super T> being a dividing line between journeymen and experts. This reminds me of Joel Spolsky's old post about the "pointers business". Are bounded wildcards Java's "pointers"?

Then we had a very fast paced vanilla Adam Bien. He demoed all the good things one is able to do with Glassfish in J2EE. He did some "no risk no fun"-styled live coding with a cinematic version of the Java pet store including aliens and predators. He had almost no slides. It was hilarious :-).

Last but not least my favourite session were the "boilerplate busters", i.e. project Lombok. Thank you guys for your work to get rid of ugly code. I will definitely start using Lombok at once. And thank you for making it such an entertaining presentation. You guys are great! It's a pity that there are no pictures of this talk.

Conclusion
Devoxx 2010 was a great conference. 12 out of 17 talks were excellent and I managed to loot some t-shirts from the exhibition. It was just a bit too full, but Stephan promised that they would close registration sooner next year. So I will definitely visit Devoxx again in 2011.

Disclaimer
This post kinda sucks because I wrote it on my Android on the plane during the flight home, and on the train, and on the subway ...

23 October 2010

Concepts of Functional Programming

Last week I had the pleasure to give a presentation at Javaabend in Vienna. Javaabend (German for Java evening) is a local Java user group event organised by openForce Information Technology at irregular intervals.

LambdaA Little Rant
This presentation has a long history, so I will start with a little rant. Last year when I started playing around with Scala, we (read some enthusiastic employees) formed an informal study group to have a look at functional languages and Scala in particular. In the beginning we made good progress and had quite some fun and met biweekly. Unfortunately the organisation had a strange attitude to training (as well as to public relations) and we were disbanded. Being stubborn as I am, I managed to establish a budget from "another source" after some time and started preparing this presentation for the monthly "Developer Round Table". The presentation was postponed several times and in the end I left the company for good.

Scope of Presentation
Now let's come back to the presentation. Talking about the principles of functional programming is a bit off-topic for the Code Cop and it's just scratching the surface of the core principles: purity, higher order functions, closures, currying, continuations and (well not really) monads. I'm no expert on functional programming, so feel free to comment corrections or clarifications. Especially the concept of monads is a bit mysterious.

Slides
Download the Concepts of Functional Programming slides. As usual the slides are not very useful without my explanations because they entirely consist of single words and/or images. This is my take on the current presentation style. I received some good feedback on the style and especially the images. One attendee even told me that the images were "too" good for him, he was distracted by them. (Thank you Flickr community for all these wonderful CC licensed images.)

MonadsDiscussion
After the presentation there was an interesting discussion on the advantages of functional programming over the imperative style, e.g. Java.
  • Is it easier to get things done with many lines of simple, imperative code, compared to one line of functional code (that most definitely does not look simple when you are new to the area)?
  • Are the functional paradigms more difficult to comprehend? Is this the reason that functional programming isn't used as widespread as the imperative one? Would the average developer produce bad quality code when using functional languages?
These are difficult questions, only time will tell.

ResourcesAcknowledgement
Researching the core principles of functional programming was part of a System One Research Day.

17 October 2010

Android Browser Bookmarks

In my previous post I already mentioned my Android phone. Soon after I got it, I wanted to import my bookmarks from my desktop PC to its standard browser. So being green I copied my favourites to the sdcard and tried to open them. Well it didn't work.

Google AndroidWorking Around
If I lived in "Google-land", I could use Google Bookmarks. But I don't and had to look for alternatives. After some searching I found a possible way to import bookmarks:
  1. Upload your single html file of exported bookmarks to a document on Google Docs.
  2. In your browser navigate to said page.
  3. Manually click on each link and save as bookmark.
Noooo, you must be kidding me. This is hideous. Then I found a nice instruction how to
import the bookmarks directly into the browser's database. That would be cool. But I'm not bold enough to root my new phone and "play with that, probably break it a bit - and then cry about it later." (Ward from androidcommunity.com)

My Solution
On several places I read hints that some Android apps were able to import bookmarks, but I couldn't find any. Instead I found Matthieu Guenebaud's Bookmarks Manager. It's able to backup and restore the browser bookmarks and uses a plain zip file to store them.
Viewing .ZIP: Bookmarks_2010-09-10_14-11-24.zip

Length  Method Size  Ratio    Date    Time   Name
------  ------ ----- -----    ----    ----   ----
  2273 DeflatN   710 68.8% 09.10.2010  2:11p bookmarks.xml
   526 DeflatN   531  0.0% 09.10.2010  2:11p 23.png
   764 DeflatN   769  0.0% 09.10.2010  2:11p 24.png
   326 DeflatN   331  0.0% 09.10.2010  2:11p 51.png
   684 DeflatN   689  0.0% 09.10.2010  2:11p 57.png
   239 DeflatN   238  0.5% 09.10.2010  2:11p 69.png
   541 DeflatN   546  0.0% 09.10.2010  2:11p 90.png
  1266 DeflatN  1271  0.0% 09.10.2010  2:11p 198.png
   490 DeflatN   495  0.0% 09.10.2010  2:11p 164.png
   304 DeflatN   309  0.0% 09.10.2010  2:11p 124.png
   408 DeflatN   413  0.0% 09.10.2010  2:11p 229.png
------         ----- -----                   ----
  7821          6302 19.5%                     11
The file bookmarks.xml has a simple XML structure of <bookmark>s inside a <bookmarks> element. Yes, that's something I can use.
  1. Backup the bookmarks, even if empty, to get an initial file.
  2. Unpack the archive.
  3. Insert bookmarks into the existing XML structure.
  4. Repack the archive.
  5. Restore from the modified zip file.
  6. Enjoy your new wealth of bookmarks.
In case you don't feel like editing the bookmarks.xml by hand, here is some Scala code.:
val bookmarkXml = scala.xml.XML.loadFile(targetFolder + "/bookmarks.xml")
val lastOrder = Integer.parseInt((bookmarkXml \\ "order").last.text)
val oldNodes = bookmarkXml \\ "bookmark"
val newNodes = to_xml_list(bookmarks, lastOrder + 1000)
val root = <bookmarks>{ oldNodes }{ newNodes }</bookmarks>
scala.xml.XML.save(targetFolder + "/bookmarks.xml", root, "UTF8", true, null)
Thanks to Scala's excellent XML support, reading and modifying the bookmarks file is easy. The method to_xml_list() iterates all favourites and creates XML fragments for each one using the following method.
def to_xml(bm: Favorite, order: Int) = {
  <bookmark>
    <title>{ bm.name }</title>
    <url>{ bm.url }</url>
    <order>{ order }</order>
    <created>{ bm.fileDate.getTime }</created>
  </bookmark>
}
Favorite is a class representing an Internet Explorer favourite that I wrote long ago. (Yeah baby, code reuse!) Value order is the number Bookmark Explorer uses for sorting bookmarks. See the complete source of GuenmatBookmarks.scala.