Latest News >> 2008-07-20 2008-06-25

I’ve been completely fed up with news/feed/rss/atom readers these days. I use Linux as my primary operating system, and I only have a few feeds that I want to rip through quick so I can get to reading the content. Yet, trying to find a reader that doesn’t suck donkey balls has been a chore.

2008-06-21

Wanna know what all the Ruby vulnerabilities are? Or at least have a fun look at how to search through code for clues? It’s a blast.

2008-06-13

I’m dropping a large blog post on everyone to just say that I haven’t died, I’ve just been busy working on my book for A/W about Mongrel. I had contracted with them to do a book about deploying Mongrel, but then decided it wouldn’t be a very good book since we’d already done one about that topic and there wasn’t too much more to say.

Update: Checkout CookbooXUL V2

Hey, check out the V2 of CookbooXUL release. It even has 10,000 recipes you can search.

Update: Packaged Download Available

I decided to package up the cookbooxul project so that people will not need to use wget anymore. Enjoy.

Ruby On Rails + XUL Experiment

Well, it looks like someone finally wrote the killer app that makes learning Ruby worth it. Ruby On Rails is a super nice web application framework that I’ve been tracking for a little while now. I’m always looking for something that pushes simplicity over complexity—unlike the Java community. In the past I took a quick look at Ruby and thought it was Yet Another Programming Language. There was nothing in it that was more or less than anything else I used, so the incentive to work with it was limited. Rails makes this very different since it is so simple compared to the complexity you get for free. As an experiment, I combined a Rails example from oreillynet.com with some stuff I’d been doing in XUL under Firefox. The end result took a life of it’s own and many people asked for the source.

The problem was, I didn’t do that much. I took the original source from the oreillynet.com article, followed through it and then changed a few things to get the new snazzy front end. You can check it out temporarily with any Mozilla based browser. NOTE: Disabled for now. In the end the whole thing took me about one more hour to get working, with most of the work in the code used to get dynamic XUL updates remotely.

Once I posted the application to the mailing list I saw the app receive about 10 hits an hour as people played with it. It’s interesting because it’s a dead simple two file hack. Literally, just two files changed and two lines added to a Ruby file. I think this is what impressed me the most about Rails. I was able to modify the sample app to use a completely different interface and I don’t know jack about Ruby or Rails.

The Plot Thickens

The source code is available as a directory of files. If you want to try and run it, then you’ll need SQLite and you’ll need to create the test.db file mentioned in the database configuration. There’s a db.sql file which will create it for you. Once you do that, just run it with ruby scripts/server and hit port 3000 on your machine.

The relevant files to review are list.rhtml and show.rhtml. These two files generate the XUL for the interface. In the show.rhtml file you’ll see a JavaScript function at the bottom that uses the XMLHTTPRequest object to grab XUL content from the /recipe/show URL and patch it into the main XUL interface generated by list.html. This means that the UI is updated dynamically from the server without reloading the whole page.

The magic to get the “JavaScript XUL patching” in showRecipe() working is that your sub-content must have the xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" in the first tag. Check the show.rhtml for an example.

The only other real change I made was to add a response.headers["content-type"]="application/vnd.mozilla.xul+xml" to any handler in recipe_controller.rb . This is the content-type setting to tell Mozilla based browsers with XUL that the file should be run as a XUL file. I’m pretty sure you need this in the show and list handlers, but I haven’t tested that theory yet.

The Story So Far

I’m an old hat at web application development, having developed apps using Java, Python, PHP and even some straight C stuff once in a great while back when I was retarded. I have a fairly consistent way of developing HTML based web applications, but I’ve always thought that HTML forms have outlived their usefulness. I’ve also grown tired of the endless unnecessary complexity that seems to plague Java and “enterprise” applications. It seems that an “enterprise” application must use every GoF pattern, work against a bloated Oracle database, run on top of Hibernate or EJB, work with JMS, and have extensive scalability at the application layer (that means the wrong place for those who don’t know).

I’ve actually written two screen applications with none of these things that did the minimum necessary and were extremely simple, but when a so called “enterprise” guru looks at them they freak. “Oh my god, that’s not good. You can’t use a properties file! That went out with bow ties.” My sense of aesthetics demands that things be as simple and straight forward as possible which means I find Java very annoying at times. And I make my living as a Java programmer.

It’s almost as if programmers these days are in a code complexity fashion contest. Everyone is wearing diamond encrusted necklaces, Gucci purses, Monolo shoes, fur coats, and every gaudy accessory they can get their hands on while they eat expensive caviar on the Andaman Sea. Meanwhile, I just want to wear jeans and a t-shirt, eat cereal and watch cartoons. It’s no wonder all my programming “relationships” end so horribly.

Ruby might be different, but so far only Rails has really showed it off well. I’m also impressed with the Needle project for being cool. I love the fact that both of these projects have rejected the reams of XML toilet paper I’m forced to use in other frameworks. Give me a parser or YAML any day.

Apart from these two projects, I haven’t been too wowed by Ruby in the past. Take the Ruby Gems thing. It took me about 30 minutes to figure out that after you install something with Ruby Gems, you must now put require 'rubygems' lines in all of your scripts. That makes it very annoying since, from my perspective, if I say install something then fucking install it so I can use it. Don’t make me go through your wacky indirection happy shit just to get at the crap. Sorry but that really pissed me off. C’mon, how hard is it to change my load path or put the stuff in the usual Ruby location? Perl CPAN does it. R CRAN does it. Why not Ruby?

Now Rails has blown me away in the first few examples. Examples can be like that and it’s only when I try to implement a more serious unusual application that I start to find the warts on the platform’s hands. Once I come up with a project that I’m willing to “Ruby-ize” then I’ll find out the real scoop on Rails and friends.

Recommendations To The Rails Crew

I’m very eager to explore Rails and other Ruby technology to confirm the Hype. Even if it doesn’t pan out I think it will be fun to learn another language and do some stuff in it. Right off the bat I can make a few recommendations based on my experience with other frameworks:

  • If it’s important to escape things in the HTML then either make it the default for the rhtml templates, or make sure all examples do this religiously. It should be that newbies don’t even know there’s another way to put text into a framework. I say this because it took some good searching to find the HTML escape syntax for the rhtml files. If you go look at the examples put forward, they either have tons of <%h= statements or they just ignore the problem. That’s how you give newbies bad habits, so don’t do it.
  • Oracle, Oracle, Oracle, Oracle. I know it’s retarded, but nobody in the web app world takes any other database seriously. Having used DB2 in the past I can say that Oracle is a royal piece of shit by comparison. There’s a reason that most banks and investment firms use DB2 and not Oracle. But, somehow Sun and Oracle cooked up this blitz that attached Enterprise to every copy of the world Oracle and Java so you’re stuck with it. Until Oracle is supported I can’t even come close to pushing it at any company with established Java development.
  • Start collecting an organized FAQ with detailed answers. Right now the Rails folks put everything in a Wiki, which is Hawaiian for “can’t find shit.” For example, I still can’t find an answer on how to get at the default handler implementations so that I can replicate them or modify their functionality.
  • While we’re at it, if there’s no “show me the goods” switch to the generator then make it. One line files are nice, but when you’re trying to learn how to do it yourself, it’s nice to get a glimpse at the default setup without rooting through a source tree.

Other than that, the Rails site is really nice and well run. A lot better than other projects, which is probably why it’s getting more attention. I really should take a page from their book on my wimp goods. I’d also like to mention that the #rubyonrails IRC channel on irc.freenode.net is really good for information. The folks there are very nice, unlike similar channels which want to pound pulpits with their fat heads.