Front PageBy CategoryRuby stuff

Celebrating Three Years of Anarchaia!

Sat Mar 29 14:04:55 +0100 2008

It has been another year of your favourite (near) daily favourite dose of links, IRC quotes, lyrics and quotes?

Lots has happened in that time! Tumblelogs really turned mainstream, new platforms like Soup appeared, and tumblelogging was featured at the Telegraph, Chaosradio Express and Rails Podcast.

Time for the yearly statistics (previous year in parentheses):

  • Anarchaia as of today consists of
    • 996 posts (669)
      • 18499 snippets (13555)
        • 12797 links (9445)
        • 2100 pictures (1440)
        • 1148 IRC quotes (979)
          • 610 #ruby-lang quotes
          • 371 #ruby-de quotes
          • 34 #rpa quotes
          • 17 #rubyist.org quotes
          • 14 #haskell-blah quotes
          • 10 #haskell quotes
          • 10 #lisp quotes
          • 82 other quotes
        • 1860 lyrics (1242)
        • 379 quotes (311)
        • 205 thoughts (138)
    • totaling 4.8 megabytes, 443416 words and 85119 lines.

Thanks for all your kind mails, contributed links and other pleasantness. I still enjoy it as much as I hope you do as well.

However, Anarchaia will have to change in the future: when my study begins (roughly October), I won’t have the time any more to do a daily issue. But I will try my best to make at least a weekly version of it.

Now, on to another year of tumblelogging!

(BTW, chris blogs turned four this week as well. 48 posts this year and still no new blogging software. I’m working on it, really!)

NP: Grotus—Good Evening

Off to Seelbach

Mon Mar 24 12:51:19 +0100 2008

Tomorrow I’m going to leave early for Seelbach deep in the Black Forest where I’ll spend the rest of the week educating myself on civil service (which I finished for two thirds already, but hey, who cares).

Anarchaia and chris blogs will resume publishing Saturday, March 29.

Please notice that this means I will not be able to attend Euruko 2008 in Prague this year. That’s sad, but I can’t help it (not that I’d have anything to talk about). Enjoy the program.

Regarding conferences, I am planning to go to the Workshop on Self-sustaining Systems in May and RailsConf Europe in September (I hope there will be a CabooseConf Europe, really).

I expect to have occasional Internet access in Seelbach, else mail will have to wait. It’s my first travel with the EEE.

NP: Grateful Dead—Promised Land

Introducing gitsum

Mon Feb 04 16:21:46 +0100 2008

The major showstopper before I was seriously considering going to Git was the lack of an darcsum-like interface for Git.

Yesterday night I finally decided to write it.

git-status (included as git.el in the Git distribution) is usually good enough to use, but I often like to do partial commits, that is, commit only parts of a file. Git can do that now for some time, using git add --interactive or frontends like git-hunk-commit or git-wt-add. Still, there was no way to do it conveniently in Emacs.

Let me introduce gitsum:

Gitsum screenshot

You can freely delete hunks you don’t want to commit, split big changes, or even edit the patch directly if you feel adventurous. It also integrates into git-status so you can easily switch between these frontends.

Gitsum is hosted at http://github.com/chneukirchen/gitsum (which I highly recommend) and is mirrored at http://git.vuxu.org/, patches and additions are welcome! It’s still very fresh and has some rough corners, but I already notice my increase in productivity.

NP: Twelve Tone Failure—As I Hit the Floor

Review: Ruby on Rails Enterprise Application Development

Fri Jan 18 18:06:13 +0100 2008

Ruby on Rails Enterprise Application Development
by Elliot Smith and Rob Nichols.
Packt Publishing, Birmington 2007.

[Full disclosure: I have received a copy of the book in exchange for this review.]

The book targets Rails beginners that have a little prior knowledge of Ruby and Ruby on Rails and aims to accompany them on their way to Rails mastership. It focuses on the iterative and stepwise development of a small CRM system for a small company. Since the chapters don’t anticipate, it can be read straight forward, while the reader continuously learns and refines his skills.

It starts with a general introduction on why to use a web-based client-server architecture for business applications, and then recommends Rails to implement them, last but not the least because it is open source and enables easy testing.

Next, the reader is introduced to basic database design, elementary normalization and how Rails’ ORM works. Then, it discusses Rails naming conventions and includes a list of reserved words in Ruby. A list of reserved class names is unfortunately not included, it would have been very helpful since Ruby already claims some very generic class names (Date, Thread, etc.).

Contradictory to the introduction, now nevertheless follows a tutorial on how to setup and install Rails. The book was written before Rails 2 and generally speaks of outdated versions, however, most of the content is not affected by this—still, there may be some traps if one tries to follow it with more recent Rails versions. After setting up Rails, the installation of a database (MySQL throughout the book) and a revision control system (Subversion) is explained.

After these preliminaries, a Rails project is created and the book explains the Rails directory structure. Tables are set up, migrations introduced, and the reader learns about the essential ActiveRecord API with finds and relationships. Validations are addressed as well; the regular expression for email checking is broken. After a quick overview of unit testing and Test::Unit (TDD is discussed but not used), the reader can check in the code for the first time.

Now, they generate controllers, introduce ERB and pagination (using the built-in paginate), how to do links and layout and furthermore how to use partials and flash. The chapter also shows how to write functional tests.

The application is ready for a first deployment. After an overview of the typical Rails hardware requirements, the book explains how to set up Mongrel.

The next chapter focuses on user experience. The authors introduce routes for better bookmarking, show how to add search and input validation and finally give examples of using AJAX for autocompletion. They also point out that AJAX should be used sparingly and only when it makes sense. The chapter also makes an excursion on how to setup Instiki as a help system.

