Java, Software

Eclipse 3.3 Impressions

So I’ve been using Eclipse 3.3 Europa to work on OSX and Windows using Google Code as the SVN provider.  Details about the project later but for now just a few thoughts on the new release:

The Awesomes…

  • Cut and Pasting code also results in the imports being added to the destination class.
  • Refactoring is all done inline in the class editor, there’s no separate dialog unless the refactor runs into trouble
  • Drag and drop in the editor works (hallelujah!)
  • Sensible packaging strategy that seems to contain everything you need for Java development (except SVN, Subversive or Subclipse should definitely be part of the standard bundle)
  • Seems to be perfectly cross-platform (Eclipse 3.2 was a bit weird on Vista and I never really liked it on OSX)
  • Ant 1.7!

Pains in the ass…

  • It’s still a little more than flaky in its threading, auto-completion has this weird glitch where it hangs, tells you its waited too long and then when you acknowledge that dialog it actually shows you the completions. This one seems confined to Windows.
  • On OSX the JUnit Test Runner seems to start up as it’s own application. I can’t figure out what set of circumstances makes it happen (initially I thought I had clicked an option or used a weird key combo but does not seem so likely). I also had the Class Loader get in a total mess when running the Unit Tests but the two may be linked.
  • No way to quickly adjust the font size in the editor. I’ve got a big screen and that’s great for the big picture but sometimes I want to enlarge code I’m working on so I don’t have to have use ninja precision with the mouse.

Outside of these there are some grey areas, the spell checker is a good idea and god knows there are enough programmers who need it. However it is not a tremendous value add and when it goes wrong it is a memory and processor monster. At work on Vista it decided that an XML file was a text file that was entirely invalid grinding the whole machine to a halt. What I would have liked instead is a bundled Servlet Engine like Tomcat on NetBeans. I’m sure there is some plugin that will provide this but I think it should be a part of the bundle (like SVN support).

Overall though Europa is still a bit of a “is that it?” experience. I recognise that there has been a significant amount of effort and everything looks really polished now but sometimes the new features make me thing “why was I putting up with that in the first place?”. Why didn’ t drag and drop work in the Java editors? If I was doing Java Enterprise why did I have to round up and install my own plugins? Why wasn’t the Ant Plugin for Eclipse 3.2 updated as a minor release?

The Europa developers have done a great job and there is no way I would stick with Eclipse 3.2, but there’s nothing so far that blows me away here.

So, what about the big question that always brings readers to the blog? NetBeans 5.5.1 or Eclipse 3.3? Well 3.3 does make some of NetBeans features look distinctly archaic: Ant 1.7 and JUnit 4 are big pluses. However its about having the right tool for the right job. I always say that if I have a gnarly old codebase then I trust Eclipse to make sense of it and get it working and get me working on it. However for Swing and Web Apps development I think nothing has really changed. You can set up a web app, framework and be experimenting in twenty minutes with NetBeans and Matisse is pretty unparalleled at the moment. With 3.3 I feel the Eclipse team have definitely done the right thing and made J2EE work a much more pleasant experience, however that was more about making up ground on NetBeans. From here on I think they need to think about how Eclipse can make other types of development easier. Personally I do think that is about bundling things like Tomcat and JavaDB into the IDE so that I can setup a configuration that includes my test databases, my test webserver and anything else I need to get my app up and running so that I am working on my code rather than my infrastructure.

Still no criticism can detract from a job well done by the Eclipse team. I just want them to do it again; and more often.

Standard
Celeb Spotting, London

Comedy Spot Max Out

David Mitchell on the tube, picking his nose and reading the Plot Against America. Looks better in life than on film. Meanwhile once off the Tube managed to spot Justin Lee Collins weaving towards the West Country train on his way from Heathrow. Another tall television presenter, sporting brightly dyed hair. Actually looks like some outlandish cartoon character in real life.

Standard
Blogging, Web Applications

Social Networking Scatter

Last Christmas I was having a discussion with a friend who is devotee of LiveJournal. LJ people tend to by LJ4Life and a lot of their online existence revolves around the site and its numerous features.

At the time I rather inarticulatly started voicing my objection to “social hub” sites in preference to having a collection of social networking sites. If I want to chat about music I don’t necessarily want the latest boardgame news or to review my book wishlist.

My preference is for highly specialised very specific sites that do one thing and do it well rather than broad, sloppy, ill-defined hubs like MySpace, Facebook or indeed LJ.

