Wednesday, July 26, 2006

AppFuse and Seam

Hmm, I really liked what I saw in Seam, especially the fact that there are so few files in an app :) Basically, I have the view that one big advantage of Rails is that it controls the whole application stack and that is kind of what Seam tried to do as well. So that's the good part.

The bad part is that the application scaffolding does not work as advertised. OK, it's beta, so that's forgivable. But if you look into the Seam forum you find that many people have problems even with the scaffolding example when they try to use their own db's. There is help given in the forum but overall I was a bit put off at this point.

Back to AppFuse I was again shocked just how much code is there already in an essentially empty starter application. So I had to get over that, adjust my mindset not to think about Rails and off I went. I was not very productive, but I got my stuff done in the end (Matt has really done a great job with AppFuse IMO). I guess Spring, Hibernate, etc can be considered outdated, but they work and there is plenty of material, help and tutorials around. And that helped my productivity quite a bit as well.

In case you should try to follow the Seam application scaffolding example take this hint: the Hibernate reverse engineering tool when applied to a medium sized Oracle db is so slow that you will assume it has crashed. Chances are that it has not. In my setup it took around 20 mins to come up with a list of tables. Apart from this abysmal performance on Oracle I like the tool, actually.

Tuesday, July 25, 2006

Java productivity and the Rails community

I need to write a Java-based web app (it has to be Java because of i18n and scalability issues my employer has with Rails) and I am looking at tools that increase my mileage. Under consideration where Seam and AppFuse, but what made me give Seam a shot is this video:
While I do not need to write a CRUD app this nicely shows how to actually get started without all the plumbing one usually has to do in Java EE (and even then there's some left). Anyway, I'll keep you posted on Seam.

Related to my research on this I came across a thread on the Rails mailing list. For christ's sake! It seems that the converted Java-guys are now Ruby-zealots that now find their pleasure in bashing Java EE. That's a shame because the Ruby community was so well-recognized for being friendly.

PS: if you also need to make up your mind about AppFuse and Seam I found Matt Raible's comments helpful (Matt is the project lead of AppFuse)

Wednesday, July 19, 2006

Ruby's classes are dynamic

One way cool feature of Ruby is that classes can be modified dynamically. I got a chance to use this feature today when I needed to change the output format of the Logger class in Rails (the default format is suboptimal IMHO). I simply had to append to environment.rb:

require 'logger'
class Logger
def format_message(severity, timestamp, msg, progname)
"#{severity} #{timestamp} #{msg}\n"

and, voila, the method 'format_message' was modified.

As a sidenote: By the time I write this the example for changing the log format given in the Rails wiki does not work. And what's worse, if you put non-working code into your environment.rb WebBrick will, of course, not come up.

Ruby, Java and rewriting everything

Here's ( a nice article on the pros and cons of Ruby as compared to Java development. While it seems to be a bit too biased for my taste it still gives a nice overview and I agree with the points the author has collected.

On the other hand I asked myself if the guy who wrote this really wants to rewrite a large Java-based system in Ruby. If so, that kind of venture reminds me of the efforts to rewrite office suites in Java back in 98 (remember Corel?). It's like "hey, I've got this shiny new tool, now let's re-implement everything". Well, when you've got a hammer everything looks like a nail.

I remember Sun's campaign for "100% pure Java" and really don't think we need need a new dogma "100% pure Ruby". I go for "100% the right tool for the job".

Monday, July 17, 2006

Ruby on Rails, Unicode and Oracle

I was kind of in love with Ruby on Rails but now our relationship has hit the first bump: the infamous UTF-8 issue. In short, Ruby does not support UTF-8 (that's more or less the situation). So Rails does not either. However, my task at hand basically involves CRUD operations on a legacy (yet, UTF-8 enabled) Oracle db including German texts. Well, here's how to do that:

The first stop for Unicode in general is the wiki page on Unicode and Rails:

The problem with that page is that it covers the setup of Postgres and MySql-based applications, but not Oracle. In order to get that done I left my database.yml as before, but added a line to config/environment.rb:


This sets an environment variable (it also works if you set the variable for your Rails server process externally). I had to figure out the value of this variable by querying the database:

select * from nls_database_parameters;

For the line in environment.rb use the parameters as: (NLS_LANGUAGE)_(NLS_TERRITORY).(NLS_CHARACTERSET)

OK, I'm happy with my Rails again.