After this, the book deals with improving error handling, authentication (for which they use unsalted password hashing) and file uploads. After displaying a primitive version of file uploads, it is shown how to install plugins and how to use acts_as_attachment.

Then, more serious deployment gets addressed. They introduce Capistrano, explain how to set it up and then use it for upgrading, downgrading and database-related tasks. A list of common problems is provided to help fix likely issues. The authors also explain how to install automatic start-up scripts, session cleaning and log rotation. The rest of the chapter deals with optimizing the Rails application: how to find and identify the bottlenecks with profiling and how to speed up Rails with the different kinds of caching available or by using eager loading. Finally, they also address scaling by using multiple Mongrels and Apache as a reverse proxy and static file server.

The last chapter, “Down the Track” tries to school the reader when it’s okay to break Rails’ conventions. They give situations where the use of custom SQL or using multiple databases is required or advantageous. The chapter also outlines general virtues of a business application developer, such as the importance of understanding the business processes, that successful applications primarily need to yield profit, that automation is good, and reporting important.

The book is concluded by an appendix showing how to setup your own Gem server.

Conclusion: The book does not satisfy the introductory claims: it is often too detailed on the basics and too shallow on the crucial things and sidetracks the reader into unimportant issues. The writing is occasionally clumsy and sometimes overuses the passive voice to incomprehensibility. Some code examples are syntactically invalid and a few Ruby-related commentary plainly wrong. Throughout the text, replace all occurrences of “property” by “attribute” and of “ampersand” by “commercial at”. Various other mistakes sprinkle the book, occasional typos, random font changes and weird spacing suggest the book was produced in a hurry. People with typographic sense will be shocked by the table of contents and complete and the utter lack of typographical quotes. The few illustrations are reproduced in a very low resolution.

Still, the book may be useful for Rails beginners that are interested in the development of an “enterprise application” and would like to know what else there is to keep track of. The complete Rails newbie however will stumble due to the preknowledge of Ruby, whilst the slightly advanced Rails developer will hardly learn anything new and would be better off with specific books on deployment or system administration to extend his knowledge.

Rating: 3 of 5 points.

NP: Minutemen—Love Dance

Unsubscribing ruby-talk

Tue Jan 01 20:11:14 +0100 2008

To: ruby-talk-ctl@ruby-lang.org
Subject: unsubscribe
From: Christian Neukirchen <chneukirchen@gmail.com>

I finally got around unsubscribing ruby-talk, which has a feeling of both pity and relief. I didn’t read it for the last months, and only skimmed the overgrowing thread list. There was no way to keep up.

What I don’t want to miss are the software announces, therefore I set up a quick’n’dirty RSS feed to keep me up to date.

It’s been over three years and more than 800 messages. See you somewhere else.

(Of course, I’ll continue to post my ANN’s there.)

NP: Morcheeba—Fear and Love

A Euruko 2007 diary

Mon Nov 12 20:01:18 +0100 2007

Friday afternoon: Flight FDH–VIE

Intersky sucks: it’s expensive, uncomfortable, and sitting next to the propellers of that small machine was no fun. The weather also sucked and made the flight feel more like a rollercoaster than a bus ride. Motto of the flight: “Ich beschwöre euch, meine Brüder, bleibt der Erde treu” (… and “Verächter des Lebens sind es, Absterbende und selber Vergiftete, deren die Erde müde ist: so mögen sie dahinfahren!”.)

Friday evening: Das Lederer

Euruko almost DDOS’ed Das Lederer, the Viennese restaurant we went to in the evening. The waiter planned for 15 people but then we were 60. ;-)

Also, I finally met Manuel in real life. We figured out that I read his del.icio.us network more often than he does.

Friday night: Metalab

After dinner and a few beers, we went to the Metalab. This is a seriously great place. Where else can you solder, etch boards, develop photos, cook dinner, surf the web, read Concrete Math, smoke, have 8-bit color lighting control, drink Club-Mate, meet guys creating a Web 2.0 porn site (NSFW) or the best hosted tumblelog solution, play kicker, and maybe even make meta-LSD?

If you ever get to Vienna, going there is a must-do IMO if you are geeky.

We stayed at the Metalab until 4:30, then we walked to the flat, and took the tram for the last few stations—if you don’t have a ticket, you can just buy one there. Very nice.

Saturday morning

Roughly four ours of sleep later I head to the university, miss the entrance and walk around it once. It’s a great building with huge staircases and marble columns, and actually the second-oldest university of Europe, which Jürgen Mangler tells us in his introduction about this year’s host, the University of Vienna. There have been four initial fields back in the fourteenth century, which were theology, jurisprudence, medicine and philosophy. The computer science department actually belongs to the jurisprudence, which is weird. He goes on and speaks about the Viennese coffee culture and that good waiters must be mean. After his intro, we decide what talks there will be and in which order.

Hal Fulton is chosen to give the keynote, Future of Ruby. After a short recap of the Ruby history (Hal was one of the first ten Ruby users in the US), he shows the growth of the community by using the ruby-talk as a metric. Then, he shows which new features are planned for 1.9 and 2.0. There also are many new implementations of Ruby going on, which focus on speed and interoperation. In his opinion, Ruby is enterprise ready for a long time. He also wants to see Ruby on handheld and phones. Notable quote: “If you have to work on Java for eight hours a day, you go home and kick your dog.”

Next, Tim Becker presented a small library of his, Dbrb, which is a very simple DWIM API for doing SQL things in Ruby. He’s not a fan of Rails and ORM in general, and DBI is very complex to use. Therefore, he decided to create a really simple SQL library, which he first tried to hack into Ruby strings etc. to make it invisible but then he just defined a method, cleverly named sql, which does everything. With it, one can easily query and change data using SQL without all the messy details. There also is profiling support to help you find bottlenecks. Dbrb is a seriously cool idea because I think all direct database interfaces for Ruby are much too complicated and I hate myself for not having the idea in the first place. Sometimes, things almost are too simple.