Recently though the large number of sites I am member of it has been a bit awkward since if I am dealing with music I now have three links I would probably want to share with people RYM, Sellaband and E-Fields (my music blog). Getting all three to refer to one another is relatively easy but it still would probably be easier to refer to a link of links. Which means setting up a static page, possibly on this blog or on my own static pages on SDF-EU. What I’d like to do is have more than one link possible on each profile in each site. Most however simply allow one link to one personal page.

So do I really want a hub site to consolidate my interests? Well currently my answer is still no. The point of the web is create links between data and I don’t want to link everything to everything without any organisation. I want to link together my related sites. I also want to be able to flick between my interests as I see fit. If I want to go and update my wants list on Library Thing I don’t want to simultaneously IM via Facebook or see if there is some gig news on MySpace. I want to be able to control my flow of data and choose what I am going to work with.

Therefore despite the proliferation I’m still not ready to be assimilated.

Standard
Art, London

Art in the Park

By chance I stumbled across the Sotheby’s contemporary art exhibition in one of Londons squares this weekend. Giving that it was bucketing down with rain it was a welcome refuge and a chance to catch up with the art world in a venue that wasn’t absolutely heaving (unlike the Royal Academy).

The first shocker was that Bansky now rates about 40K+ for each painting. If the guy graffittis your house is now adds approximately 15% to its value. Yowzer! And to think how many times Bristol City Council erased his earlier (presumably more valuable) works.

The second was a reminder of how disturbing the Chapman Brothers mutant children are. I haven’t seen any of them for a while and I won’t be rushing out for some more anytime soon.

The exhibition was pretty excellent really for something free and drawn entirely from sales. It is always interesting to see how many Andy Warhols there are and what their expected prices are. There are a lot and they are probably cheaper than you expected. I also always come away from a collection of Warhols with a higher opinion of him as an artist. I think he really was one of the great artists of the last century and as his influence continues possibly one of the greatest artists ever.

One aspect of the show that was very new to me was the wave of Chinese contemporary art that has been going international recently. I had heard about it but actually it is all its cracked up to be and I would definitely like to see a more specifically curated show on the subject.

Finally there were a few Grayson Perry vases. I’m not sure whether this was or wasn’t the first time I’ve seen his work but I did think that his Turner Prize was deserved on the basis of this work.

Standard
Television

The Return of the Master

Last night’s Doctor Who? Awesome. The return of the Master played by Derek Jacobi and John Simm was incredibly exciting and sinister. I am delighted at having one of the classic Who villains return and if there has to be another Timelord then this was the one it should have been. The casting of John Simm is absolutely perfect and this season looks like it is going to have a blowout ending.

By a strange coincidence I also limped to the end of the Life on Mars Season 2 DVD after missing the last couple of episodes when they were broadcast and then failing to make enough time to watch the boxed set until recently. I agree with everyone else in the world: Life On Mars has a good ending followed by a really bad one. Switch off after the fade out.

Standard
Java, Work

We don’t need no stinking relational data

A friend recently told me that the Java developers at his company treated the database as a datastore from which they took data and if they were in a good mood they might put it back too. Ah how we laughed… however secretly I thought that was rather unfair. Java developers generally have a tough time with databases and sometimes the things they do to them makes you want to scream but overall I think most respect the fact that an object-orientated language does one thing and an implementation of relational data does another, very different thing. After all you wouldn’t try to write an MP3 player in SQL… oh, hold on bad example you might not want to try that in Java either…

Anyway, any situation where you want to compare and relate data is likely to be a situation where you want to use SQL. Handling things like threaded programming, IO, cross-platform GUIs, scalable web applications are all likely to involve Java. This was proven to me by a Business Analyst who was cross-matching the output of two different systems. I tried to solve the problem by writing a Java application that essentially built up hash maps of various keys and then compared them. I thought it was pretty nifty but it was hard work and drilling down into why the failed matches failed was hard work.

The analyst, damn her, insisted that the output of the two programs be loaded into a database. She then took days to complete the entire reconcilation and was entirely capable of explaining and proving matches and non-matches. My method would probably have taken weeks and a lot of the output would probably have to be taken on trust.

It one of those moments where you can choose to be humble or humilated. Well it sounds bigger if you’re humble anyway but I think I learned an important lesson as a result. If people have spent twenty years or more perfecting a tool for a specific task don’t flatter yourself that you’ll do a better job from first principles with your preferred tool. It’s just a case of Golden Hammer syndrome.

