Saturday, May 21, 2011

Some geecon 2011 notes

A week has passed and I have forced myself to put together some notes I have scribbled during my stay there:

Java 7

What have we found: the good part is that oracle is holding up to the schedule and there is a big chance that this year there will be finally a new java version. I am still curious if this will somehow change the so often said question: "java is dead", but otherwise this is good. So what interesting functionalities can we find in java 7:
  • support for dynamic languages - so your groovy, scala, jruby will be once again faster better cooler
  • project coin : so you can write something like this: List<String> list = new ArrayList<>();
  • fork-join - concurrency library that is not bad, but I would maybe concentrate more on concurrency alias actors (for example akka). You could try this library long time ago as it was available as jsr166y.jar
  • after many many years, you'll be able to use strings in switch statement (although everybody knows that switch - case is bad and we should use strategy pattern instead :D)
  • automatical closing of Closable resources opened in the beginning of try statement
  • one catch for multiple exceptions
For me it was a disappointment that the collection usage simplification won't make it into java 7 (although I knew this before I still had some hope).

To see how this will work in action you can look at this quite old article.


Besides the presentation on the whole spring ecosystem we heard something about the long awaited spring 3.1. They added caching support (quite old information) as they had no more patience to wait for the never coming java standard. Also it should be fully compatible with java 7. It is possible that the execution and scheduling framework will use the new fork-join library. For me a it was quite interesting how easily (with few lines) you can integrate with many network and social solutions: email, XMPP, RSS/Atom, twitter. Twitter can be also used for one to one communication. Spring also checks if you haven't reached the twitter message limit (the limit check works even when you are writing messages from multiple devices/platforms). Also we learned that twitter is often making incompatible changes. And as Spring relies on 3rd party libraries in this integration they can't control the speed of change adaption. This is also why they announced "spring social" (also quite old information) where they will write and adapt all code by their internal team. So by using spring social you should be almost always up to date with current twitter api. The last interesting thing (which some people still don't know) is spring data that provides a simplification of jdbc, hibernate, jpa and noSql databases processing


This was quite a good introduction into the whole hadoop ecosystem. From what I know Hadoop is based on some research papers from google. You can use it to execute tasks over massive amount of data where the task can be divided into smaller tasks and then the result can be combined to produce one global result. The heart of it all is HDFS (hadoop file system), that is based on GFS (google file system). It presents a distributed file system layer, that is positioned above your physical disks. Over it operates the MapReduce framework. To write your custom map reduce tasks/jobs you have to implement interfaces Mapper and Reducer and extend class MapReduceBase, plus define a job configuration (but you are not limited just to java - although it seems that java is one of the most perforant solutions). Another interesting module is HBase which lays over the HDFS and provides equivalent functionality to google's bigtable (from my point of view Hadoop is just one big loot stolen from google that is provided as open source - but this is good). Hbase can be used as input or output for MapReduce jobs. The good thing about Hadoop is that you can process tasks over massive new data without the risk that it will blow up, because it needs to be reindexed first (as you might see in standard database solutions). For me a new information was that cloudera provides a simplification of the installation process and a business (payed) support (which can be a good argument for your customers)

Code generation

There was a presentation of some frameworks that provide you code generation from annotations. Lombok provides annotations to simplify your work: @Getter, @Setter, @Synchronized (even when it seams stupid it does it better than simple synchronize), @EqualAndHashCode, ... The annotations will be replaced by code during compilation process (to make this work the process must be written for each platform: windows, linux, ...). Other solution was Spring Roo, that uses aspectj and *.aj files (which you probably already know). There were also some interesting annotations from Groovy: @Delegate - when used on variable, then the encapsulating class has all its methods and they refer to this object (quite cool - from what I know there is no such thing in java), @Lazy - lazy initialization, @Singleton - proper singleton implementation. For me quite new thing was contract driven programming where you can define a precondition that must be met so that a method can be executed without exception and an after condition - to be honest I am not sure what will happen if this after condition will be violated (as I don't expect it will do some rollback). The sad thing is that the ide support is sometimes not good (for example for Lombok in IDEA). I've also learned new java command: javap that will show you the skeleton of compiled class (everything except method implementation details)


I'll just summarize some interesting and practices (different from the ones so often heard):
  • set timer to 2 hours, start your work. review your work. is it better -> commit it. is it worst -> revert
  • do incremental changes
  • the code with most revisions is the best candidate for test coverage
  • if you want to use new libraries, but your project tech lead won't allow you to put them into production, put them into test code :D
  • have fun, for example give some small awards to those who are most active in code maintenance (like for example a picture on the wall "maintainer of the week", or badges "100% test code coverage guru")
  • good argument for unit tests: when you write them other colleagues can't *** up your code

New J2EE

I have seen only a small glimpse of it, but it seems very readable and simple. Although some spring guys have been making fun of j2ee as from they point of view (when we omit glassfish) nobody supports the whole standard (even when it is released longer than a year now).


After some live demos a left the presentation with impression that this is a cool framework for distributed programming in scala (at least from the maintenance point of view). The distribution of code is almost automatic (not much more than compilation of code is required), new nodes execute jobs instantly after they start and it seemed that there is no complex configuration. So the main goal you have to focus on is your business logic (MapReduce/Actors).


This graph oriented database (yeees, you're right: NoSQL) was presented by the most charismatic presenter from the whole conference. From other NoSQL databases it has some interesting features. It supports transactions. As it is a graph oriented database it stores objects and maps relations between them. Also the querying has a language defined for it, so you don't have to figure out how to retrieve the data from your key value store and also there is no need to write map-reduce functions. It is good for data retrieval in situations where normal database would blow up, because of the required joins (also the speed of querying seems to be unaffected by the data amount, which is quite a opposite situation as you can see it on relational databases). So for example work with hierarchies is a great candidate for Neo4j (you can also define how deep would you like to go, to prevent the out of memory error once you would retrieve too much data). There is heavy use of caching (in this point I am not sure how the first query (before anything is cached) would perform). But there are also some things you must be aware of. The neo4j doesn't scale well (between multiple nodes) when your data is heavily interconnected. As in this case there is a great traffic between nodes that slows the whole query process. To assure great scalability you should be able to split your data into separate data buckets, where each node would host one to many complete data bucket.


From my point of view, it is really hard to say something new about hibernate. But there has been a good summarization presentation about the common pitfalls/mistakes.


This was a part of the workshop day. It contained a small introduction to node.js (if you review the presentation on the node.js page you'll get the almost same information), plus we heard a small but clear explanation of javascript prototyping. After this we downloaded some great practical example (mortal combat client/server written in node.js - code can be found here). Once we got it running we were asked to implement the login screen. Oh and yes, for those who would like to try it out, I would like to cite one advice that has been told to me: "are you trying to run it on cygwin? forget it! Its no good."

my notes:
- if you hate javascript I advice you to see this presentation (that has nothing to do with geecon :))
- node.js has good integration with html 5 web sockets (if you don't know why they are the new hype, read this article)

So in the end I would like to do some summarization. Once I left geecon I had some mixed feelings. From my point of view it is hard to say something new about java as most of the interesting stuff is now being processed in different languages: groovy, scala, ruby, javascript. But somehow they have managed to make it a quite interesting conference. The only thing I was maybe missing were some electric plugs (as they are normally not present in multi-cinemas) (yeah I know, I should have bought a mac :() but otherwise it was ok.

notes for me:
- never sit down. you'll fall asleep
- don't eat polish eggs

No comments:

Post a Comment