David Anderson presented his Informl Wiki, which essentially is a Wiki with support for forms and database objects. He demoes a portal for King Louis XIV and shows how easy it is to make simple CRUD apps and entry forms. They have a cool wikish and simple markup format for forms and one can do database queries and report generation with it as well. You’ll find it here.

In the lunch break, we had some pizza.

Then, Ramine Darabiha and Sven C. Köhler demonstrated Mysit.es, which aims to provide a central data storage for all your Web 2.0 sites and they showed how to create a new service with it. Lots of Myfoo.es-jokes came up, the one I like most is “Myfec.es — Put your shit online, literally.”

After this, I gave my talk Introducing Rack. The material is online, so I’ll not go deeper into Rack here.

Stephan Kämper talked about Transitions next up, which he classified into social, qualitative and quantitative and personal ones. He showed that Euruko itself is full of transitions, and how they matter in daily life. He also showed that there are many transition effects in Keynote.

Kingsley Hendrickse spoke on Riess Automation, which is a library to script the Internet Explorer using COM. He didn’t like Watir anymore, so he decided to write Riess, which is better designed, has a nicer DSL, is quicker, has builtin assertions and also can work without JavaScript. He accesses the DOM via COM directly and provides a CSS selector like API to do assertions on the DOM. He also quickly demostrated Hyperdrive, which can be used for testing any Win32 application. As well as “automating tasks in World of Warcraft”, that is.

Then, Peter Szinek gave a presentation on ScRUBYt!, which is a DSL for writing web scrapers, a task generally known to suck. However, with ScRUBYt!, which uses Hpricot and WWW::Mechanize, it becomes fun again. His examples at least looked a lot simpler than the usual scraping code I’ve seen. There also is Firescrubyt, which uses Firewatir (to talk to Firefox) and Scrubyt and can be used to scrape AJAXy sites.

The last talk on Saturday was Martin Grund on Easy DSLs with Ruby, where he explained what DSLs are and showed how to create a simple, lispy, external DSL with Dhaka. Then, he demoed a DSL he’s been writing, RMQL, which is a kind of simplified XQuery.

Saturday evening: Universitätsbräu

This evening, I had my first Schnitzel and after some beers, Jürgen Mangler and I started hacking some deepish metamagic trick which we would talk about the next day then.

After dinner, we went to the Metalab where we stayed until half past three and then went home—where I talked to Jürgen and his girlfriend and we tried to explain her what we hacked in the evening.

I went to bed short before five o’clock, whereas they went to see an episode of Stargate. Yeech.

Sunday morning

I woke up after another four hours of sleep, but since I tried to be polite, I didn’t wake Jürgen, which made us be late, which was a bit troublesome because he had the key to open the conference place. ;-)

Jürgen and I presented our yesterday-late-hack, **super: an exercise in drunken programming*. Instead of *foo and bar, we used food and beer as metavariables.

The following talk was by Kingsley Hendrickse again, this time on BDD with RSpec. After explaining the idea behind BDD a bit, he tried to develop an address book in a pair-driven BDD style. That is, he’d write the tests^Wspecifications and someone in the audience would write the code. They didn’t get very far, though. Probably everyone had not had enough sleep

Next, Paul Battley spoke on Fun with trees. He tried to find similar product names for work and needed a fuzzy string match for that. After showing a few well-known algorithms how to do that (Soundex and Metaphone, for example), he introduced metric trees based on the Levenshtein distance, which results in a so-called BK-Tree. He explained how to build, query and use them.

Stephan Kämper talked on Quality in code after, since there has been lots of discussion about “beautiful code” recently. He referenced Zen nnd The Art of Motorcycle Maintainance, and showed various small Ruby hacks on how to make more beautiful code.

Then, Hal Fulton quickly presented a Proposal for an in operator in Ruby. Fine with me.

In the lunch break, I had my second Schnitzel at the Cafe Einstein.

Tim Becker spoke on DTrace, which really is impressive. There are 45k different things in Leopard you can probe for and he showed how to write D scripts (which reminds me a lot of awk) to discover various things. He showed how to inspect Ruby with DTrace in a high-level way. Very powerful stuff.

After that, Ry Dahl gave a talk on Ragel & Ruby, where he first explained what Ragel is, when to use it and how state machines work. He showed pieces of Hpricot for explanation purposes. Ragel can generate multiple languages, but the recent Ruby generator is very slow, but useful for development and experimentation.

Martin Grund and others showed Twizzr then, a recreational game they wrote the night before. It’s a few hundred LOC camping application that is well tested. Twizzr is a quiz game interfacing via Twitter. One recieves news headlines and needs to figure out the obscured word in them. They had some problems with the Twitter API because it limits to 70 messages per hour.

The last talk was by Sacha Schlegl on his ebXML implementation with a very clever name: Hefeweizen.

Then, Euruko 2007 ended and I have to say I really had a great time this year. There was a very friendly and open atmosphere as well as an excellent location in the University of Vienna where they have WLAN that works and enough multiple sockets for everyone. I hope everyone of the roughly 70 people that attended (there even were a few girls, contrary to last year!) enjoyed it as much as I did.

Miscellaneous

Song of the weekend: LaborCase—Vanille (heard at the Metalab).

There were no videos made this year, but if you really want to see a video, search for two girls one cup (NSFW).

NP: Bob Dylan—Winterlude

Off to Euruko 2007

Thu Nov 08 22:39:41 +0100 2007

This is the last post before traveling to Vienna for the European Ruby Conference 2007, where I’ll be talking about Rack this year.

Since Apple is slow with delivery at the moment, I don’t have a new shiny MacBook to travel with yet. Someone will need to lend me his notebook to do the presentation, and I’ll use the good old hippie PDA to take notes.