However there are still a lot of Java developers who do think of the database as a datastore. And it is utter madness. If you are using Berkley DB you maybe have a point. But the minute you have a relational framework to your data then the database is not a datastore. It is a monstrously potent way of making data your bitch. Hundreds of developers have tried to move data processing out of the database and into the application layer. I have never witnessed one who has actually succeeded in doing anything than replicating a relational database in memory and the majority just created a catastrophic mess.

If you think the database is a datastore then step away from the database and do something else. Don’t try to bastardise relational algebra, like a lot of things in life it’ll just end in tears.

Standard
Java

JPA, Derby, Hibernate, OpenJPA and Me

I am incredibly excited by the fact that I have just written a single row to an embedded Derby database via the standalone JPA Hibernate implementation. Never before have I persisted an object via the power of just one Annotation. It totally rocks.

Of course what doesn’t rock is the million or so JARs that Hibernate uses to do it. I need to look at how much actually needs to be deployed in a minimal situation. JBoss seems to encourage the deployment of three uber JARs: the x-all.jars.

OpenJPA is lighter on the JARs but requires an agent to be running to, on the fly, byte convert the annotated POJOs into entity managed types. Interestingly both Hibernate and OpenJPA require javassist but seem to use it in different ways.

Currently all of the JPA implementations seem full of quirks and there is no obvious winner of convenience or completeness.

My first major problem is that Hibernate does not support Derby properly when it comes to autogenerating columns. It generates SQL that inserts null into the autogenerated column, I have been wondering whether that is the way that MySQL does it but it seems to be just plain wrong. It seems to be a slightly too literal relationship between the object and the underlying table that should be taken care of by the Dialect adaptor on the insert statement.

A search across the Hibernate forums results in the conclusion that the Hibernate team don’t like Derby and feel that people should be using HSQLDB instead. Aha! The Rails technique! I will answer the questions that I pose, not your lame questions.

I have no idea which of the embedded databases is better but I would think that since Derby is bundled with JDK 6.0 it might be an idea to see if your database solution supports it or not.

Anyway since I couldn’t get no Hibernate love I thought it would be a good opportunity to try swapping around JPA providers and see if the API was a swapable as promised. The logical candidate was OpenJPA as I presume that Apache pretty much eat their own dogfood.

The swap over was completely seamless from a coding point of view. All the annotations were unchanged and the persistence unit just needed the log in details changing as I am using the database in an embedded mode.

Everything else was bloody hard work though. My first mistake was that I had used some HQL queries in my initial stab at the work and these of course blew up. This was just my naivity and after checking the canonical EJB QL definition (the J2EE 5.0 tutorial seems to do the business) I got them working again.

However the most frustating issue was a bloody XML parsing error which gave a standard cvc error that was really unhelpful. The issue was about validating parsing. Although all the examples tend to give standalone XML documents OpenJPA needs the namespace data on the root element or it blows up real nasty.

This was a major blocker due to the obscurity of error and it should really be on a FAQ somewhere. Alternatively you can always specify the namespace of the XML schema and you should be fine no matter what implementation you are using.

Agent issues (usually relating to forgetting to add the agent parameter to the JVM arguments) accounted for the remaining difficulties but these issues are easier to spot. If you get a cast exception or a message that an object has no alias then it means that your annotated objects are not being read into the Entity Manager configuration because… the agent isn’t running.

Overall my experience with JPA has been very positive and it certainly makes using embedded databases a lot more appealing compared to say using JAXB and XML or simply property files. My experiences with the implementations is less than stellar though. Hibernate has a big plus in that it does not require the use of an agent but it uses a lot of JARs and some of them, like Log4J are not really necessary in a Java 5.0 world. I liked OpenJPA a lot, it still has a lot of JARs and like Glassfish/TopLink you still need to include a lot of bits and pieces from the App Server to make the thing work (Geronimo in this case not Glassfish) . I may stick with it for now but since I am using an agent based solution it might be worth checking out the RI Toplink Essentials.

There’s a lot still to do in the JPA SE area and I hope that one of the three contenders comes up with an unfussy single JAR solution soon because as an API JPA is excellent.

Standard
Blogging

Phear my CSS skillz

Yes! I have purchased the CSS upgrade! Yes! I have just spent an hour pissing around with my site settings. You may now phear my mad skillz as you notice that my posts are wider than they were before while my sidebar is a little more floaty than before.

And most importantly the headlines of my posts are no longer a disgusting lime green.

Phear me CSS mortals!

Standard