Jun 04

The importance of Iron Ruby

Tech 2 Comments »

Ola Bini (JRuby and ThoughtWorks) has written about the importance of Iron Ruby and how he fears it is going to take forever unless Microsoft changes how they do open source:

For example, what is a compliant Ruby implementation? Since there exists no spec, and no comprehensive test suite, the only way to measure compliance is to check how close the behavior matches MRI. But this have some problems too. How do you check behavior? Well, you need to run applications. But how do you get so far as you can run applications?
What JRuby did was that we looked at MRI source code.

John Lam can not look at MRI source code. He cannot look at JRuby source code. He cannot look at Rubinius source code. If he does, he will be terminated.

So, the next best alternative: accepting patches from the community, which can look at Ruby source? Nope, no cigar. Microsoft is not really about Open Source yet. Their license allows us to look at their source code, and also to fork it and do what we want with it. But that’s only half of what open source is about. The more important part is that you should be able to contribute back code without having to fork. You can’t do that with IronRuby, since Microsoft is too scared about being sued for copyright infringement.

I am going to make a bold statement here. Under the current circumstances, I don’t believe it’s possible for John Lam and his team to create a Ruby implementation that runs Rails within at least 18 months. And frankly, that’s not soon enough.

John and Jim and phenomenal at what they do, so I hope that: a) Microsoft does change their stance on open source. b) even if they don’t John knocks it out of the park a la IronPython.

Jun 04

GearsDB: A simple abstraction for the Google Gears Database

Ajax, Google, Tech 2 Comments »

I have been having fun playing with Google Gears. As I build applications with it (such as RSS Bling) I find myself repeating a few things on the database side.

Just wanting objects back

Instead of working with result sets, I just want to think in objects / hashes coming back.

To grab one fella I can:

bob = db.selectRow('person', 'id = 1');

or

bob = db.selectOne('select * from person where id = 1');
bob = db.selectOne('select * from person where id = ?', [1]);

console.log(bob.name); // write out 'Bob'

It is more interesting when you return back a bunch:

db.selectAll('select * from person where name like ?', ['bob%'], function(person) {
document.getElementById('selectAll').innerHTML += ' ' + person.name;
});

The callback gets passed in an object representation of the row. You can get back all of the results, but you should favour dealing with a row at a time instead of waiting around.

Inserting and updating

You often have an object that you want to fling in. This is easy to do via:

var bob = {name: 'Bob', url: 'http://bob.com', description: 'whee'};
db.insertRow('person', bob);
db.insertRow('person', bob, 'name = ?', ['Bob']);

The last form will only do the insert if another Bob isn’t already in there.

You can then update via:

db.updateRow('person', person); // assumes that 'id' is the id, else you pass it in

or force the row in via insert or update (if it exists update, else insert):

db.forceRow('person', person);

To round things off you can db.deleteRow('person', bob);, db.dropTable("person");, and db.run('create table....');.

run() is a simple wrapper around execute() that handles logging and such for you.

To get started with the database you just need to:

var db = new GearsDB('gears-test'); // db name

All of this is in an open source project gears-dblib, and you can see simple tests/examples running.

The project also runs with Firebug Lite so you can play with simple console.log type things even if you don’t have Firebug installed (e.g. want to test on IE). Very nice indeed.

Of course, someone will rewrite ActiveRecord and Hibernate in JavaScript shortly to work with Gears ;)

Jun 01

Google Feedburner: I am really excited about this one

Google, Tech 5 Comments »

The rumours have been out for awhile, but it is great to see that Google has bought FeedBurner.

I am actually really excited about this. There are so many natural fits:

  • Google Analytics – FeedBurner stats
  • Google Reader – FeedBurner
  • Blogger – FeedBurner: this is going to be really nice!
  • Ads – Ads

Congrats to the FeedBurner team, and welcome. I am now going to use FeedBurner for the Google Developer Podcast :)