I’m looking forward to meet everyone there.

Anarchaia will resume publishing on Monday, November 12.

NP: Bob Dylan—Driftin’ Too Far From The Shore

On Mail

Wed Oct 31 17:34:10 +0100 2007

I have just aborted a week-long oddisey of finding a good mail client that can deal with pretty big IMAP mail boxes. (Of course, this is because Gmail now does IMAP, which is a really nice idea.)

They all suck, are too slow, or both.

Before everyone now comes shouting, “Bah, just use Mail.app”, these are my requirements for this use case (I’ll try Mail.app again as soon as I get Leopard, and will tell you how it breaks down then…):

  • Must work over SSH without X, which means console/line based
  • Must support IMAP well (bye mutt)
  • Must support big mailboxes (100k messages and more)
  • Must be open-source
  • Should be unixish in some way

One more word about the big mailboxes: I do not need to see all headers at all times, and if the mailer can operate fast on a subset (say, the last 2000 mails), this is fine enough. I’d rather use a quick program with a smaller working set than a slow program which shows all messages of this century. In fact, this is recommended by the IMAP client coding HOWTO. (I think only Pine does it, and that didn’t work too well either.)

I tried all of these: Mutt (the only program with nicer source than interface), Pine (works well with smallish IMAP boxes, but breaks down with my 172k-ruby-talk box), Nail (same, and the UI sucks), and Cone (I gave up compiling).

As you will notice, most of these clients are written in C. It’s probably because of their age, but really it is a waste of time. Mailers written in C are the worst you can imagine, except for mailers written in C++, which share the issues but take ten times as long to compile.

Mail clients written in C usually means that they are noncustomizable/untweakable (Pine) or they use hacky configuration language (Mutt). Scripting languages exist, and given proper algorithms and datastructures (which you need anyway, if you want to make a scalable mail reader), they are fast enough to do anything mail related, while still being proper, portable languages for extensions and plugins. (There are a few mail programs written in Perl, but they don’t seem successful.)

I’m back to Gnus/fetchmail/Maildir now. It can support IMAP, and works relatively fast (see below for reason), but searching for new mail is slow, and blocks my complete Emacs (I may end up just starting two instances…).

And Gnus, I now realize, is a fine mail reader. This probably is because it was made as a news reader, and the virtues of a news reader are what counts in my case: Gnus asks you how many messages to load (usually just the unread ones), and works zippy with them then, but even with 10k of messages, it still *is* usable.

Furthermore, it has a seriously cool feature: expiring. You don’t delete mail (I never do that, anyway, which is why my mailboxes are getting so big), but you expire it, and if the mail is expired and older than a week or so (configurable), it either deletes it, or moves it into a different mail box, or does anything you tell it with elisp. I now use this to make monthly mbox-archives of ruby-core and ruby-talk, since HFS+ doesn’t really like 150k+ files in a directory.

Which gets me to a side note… one of my first posts on this blog was about mail storage formats, and Maildir essentially was the winner. Maildir is rock-solid, but tools like rsync or rsnapshot really have to work hard to back them up, if they reach a decent size. And many file systems (still no ZFS in OS X) slow down a lot. I’d like to propose a Multimaildir format that stores mails like Git in Maildir/000/999 and the next one in Maildir/001/000 instead of stuffing them all into one directory. Should be pretty easy to do, and makes everything faster. (You also could move your old mail easily, just move Maildir/000 somewhere else (O(1)), instead of globbing like hell (O(n)).) End of sidenote.

I also had a closer look at MH, which always fascinated me. There is a good O’Reilly book on it available online, and I like how it was designed. Very unixish. I can’t really imagine using it, though. (I read/skim lots of mailing lists, and apparently MH doesn’t thread, and I guess it’s just too slow to vgrep a summary and read the few interesting posts. Maybe with a really well-tuned Zsh setup, with keybindings and everything.)

For half a day I glimpsed the idea of writing an IMAP-based MH. In fact, such a thing, written in Python, exists as MHI. But I’m not sure I really want to use it, and it would suck to spend a lot of time to reinvent the wheel and not even drive with it.

So, I thought about my needs, did a bit of research with antique mail clients. (Did you know jwz used Netscape 3.02 for a looong time to read his mail? Not console based, unfortunately.)

Now, I’m sucking it down and will write my own client, and I’ll use something one rarely sees on Unix: lets call them “interactive non-screen based interfaces”. Actually, that’s wrong, because you probably use the shell every day. Mutt and Pine take all your screen and are nontrivial to implement (you need to do a pager, and all the curses stuff, yeech), while mail/mailx/nail are totally-line based and you need to end each command by pressing return (which is one key too many for lots of mails).

I think we should do it like this: make a small library that provides a few widgets, like “line picker”, “item picker”, “line reader”, add an Emacs-style (or, almost easier, vi-style) keyboard map system to dispatch between these and make all input interactive (cbreak). Many apps on ITS worked like that, and it’s pretty comfortable to use, while still fast, flexible and text-based.

I’m pondering making a Gnus feelalike in Ruby based on this scheme, with the following very limited function set: just IMAP (but that well), and all configuration by editing/adding Ruby, threading like jwz does it, and just the stuff I need. One should have usable results within a week, who knows.

I could end up in the history of men by writing the first mail reader that doesn’t suck. :-P

NP: Bob Dylan—No More Auction Block

A RailsConf Europe '07 Diary

Sat Sep 22 12:31:41 +0200 2007

Flight STR–TXL, Sunday

Flying with air berlin is very pleasant: You get to choose from five newspapers, get free coffee and cake, and they show you the stupid (albeit rendered) security video on a TV screen.

Sunday evening

