Need a bike in Paris?

I’ve been playing around with Ruby and Ruby on Rails lately. Ruby is a very elegant language in many ways, but it’s not well-respected by mainstream developers and doesn’t have a fancy IDE (that’s Interactive Development Environment, Mom), so it’s the sort of language I can get excited about. I come from a long line of command lines.

Anyway, I came across the coolest little Ruby app. There are these loaner bikes available at train stations in Paris, and for an annual subscription fee you can borrow them, as part of a service from Velib. Amsterdam and some other European cities have loaner bikes for free laying around all over the place, but presumably the bikes from Velib are in a little better condition.

Velib provides information about which bikes are available at each station, through a free web service. For example, to find out how many bikes are at station number 20022 (wherever that is), you’d just go to http://www.velib.paris.fr/service/stationdetails/20022, and you’d get back some XML that might look like this:

<?xml version="1.0" encoding="UTF-8" ?>
<station>
  <available>24</available>
  <free>6</free>
  <total>32</total>
  <ticket>1</ticket>
</station>

This tells you that there are 24 bikes available out of 32 total. (I have no idea what “free” and “ticket” mean.)

So Thibaut Barrère has created a little Ruby app that shows a graphical representation of where bikes are available throughout Paris, by calling the Velib web service to get info about how many bikes are currently at each station, and then plotting it all on a map. The map above shows availability of Velib bikes around Paris as of 1:45pm on Wednesday, 03/26/2008.

I think this is cool in two ways: it’s an interesting Ruby app to learn from, but also I love the way more and more businesses are providing free (or nearly free) access to useful data on the internet, via web services and other mechanisms. Many businesses have info that they’ll give out to anyone on the phone, and providing that same info through a web service means developers can use it in creative ways.

This entry was posted on Thursday, April 24th, 2008 at 9:54 pm. You can subscribe to comments on this post through its RSS feed.

4 comments posted:

  1. Don’t know a lot about Ruby on Rails, but I’ve done some stuff in Python. The two are, as near as I can tell, compared in much the same way Windows and OS X are compared in the geek community. You know, rabidly and with little room for the other approach.

    I know Python is very cool, and can only assume that Ruby on Rails is, too. Where did you do your reading about it? Or did you jump into it some other way?

    One of the easiest languages I ever wrote in was Object Rexx — Rexx was originally a scripting language for the AS/400, and Object Rexx was an offshoot of that. Very conversational. It had some idiosyncrasies (its logical operators were a little funky, so going back and forth from PHP or Python to Rexx took a little mental gymnastics), but neat nonethless.

    Another neat one I just learned about is Inform — it’s a result of reverse engineering the old Infocom text games (Zork, Hitchhikers Guide to the Galaxy, etc.). A typical snippet of code is:

    The Deathbot Assembly Line is a room. “Here is the heart of the whole operation, where your opponents are assembled fresh from scrap metal and bits of old car.” The dangerous robot is a thing in the Assembly Line. “One dangerous robot looks ready to take you on!” A robotic head, a drill arm, a needle arm, a crushing leg and a kicking leg are parts of the dangerous robot.

    (I hope that blockquote tag works — if not, please don’t hesitate to edit.)

    But I digress. Did you find Ruby on Rails to be pretty intuitive? I’ve heard it has a steeper learning curve than Python, but it seems to me that I see them each about the same amount in job ads and curricula.

  2. Hmm. Intuitive. I’d say that Ruby on Rails is intuitive if you’re thinking in terms of MVC (model-view-controller, a design pattern first popularized in Smalltalk environments of the early 80s). MVC is one of those things that makes great sense, and I’ve done things that borrow from it at various times, but RoR all but enforces it: you absolutely positively must think in those terms. If you do, it’s a super-productive environment.

    Ruby is a pretty elegant and consistent language, a combination of Perl-style scripting (think productivity) and Smalltak-style object orientation (think flexibility — “everything’s an object”). And RoR takes full advantage of Ruby, leading to valid code that includes expressions like 30.months + 15.minutes (a perfectly valid expression in a Rails app).

    Here’s the best brief tutorial I’ve seen: http://fairleads.blogspot.com/2007/12/rails-20-and-scaffolding-step-by-step.html

    I’d recommend installing Instant Rails (http://instantrails.rubyforge.org/wiki/wiki.pl) and then do Sean’s tutorial at the link above. In about 15 minutes you’ll have a hands-on opinion. And besides, I need somebody to help me stagger through the learning curve. Safety in numbers, you know.

  3. Cool. I can’t dig into it right now, but maybe later this week. I’d love to be able to argue with all my Python friends (who are a bit too rabid for my taste about a lot of things).

    Hey, just saw this link on Slashdot today. Might be fun to play with, too.

  4. Hey, for arguing with your Python friends, you might want to read this very details comparison of Ruby and Python: http://blog.ianbicking.org/ruby-python-power.html

Have your say

Fields in bold are required. Email addresses are never published or distributed.

Some HTML code is allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>
URIs must be fully qualified (eg: http://www.domainname.com) and all tags must be properly closed.

Line breaks and paragraphs are automatically converted.

Please keep comments relevant. Off-topic, offensive or inappropriate comments may be edited or removed.