02
May 07

Green and Calm

There are few things in this world more soothing than the green bar of a project-embracing JUnit test suite after moving to a new platform.


01
May 07

IronRuby

Microsoft apparently hops on the dynamic languages train and releases IronRuby, a Ruby interpreter for the .NET platform which is also supported by Microsoft’s counterpart to Adobe Flash, the all new silvery Silverlight (which by the way also supports Python). I’m not exactly a fan of Microsoft, but I like the idea that web applets can now be written in Python and Ruby. How great would it be if these languages could once replace JavaScript on the client side as well. For now, I’ll stick with RJS templates for that purpose.


26
Apr 07

APIs and DSLs

Today I stumbled upon Josh Bloch’s talk How To Design A Good API and Why it Matters at Google Tech Talks. Its loaded with profound wisdom and advice from one of the masters of API design.

He explains that API design is very similar to language design, and I immediately thought that this particularly holds for APIs which are designed as domain-specific languages, which is one of Ruby’s strengths (read this article from Oreillynet.com to learn more about DSLs).

A few slides later he talks about characteristics of good APIs:

  • Easy to learn
  • Easy to use, even without documentation
  • Hard to misuse
  • Easy to read and maintain code that uses it
  • Sufficiently powerful to satisfy requirements
  • Easy to evolve
  • Appropriate to audience

To achieve all these properties for an API is certainly non-trivial, but at least some of them get easier if you design APIs as a domain-specific languages: As the term says, a DSL provides a language that is tailored for a particular domain, in addition DSLs are generally declarative and hide language aspects that are irrelevant. Such a language is obviously easier to learn, use and to read than a mere API, and is more appropriate to its audience. In the end, these are known strengths of declarative languages. Here’s an example taken from the Capistrano manual (Capistrano is a Ruby DSL for remote software deployment):
[ruby]
desc “Start the spinner daemon”
task :spinner, :roles => :app do
run “#{current_path}/script/spin”
end

desc “Used only for deploying when the spinner isn’t running”
task :cold_deploy do
transaction do
update_code
symlink
end

spinner
end
[/ruby]
Though this doesn’t hide imperative aspects completely, I think it’s a good example of how a DSL feels – just as if it wasn’t Ruby but a different language.

So, is it safe to conclude that DSLs are the better APIs?


25
Apr 07

How to not solve a Sudoku

I found this at Ravi Mohan’s One Man Hacking:

Ron Jeffries attempts to create a sudoku solver – here, here, here, here and here. (You really ought to read these articles. They are ummm…{cough} …err…. enlightening.)

Peter Norvig creates a Sudoku Solver.

Compare. Learn.

To increase the impact, I suggest you read Norvig’s essay first. It’s a great read and the elegance and concision of his solution gave me this tingly warm feeling of sheer developer entrancement. In contrast, Jeffries’ writings on implementing a Sudoku solver by following a test-driven development approach, are just disconcerting. In the end, he abandons his half-finished work after five postings. If he achieves anything, he impressively demonstrates that he’s not exactly an algorithms expert (which Peter Norvig, of course, is).

But, as Ravi says, there’s an important lesson to learn here: agile approaches are about software development, not about algorithm design. To be more precise: they are mainly about achieving software quality, not correctness. It’s the purpose of tests to help the developer maintain functional correctness – not to guide her towards a correct solution of an algorithmically non-trivial problem, such as Sudoku solving.

I think, this is a good example for the old saying “If your only tool is a hammer, every problem looks like a nail.” And it supports my impression that in these days too many people in the development world focus on the methodological aspects of software development and underestimate the importance of fundamentals such as algorithm design.

UPDATE: Vlad Levin goes into more detail on this issue.


24
Apr 07

iCal meets Google Earth

Some days ago I had this idea of a calendar browser showing my upcoming events in a 3D perspective, i.e. events of next week are close by while events some months away are far in the distance. The purpose is that I get an intuitive impression of things to come, their sequentiality and relation – something I miss in the typical grid-like calendar views offered by iCal and Outlook.  I talked about it to some of my colleagues and when I tried to explain the idea, I said something like “It should be like looking at Google Earth from a tilted angle, events placed on a sphere which I can roll back and forth“. It took me some moments, then it hit me: It’s easy to place markers on Google Earth by using KML files – and by using Google Earth as a platform, I get all the UI features I need for free.

Fast forward to one and a half days later: A very basic implementation of the “iCal meets Google Earth” mashup is ready, which I call einstein, well, because what it does is some kind of joining space and time. I used Ruby (of course), employing the vpim library for extracting iCal data and XML builder templates for creating the KML output. In the end it was almost too simple.

And this is what it looks like (by now):

einstein-screenshot


24
Apr 07

Algorithms And Data Structures On Drugs

What a beautiful blog I have found: Data structures and algorithms, with nice explanations and visualizations for the complete programmer newbie.


22
Apr 07

Lightweight Developers

Maybe I like Ruby because I’m a lightweight developer? See for yourself:

via RedHanded.


02
Apr 07

I Am Just A Poor Lonesome Developer

… and a long, long way from home. Currently, I am looking forward to doing software projects as a solo developer for the next time. The XP way seems very promising to me but it has a strong focus on teams – pair programming, stand-up meetings and the like. Fortunately, the XP people are also aware of the “solo developer” problem and there are some interesting suggestions for using the XP benefits for your lonely-cowboy-project.


28
Mar 07

Sneaky Snippets (2): A Spec’s Half-Life Period?

From a specification template of a company I worked for some years ago:

Purpose for states: Draft, Adopted, Deprecated

It kinda speaks for itself.


22
Mar 07

Java and/or Ruby

Currently I am working on a small prototypical application involving lots of webscraping, a database and some sophisticated term indexing and search query expansion. Since some parts of the app are quite independent from the others, sharing data only via the database, I decided to code as much as I could in Ruby. There is nothing better for getting into a new language than working on a real project.

For web scraping (which I always did with Python, my absolutely favourite scripting language to date, and the fabulous BeautifulSoup library) I decided to switch to Hpricot (silly name), which does the job of scraping untidy HTML pages good enough for me.

So, what do I use as a cost-effective, well-maintained search and indexing framework? Of course Lucene, because I have grown up with Java and the bold faith that there is a library for everything under the sun – written in Java. But lately I found that there is in fact a Lucene-lookalike implementation for Ruby named Ferret. And it is even faster than Lucene. So off to new pastures.

All that is left in Java will be the RDF handling, because there is nothing as sophisticated for RDF/OWL ontology handling as the Jena library in Ruby.

Tune in next time to hear me talk about the pitfalls of weakly-typed scripting languages …

Links:


Better Tag Cloud