Time for some Bratwurst (pics)! After arriving at our apartment and figuring out how the WLAN is supposed to work, we take the tube to Kalkscheune where lots of people are already. The rug-b people made name tags for us. (Hey Vico!) After we all had enough Bratwurst, some go play Werewolf while we decide to go to the Tacheles (a.k.a. “shitty building”) and have some beer.

Monday

Since I didn’t book any tutorial sessions, it’s time to sleep out. We try to fix the WLAN but completely fuck it up. (You should have seen us trying to even find the router!) Later, we go to the great St. Oberholz (blog) cafe which has good coffee, good food, free wifi and Bionade. Not to forget nice waiters (Hey Ines!) and lots of Mac users. I had a heavy walnut tarte.

Monday evening

We missed Dave Thomas’s keynote because had a big Thai dinner. It was awesome and very tasty. And hot. Some go play Werewolf. Later we tried to find the Havanna Club Club, where there was a guy which a friend of a friend one of us knows. We searched for an hour, and ended up at the Madonna Bar, where we had some beer.

Tuesday

Being a bit late, I rushed into the DHH keynote. He showed evolutionary advancements on the way to Rails 2.0, for example automatic database setup, easier-to-read ActiveRecord inspects (yay) and partials by object type (which is pretty nice). He also demonstrated how to add new content-types to create special output for the iPhone. Finally, he announced a Rails 2.0 preview release to appear shortly after the conference.

Then, I attend the first sessions: Deployment and Continuous Integration from the Trenches by Fernand Galiana, who talked about new features in Capistrano 2 such as namespaces, different deployment strategies and events, which allow for seperation of aspects. After a whirlwind tour of cap2 we learned about certain traps and how to avoid them, for example by using lazy variable expansion. He also showed best practices such as factoring common code with load, multistage deployment and caches, which also can use rsync now. Fernand concluded his talk by showing a quick example of how to write your own tasks and announcing his Rails-driven Capistrano frontend dubbed Capote. His talk was amusing and full of hilarious engineering pictures.

Next up was Dr. Nic Williams with his excellent talk Meta-Magic in Rails: Become a Master Magician which started with a list of features he liked in Ruby and which help doing meta-stuff like the flexible syntax and the highly dynamic behavior. He explained he likes “a big number of complexity” and went on to compare Perl with a puppy unconscious of itself, Java with Keith Richards, and Ruby with Matrix’s Neo, who knows everything about himself and his environment. He introduced his Magic Models which use const_missing to generate ActiveRecord models on the fly and outlined a few important meta-programming techniques. It was a really funny and instructive talk (at least if you are not already a Ruby pro).

In the lunch break, I got to know some found the Havanna Club Club later, and it was just where we searched. Sigh.

In the afternoon, I attended Really scaling Rails by Britt Selvitelle, who works for flickrtwitter (thanks, nec). After explaining to the audience that most of them probably won’t need his hints yet, he explained their mongrel setup (they only proxy one request at a time from Apache to each mongrel, so requests won’t queue up) and gave tips on benchmarking actions. He insisted on not over-architecting. Furthermore, he explained how to create daemons for long-running tasks (such as informing 10000 followers of twitter’s popular users) and how to cache DB queries. He also introduced starling, which is an in-house queue server they wrote. If you can, cheat, he recommended to us, meaning that users won’t notice if things don’t update in real time or are totally synchronous. He also told about essential things for deployment, such as monitoring and easy deploy/rollback. Scaling is only needed where it matters. Lastly, he explained the importance of an API for twitter and how it was relevant for the big community they now have.

The next talk was Improving the Rails ecosystem by Evan Phoenix, the leader of the Rubinius project. He talked about how a better Ruby results in a better Rails and how Rubinius is focused on improving some Ruby deficiencies, like full operator overloading (you can overload != by itself), better memory usage (better sharing among forked processes), .rba archives for easier code deployment and more readable and informative backtraces. He announced they would release a 1.0 at the end of the year and concluded the talk with an extensive Q&A session. This was a very funny talk as well, last but not the least because of his sole usage of made-up statistics. (Rubinius is faster than three-legged dogs and turtles, but slower than the Space Shuttle, you knew?)

The day ended with Roy Fielding’s keynote The Rest on REST2, who once looked at the entire web—back when it was fifty sites. After a short history of the web until 1995, we got to know he was the main HTTP RFC editor and he went on outlining the web’s architecture. He explained how REST implies hypertext in some sense and how it made the web bigger. He also told he had a look at Rails and tried to show how to make it more RESTful (he lauded the CRUD); most things already can be done easily. It was a good talk (have a look at the slides, they are self-explaining mostly) and I really liked the small quotes on top of each slide.

Tuesday evening

We had some Schnitzel at a restaurant Unter den Linden which name I forgot. Then, we headed to RejectConf which took place at the Pirate Cove (noone noticed that tomorrow would be Talk Like A Pirate Day, though. Arrr!!) Some went to play Werewolf.

Dr. Nic praised me for even being able to talk about Ruby meta-programming after some rounds of Jägermeister shots. No big deal. ;-)

The caboosers also got a new set of t-shirts. (Thanks, chrissturm.)

Wednesday

The second day of the conference sessions started with Best Practices by Marcel Molina Jr. and Michael Koziarski of the Rails core team. (We learned Jamis Buck wasn’t there because his wife got a child.) They noticed most Rails projects stuff too much stuff into the controller and not enough into models. They explained that the controller merely should contain action code and most of the business logic belongs to the models. Marcel recommened the Smalltalk Best Practices book again, which is really worth a read. Michael talked about how association proxies make you code easier to understand and how to factor code into many descriptive methods.

