<?xml version="1.0" encoding="ISO-8859-1"?>
<opml version="2.0">
<head>
<title>27.opml</title>
<dateCreated>Wed, 27 Feb 2008 01:00:46 GMT</dateCreated>
<dateModified>Wed, 27 Feb 2008 01:00:46 GMT</dateModified>
<ownerName>Tom Morris</ownerName>
</head>
<body>
<outline text="Ruby and RDF - Beauty and the Beast?" created="Wed, 27 Feb 2008 01:00:46 GMT"><outline text="I've been working on writing a Ruby &lt;acronym title=&quot;Resource Description Framework&quot;&gt;RDF&lt;/acronym&gt; implementation. It's been quite good fun. Just thought I'd blog about some of the things I've been doing in building it and thinking about how to develop it.&#13;" created="Wed, 27 Feb 2008 01:00:46 GMT"/><outline text="&#13;" created="Wed, 27 Feb 2008 01:00:46 GMT"/><outline text="First off the bat, I have to say I absolutely adore Ruby. It is, along with &lt;a href=&quot;http://python.org/&quot; rev=&quot;vote-for&quot;&gt;Python&lt;/a&gt;, one of the sexiest languages ever created. It's amazingly relaxing and pleasant. When I'm writing Java or PHP, I usually end up swearing and shouting at my monitor and getting all &lt;a href=&quot;http://headrush.typepad.com/creating_passionate_users/2006/04/angrynegative_p.html&quot;&gt;negative&lt;/a&gt;. Even if Ruby is slow or Rails doesn't scale or whatever, it lowers stress levels and probably blood pressure. We should teach it in schools, for chrissakes.&#13;" created="Wed, 27 Feb 2008 01:00:46 GMT"/><outline text="&#13;" created="Wed, 27 Feb 2008 01:00:46 GMT"/><outline text="Second thing is I've been using &lt;a href=&quot;http://rspec.info/&quot; rev=&quot;vote-for&quot;&gt;RSpec&lt;/a&gt; (pronounced &quot;Arr Spec&quot;, not &quot;Arse Peck&quot;), the tool for behaviour-driven development, which is a fancy reformulation of test-driven development. I like it a lot. TextMate gives me a pretty window filled with green boxes when I do things right and an informative window filled with black and red boxes when I fail. More than that, though, it actually makes you focus on writing the important tests - rather than just a test to ensure that the class exists (yes, it probably does!), it makes you do object-oriented programming in a way that solves problems quickly and efficiently. I'm probably not in a great position to judge, but I think I'm turning out reasonably pretty code that's no more than is required to solve the problem. Development becomes quite easy - I have a printed copy of &lt;a href=&quot;http://www.w3.org/TR/rdf-concepts/&quot;&gt;Concepts and Abstract Syntax&lt;/a&gt; on my desk, and I then work through it turning it into RSpec code, then finally coming back, rewriting the RSpec and the tests, then finally writing a small bit of code that solves the problem.&#13;" created="Wed, 27 Feb 2008 01:00:46 GMT"/><outline text="&#13;" created="Wed, 27 Feb 2008 01:00:46 GMT"/><outline text="I've been committing all this code and pushing the updates onto Github, but in a new branch called 'new'. You can &lt;a href=&quot;http://github.com/tommorris/rena/tree/new&quot;&gt;take a peek&lt;/a&gt;. It's not yet functional, but the tests all run and pass.&#13;" created="Wed, 27 Feb 2008 01:00:46 GMT"/><outline text="&#13;" created="Wed, 27 Feb 2008 01:00:46 GMT"/><outline text="The folks on the #ruby IRC channel have been helpful too - I found out about method_missing on there, which turned what could have been quite painful (namespace support) into a 14 line class. Namespaces in Python's rdflib look a bit like this FOAF['name'], but in Ruby, I've opted for foaf.name instead - using the method_missing to return a uriref for any method call on a namespace class.&#13;" created="Wed, 27 Feb 2008 01:00:46 GMT"/><outline text="&#13;" created="Wed, 27 Feb 2008 01:00:46 GMT"/><outline text="This is how I want my code to end up looking:&#13;" created="Wed, 27 Feb 2008 01:00:46 GMT"/><outline text="&#13;" created="Wed, 27 Feb 2008 01:00:46 GMT"/><outline text="&lt;code class=&quot;ruby&quot;&gt;&lt;pre&gt;graph.add_triple x.tom, foaf.knows, x.dan&lt;br /&gt;graph.add_triple x.tom, foaf.firstName, &quot;Tom&quot;&lt;/pre&gt;&lt;/code&gt;&#13;" created="Wed, 27 Feb 2008 01:00:46 GMT"/><outline text="&#13;" created="Wed, 27 Feb 2008 01:00:46 GMT"/><outline text="It's pretty damn close to N3 in beauty, and it's certainly better than - oh - let me think:&#13;" created="Wed, 27 Feb 2008 01:00:46 GMT"/><outline text="&#13;" created="Wed, 27 Feb 2008 01:00:46 GMT"/><outline text="&lt;code class=&quot;java&quot;&gt;String fullName = &quot;John Smith&quot;;&lt;br /&gt;Resource johnSmith = model.createResource(personURI).addProperty(VCARD.FN, fullName);&lt;/code&gt;&#13;" created="Wed, 27 Feb 2008 01:00:46 GMT"/><outline text="&#13;" created="Wed, 27 Feb 2008 01:00:46 GMT"/><outline text="Heh, no offence meant - we all love &lt;a href=&quot;http://jena.sourceforge.net&quot;&gt;Jena&lt;/a&gt; really, but &lt;a href=&quot;http://jena.sourceforge.net/tutorial/RDF_API/index.html&quot;&gt;it's not exactly beautiful&lt;/a&gt;.&#13;" created="Wed, 27 Feb 2008 01:00:46 GMT"/><outline text="&#13;" created="Wed, 27 Feb 2008 01:00:46 GMT"/><outline text="I was then thinking more broadly about where we go next with this. I'm probably going to pull most of the parsing and writing out of the existing Rena tree - it supports RDF/XML and N-Triples. It'd be nice to be able to push out Turtle and N3 too. And if I'm working on those, I'm going to need to group things by subject. Which led me to thinking about whether resource may be a good way for non-experts to access data inside graphs. &lt;a href=&quot;http://danbri.org/&quot; rel=&quot;met friend&quot; rev=&quot;vote-for&quot;&gt;danbri&lt;/a&gt; promptly explained the problem with the use of a pair of inverse properties - namely foaf:maker and foaf:made. You can't expect every resource will do these the same, which means you either bite the bullet and accept data loss, or you perform some magic where you look for resources as being both subjects and in-graph objects. Madness lies that way.&#13;" created="Wed, 27 Feb 2008 01:00:46 GMT"/><outline text="&#13;" created="Wed, 27 Feb 2008 01:00:46 GMT"/><outline text="More madness lies down other paths though. We could look write some kind of extensibility method into the Ruby library which means that people could basically define a class for, say, FoafPerson, which would be a sub-class of a class called Resource (which would not be used tremendously often on it's own). That way, someone who wanted to read &lt;acronym title=&quot;Friend of a Friend&quot;&gt;FOAF&lt;/acronym&gt; data could simply import FoafPerson and then read data out of it like they already do with other classes that hook up to web services. But this seems a little bit of a let-down. Isn't the point of &lt;acronym&gt;RDF&lt;/acronym&gt; that one doesn't need to have any domain-specific code (as is required in, say, parsing XML or microformats where the parser needs to know what it's looking for).&#13;" created="Wed, 27 Feb 2008 01:00:46 GMT"/><outline text="&#13;" created="Wed, 27 Feb 2008 01:00:46 GMT"/><outline text="Then the other approach is to have it look for an &lt;acronym&gt;RDF&lt;/acronym&gt; Schema or &lt;abbr title=&quot;Web Ontology Language&quot;&gt;OWL&lt;/abbr&gt; ontology, pull that in and use &lt;em&gt;that&lt;/em&gt;. That's also good, but that's more code to write, more classes for people to understand and we are trying to keep this simple enough to be usable.&#13;" created="Wed, 27 Feb 2008 01:00:46 GMT"/><outline text="&#13;" created="Wed, 27 Feb 2008 01:00:46 GMT"/><outline text="Still gotta think about this. I know that Chris Bizer's &lt;a href=&quot;http://www4.wiwiss.fu-berlin.de/bizer/rdfapi/&quot; rev=&quot;vote-for&quot;&gt;RAP&lt;/a&gt; library has a three-pronged approach - statement, resource and ontology models. That's good - as you can have it at whatever level you like it. I'm hoping that some of Ruby's flexible language will mean we can have a simple Graph class that has all the possible approaches joined together in a more seamless way. The average user doesn't want to have to think &quot;I want to browse this data in a statement-centric way&quot;. They think &quot;I want to iterate through all the people and do &lt;em&gt;x&lt;/em&gt; with their names and e-mail addresses&quot;.&#13;" created="Wed, 27 Feb 2008 01:00:46 GMT"/><outline text="&#13;" created="Wed, 27 Feb 2008 01:00:46 GMT"/><outline text="Which brings us to SPARQL. SPARQL is cool and amazing, but I think it's too complex for most people. That's why I think cracking the model problem and making a really usable data model for people is going to be a good way to go.&#13;" created="Wed, 27 Feb 2008 01:00:46 GMT"/><outline text="&#13;" created="Wed, 27 Feb 2008 01:00:46 GMT"/><outline text="But here's the thing. I will not and can not build this on my own. I need collaborators to make it all work. That means people with Ruby experience and experience parsing &lt;acronym&gt;RDF&lt;/acronym&gt;. I'm still making myself familiar with all the cool, sexy Ruby stuff like RSpec and Rake and Capistrano and so on, and need people to make sure I don't do anything stupid. So I'm throwing open the gauntlet - come and help fix the code. Clone my repository and hack on it. Doesn't matter if you break it, you can always revert your changes. Send me patches. Come and chat on IRC about it. Poke people you know who are good at this stuff and get them to break and fix code and send patches. As a little bonus, I've got some &lt;a href=&quot;http://github.com&quot;&gt;Github&lt;/a&gt; invites to give out to people who want to help out. Send me patches and you may just get an invite to the sexiest repository service ever.&#13;" created="Wed, 27 Feb 2008 01:00:46 GMT"/><outline text="&#13;" created="Wed, 27 Feb 2008 01:00:46 GMT"/><outline text="Anyway, over and out. Time for a little late-night PlayStation crack and then to bed. I'll be at &lt;a href=&quot;http://upcoming.yahoo.com/event/432853/&quot;&gt;Geek Dinner&lt;/a&gt; tomorrow, so come and bug me about Ruby. If my laptop weren't still in the Apple Store getting fixed up by a Genius (or not), I'd suggest pair programming.&#13;" created="Wed, 27 Feb 2008 01:00:46 GMT"/><outline text="&#13;" created="Wed, 27 Feb 2008 01:00:46 GMT"/><outline text="P.S. You can interpret the title any way you like. Personally, I think beauty and beastliness are not disjoint properties. Beasts (in the sense of animals) can be beautiful, and even moral beastliness can be aesthetically pleasing too (think Nazi uniforms, propaganda films and posters and horror movies)." created="Wed, 27 Feb 2008 01:00:46 GMT"/></outline></body>
</opml>