Then, I attended JRuby at Thoughtworks by Ola Bini, who complained about MRI having threading issues, bad unicode support, and speed and GC problems. JRuby, which was started in 2001(!), tries to address all these problems. He also told that Java 6 made JRuby twice as fast without changing anything. JRuby will be compiled to bytecode to allow obfuscation, which is important for certain businesses. It also allows for easier deployment. At the end of his talk, he introduced his new Apress book “JRuby on Rails”.

After this, I went to Ruby on Rails Security by Heiko Webers, which was a lemon. He tried to shock the audience by telling he saw lots of session ids on the wifi, but proceded to give a totally boring talk about essential security concepts which would have been demonstrated a lot better by, well, demonstrating them. More action please!

In the lunch break, I met David Chelimsky of the RSpec team. We talked a bit about BDD and the future of RSpec and test/spec. He also explained the new StoryRunner to me. Then, I met Geoffrey Grosenbach and we recorded a Ruby on Rails podcast out of the blue!

The first afternoon session I attended was Browser-based Testing of Massive Ajax-using Rails Applications with Selenium, by Till Vollmer of MindMeister, a pretty neat AJAX mindmapping tool. He explained what Selenium is, and how usual tests don’t test browser behavior, which is essential for them. After a quick overview of Selenium’s features, he demonstrated their test suite for a live example.

Next was Functional JavaScript Development with Prototype by Ben Nolan. He told about JavaScript lambdas and what binding them means and went on talking about Prototypes enumberable extensions which have lots of useful methods like invoke, pluck or inGroupsOf. He mentioned taking some Haskell courses at university and stated JavaScript code is much easier to develop and debug when it consists of small, idempotent functions. Also, he recommended to store data in the DOM and not in private properties of JavaScript objects.

After the afternoon break, I went to Jay Fields’ talk on Extending Rails to Use the Presenter Pattern which was very fuzzy and mellow. He couldn’t really get his point across and most of the audience left the session without knowing what a presenter even is, which is kind of sad since it surely could have been useful in some situations. Or not.

The last session, PhD on Rails by Sam Aaron however saved the day. It was such a refreshing, intelligent and humorous talk that I completely forgot to take notes. Let me try to remember: He created a database backed system to keep track of objects which are rendered in a three dimensional spaces and then implemented a query language to operate on them. Really cool. And the first person I met that uses VRML.

Wednesday evening

We tried to find a restaurant for roughly 25 persons which was not that easy. We ended up in a pretty expensive French brasserie, but I liked my dinner. Some went to play Werewolf. The rest went to Ambulance Bar where we had half a dozen cocktails each. They were very good. We got back to the appartment at 3am, just before the Werewolf players finished.

Thursday

I decided to stay one more day after the conference, and we spent all day at St. Oberholz again. I had a great tiramisu and a beagel. Yum.

Thursday evening

We decided to go to the Fernsehturm for dinner, had a Weizenbier up there waiting until we could enter the spinning restaurant, which was pretty cool. The food was far better than I expected and not even that expensive.

After dinner, we went back to the appartment because we all would need to wake up pretty early.

Flight TXL–FMM, Friday

I had to wake up 6am to get to the airport in time. I met Geoffrey there again and we had another little chat. I flew back with tuifly, which let me chose whether I wanted to be seated to the window or not but had no free coffee or other features. They play the stupid security video for you. It was a bit cheaper, though.

General points

  • git is gaining popularity among Ruby hackers, I saw lots of them installing it and toying around.

  • Berlin: I had forgotten how great the city is. The complete and utter lack of aesthetics actually is appealing, but the icky typography in the subway hurts my soul.

NP: Bob Dylan—This Wheels On Fire

Off to RailsConf Europe 2007

Sat Sep 15 14:55:31 +0200 2007

Tomorrow I’ll fly to Berlin to attend RailsConf Europe 2007. There will be no mail, IRC and can’t live blog. But I wont be angry at non-working or darn expensive WLANs, either.

I have a hipster PDA with me, and an (albeit digital) camera, so don’t feel too safe.

If you’d like to meet me, feel free to contact me by mobile or txt (I will read, but not reply to tweets for chneukirchen).

I’d like to organize a BoF or similar for people interested in Rack and running Rails together with Rack. Catch me if you are curious.

chris blogs and Anarchaia will resume publishing on Friday, September 21.

Have a good time.

NP: Bob Dylan—4th Time Around

Mapping Programming Language IRC Channels

Wed Aug 08 19:50:31 +0200 2007

I enjoy lurking in obscure IRC channels and often have been amazed how many people I met there I already knew from some other channel. Today, this happened again, so I just had to map all language channels I could find on Freenode and make a diagram of their relationships.

I tried to find all language-specific general channels, and came up with these: #perl, ##c, #python, ##c++, #ruby-lang, #haskell, #bash, #lisp, ##java ###javascript, #perl6, #scheme, #erlang, #ruby, #latex, #lua, #d, #asm, #zsh ##tcl, #ocaml, #fpc, #io, #awk, #sed, #forth, #scala, #ada, #dylan, #sml, and #!/bin/sh.

I also added #rubyonrails, #concatenative, #esoteric, #oasis, #haskell-blah, #ruby-de, #camping, and #rack, which are not really general language channels but interesting to see.

After frustration with R (I first wanted to make a kind-of heatmap), I decided to use GraphViz’s fdp. Here’s the preview of the map (click for fullsize, beware: 1833x2084px):

IRC Map of Programming Language Related Channels

If you want to print it, there also is a PostScript version.

The font-sizes are logarithmic, legend for the edges:

  • If 45% of the smaller channel are in the other channel, there is a bold line.
  • If 25% of the smaller channel are in the other channel, there is a solid line.
  • If 10% of the smaller channel are in the other channel, there is a dotted line.

Enjoy.

NP: Jeff Buckley—Lilac Wine

Announcing test/spec 0.4, a BDD interface for Test::Unit

Fri Jun 29 16:08:27 +0200 2007

Today I’m releasing test/spec 0.4, a library to do BDD with Test::Unit.

News in 0.4:

  • June 29th, 2007: Fourth public release 0.4.
    • Support for Ruby 1.8.6.
    • Support describe/it/before/after RSpec 1.0 syntax.
    • Allow should.raise { code_that_raises }
    • Add xcontext to disable complete contexts.
    • Backtraces are cleaner now.
    • Mention test/spec on Rails.
    • Fix small Gem bugs.
    • Fix bug related to counting negated assertions.
    • Fix bug in specrb.
    • Allow empty xspecifys.
    • Make SpecDox and RDox count empty specifications.
    • Allow Kernel#context to take a superclass.

Full announcement: ruby-talk:257483.

You can download test/spec 0.4 at
http://chneukirchen.org/releases/test-spec-0.4.0.tar.gz

Alternatively, you can checkout from the development repository with:

darcs get http://chneukirchen.org/repos/testspec

Please mail bugs, suggestions and patches to .

(Patches using “darcs send” are most welcome.)

Since version 0.3, a Gem of test/spec is available. You can install with:

gem install test-spec

(It may take some time for the index to be updated and the mirrors propagated.) I also provide a local mirror of the gems (and development snapshots) at my site:

gem install test-spec --source http://chneukirchen.org/releases/gems

MD5:

be9a3d747dc212bb21f7d78928d20652  test-spec-0.4.0.tar.gz
e2f4757aa764d67ed5630d5e1093316c  test-spec-0.4.0.gem

NP: Juliette & the Licks—Pray for the Band Latoya

Analyzing the JRuby test suite

Wed May 30 14:40:44 +0200 2007

One of the biggest Ruby unit test suites in existance is JRuby’s, which weights (all external suites included) a whopping 39kLOC. It is split into some big subprojects:

  • The JRuby test suite (10kLOC)
  • The Rubinius test suite (8.4kLOC)
  • The Rubicon test suite (5.8kLOC)
  • The BFTS (4.3kLOC)
  • The Matz Ruby Interpreter test suite (4kLOC)

(The other ~6kLoc are benchmarks and Java unit tests, which are not relevant here.)

I have analyzed each of them according to these factors:

  • Number of test cases (contexts)
  • Number of tests (specifcations)
  • Number of assertions (shoulds)
    • how many are negated
    • what do they test

I’ll go through each test suite and present the numbers. Please note that they were made with some hacked-together scripts and may not be totally accurate, but they should show the big picture. All numbers are based on checkout r3767, last changed 2007-05-30 07:52:31 +0200.

The JRuby test suite

The JRuby test suite uses minirunit and Test::Unit for its tests. The minirunit part has 2747 assertions, but no specially marked test cases. The most used assertions were:

  • test_equal (1695)
  • test_ok (400)
  • test_exception (277)
  • test_tree (118)
  • test_no_exception (73)
  • test_check (69)

There are a lot non-xUnit assertions defined, which only make up a small part of the suite: the often used ones are test_tree (assertions about the parse tree) and test_marshal.

Negated assertions occur as test_no_exception and test_fail, and make up about 5.6%. (Including 71 cases of test_ok with a negated expression.)

The small mri test suite (minirunit too) has 260 assertions, of which 226 are test_ok, 19 test_equal and 15 test_check.

The Test::Unit part of the suite has 40 test cases with 244 tests. There are 568 assertions, of which 33 (5.8%) are negated. Most used are:

  • assert_equal (331)
  • assert_raises (38)
  • assert_parse_only (38)
  • assert_inspect_evaled (28)
  • assert_argerr (20)
  • assert_cycle (18)

Other non-xUnit assertions are: test_to_yaml, test_eval_inspected, test_path_segments.

The Rubinius test suite

The Rubinius test suite uses a small clone of RSpec called mini_rspec. It contains 117 contexts with 1046 specifications. There are 2513 shoulds, of which 15 are negated (0.6%).

The most used shoulds were:

  • should == (1765)
  • should == true (304)
  • should == false (106)
  • should_raise (141)
  • should == nil (87)
  • should_include (35)

should_receive (12) was the only custom should found.

The Rubicon test suite

The Rubicon test suite uses Test::Unit and has 42 test cases with 480 tests. Of 2316 assertions, 18 are negated (0.8%).

Most used assertions were:

  • assert_equal (1941)
  • assert_flequal (107)
  • assert_nil (102)
  • assert_raise (79)
  • assert_same (30)

Non-xUnit assertions are assert_bag_equal.

The BFTS

The Big Fucking Test Suite consists of 13 Test::Unit test cases with 359 tests. There are 1914 assertions, 34 are negated (1.8%).

Most used where:

  • assert_equal (1706)
  • assert_nil (85)
  • assert_raises (76)
  • assert_same (23)

There are no non-xUnit assertions in the BFTS.

The MRI test suite

The MRI test suite consists of 46 Test::Unit test cases with 166 tests. There are 1178 assertions, of which 28 are negated (2.3%). Most used were:

  • assert_equal (982)
  • assert_raises (69)
  • assert_nil (43)
  • assert_instance_of (17)

Non-xUnit assertions are: assert_arity, assert_eval_inspected, assert_inspect_evaled.

Conclusion

N.B.: These unit test suites test language implementations and not highlevel libraries or applications, therefore these results are not directly applicable for general testing frameworks. It would be great if someone could do tests like these for big libraries (Rails) or big applications.

The main assertions used are tests for equality (and especially true, false and nil) and tests for exceptions. Only a small part of assertions are negated, and these mostly check that nothing is raised.

xUnit assertions cover over 90% of all assertions, but custom and user-defined assertions simplify testing by abstracting common code and making test cleaner and clearer.

Future testing frameworks (especially for language test suites) should optimize for these features.

NP: Bob Dylan—Forever Young

Rack 0.2, a modular Ruby webserver interface

Wed May 16 17:27:36 +0200 2007

Today I’m proud to release Rack 0.2.

Rack provides a minimal, modular and adaptable interface for developing web applications in Ruby. By wrapping HTTP requests and responses in the simplest way possible, it unifies and distills the API for web servers, web frameworks, and software in between (the so-called middleware) into a single method call.

The exact details of this are described in the Rack specification, which all Rack applications should conform to.

Supported web servers

The included handlers connect all kinds of web servers to Rack:

  • Mongrel
  • Mongrel/Swiftcore (require it before Rack.)
  • WEBrick
  • FCGI
  • CGI

Any valid Rack app will run the same on all these handlers, without changing anything.

Supported web frameworks

The included adapters connect Rack with existing Ruby web frameworks:

  • Camping

These frameworks include Rack adapters in their distributions:

  • Ramaze
  • Maveric
  • Racktools::SimpleApplication

Available middleware

Between the server and the framework, Rack can be customized to your applications needs using middleware, for example:

  • Rack::URLMap, to route to multiple applications inside the same process.
  • Rack::CommonLogger, for creating Apache-style logfiles.
  • Rack::ShowException, for catching unhandled exceptions and presenting them in a nice and helpful way with clickable backtrace.
  • Rack::File, for serving static files.

All these components use the same interface, which is described in detail in the Rack specification. You can choose to use them exactly in the way you want.

Convenience

If you want to develop outside of existing frameworks, implement your own ones, or develop middleware, Rack provides many helpers to create Rack applications quickly and without doing the same web stuff all over:

  • Rack::Request, which also provides query string parsing and multipart handling.
  • Rack::Response, for convenient generation of HTTP replies and cookie handling.
  • Rack::MockRequest and Rack::MockResponse for efficient and quick testing of Rack application without real HTTP round-trips.

rackup

rackup is a useful tool for running Rack applications, which uses the Rack::Builder DSL to configure middleware and build up applications easily.

rackup automatically figures out the environment it is run in, and runs your application as FastCGI, CGI, or standalone with Mongrel or WEBrick—all from the same configuration.

Where can I get it?

You can download Rack 0.2 here:

Alternatively, you can checkout from the development repository with:

darcs get http://chneukirchen.org/repos/rack

(Patches using “darcs send” are most welcome.)

Installing with RubyGems

A Gem of Rack is available. You can install it with:

gem install rack

I also provide a local mirror of the gems (and development snapshots) at my site:

gem install rack --source http://chneukirchen.org/releases/gems

History

  • March 3rd, 2007: First public release 0.1.

  • May 16th, 2007: Second public release 0.2.

    • HTTP Basic authentication.
    • Cookie Sessions.
    • Static file handler.
    • Improved Rack::Request.
    • Improved Rack::Response.
    • Added Rack::ShowStatus, for better default error messages.
    • Bug fixes in the Camping adapter.
    • Removed Rails adapter, was too alpha.

Contact

Please mail bugs, suggestions and patches to .

You are also welcome to join the #rack channel on irc.freenode.net.

Thanks to

  • Michael Fellinger, for the helpful discussion, bugfixes and a better Rack::Request interface.
  • Christoffer Sawicki, for the Rails adapter.
  • Tim Fletcher, for the HTTP authentication code.
  • Armin Ronacher, for the logo and racktools.
  • Aredridel, for bug fixing.
  • Gary Wright, for proposing a better Rack::Response interface.
  • Alexander Kellett for testing the Gem and reviewing the announce.
  • Marcus Rückert, for help with configuring and debugging lighttpd.
  • The WSGI team for the well-done and documented work they’ve done and Rack builds up on.

Copyright

Copyright (C) 2007 Christian Neukirchen http://purl.org/net/chneukirchen

Rack is freely distributable under the terms of an MIT-style license.

Links

Rack: http://rack.rubyforge.org/
Rack’s Rubyforge project: http://rubyforge.org/projects/rack

Camping: http://camping.rubyforge.org/
Ramaze: http://ramaze.rubyforge.org/
Maveric: http://maveric.rubyforge.org/
racktools: http://lucumr.pocoo.org/trac/repos/racktools/

f1063711f228d19875a3211d71308b5c  rack-0.2.0.tar.gz
fad21b5fac8790fe6bf295fefdac5816  rack-0.2.0.gem

NP: Aimee Mann—Clean Up For Christmas

Celebrating Two Years of Anarchaia!

Tue Mar 27 17:37:19 +0200 2007

How quickly the went the two years with your (near) daily favourite dose of links, IRC quotes, lyrics and quotes? It’s hard to believe.

And, in this second year, tumble logs really became popular, not at least due to the help of Tumblr, the first tumblelog hoster open for everyone! The Tumblelist is almost running over!

Of course, you ask for the yearly statistics (previous year in parentheses):

  • Anarchaia as of today consists of
    • 669 posts (336)
      • 13555 snippets (7353)
        • 9445 links (5003)
        • 1440 pictures (763)
        • 979 IRC quotes (657)
          • 584 #ruby-lang quotes
          • 255 #ruby-de quotes
          • 33 #rpa quotes
          • 17 #rubyist.org quotes
          • 10 #haskell-blah quotes
          • 10 #camping quotes
          • 70 other quotes
        • 1242 lyrics (590)
        • 311 quotes (251)
        • 138 thoughts (89)
    • totaling 3.4 megabytes, 61320 words and 316340 sentences.

I’d like to thank all my readers for their kindness, thankful mails and popularity-increasing links. I hope you enjoy it as much as I do—every day anew.

Now, on to another year of tumblelogging!

NP: Dead Moon—Destination X