<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>H3RALD : Feed</title>
    <link>http://www.h3rald.com/h3rald/public/rss</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>Personal Log - June 2009</title>
      <description>&lt;p&gt;Welcome to yet another of my extremely boring, excessively fragmented &lt;a href="/tags/personal_log"&gt;personal log&lt;/a&gt; posts. I&amp;#8217;m seriously thinking of dropping the whole series in favor of more frequent (and shorter) blog posts, starting from next year. This means you&amp;#8217;ll probably have to read &lt;em&gt;another six&lt;/em&gt; of these priceless gems, until december 2009.
As usual, feel free to skim through as each of the following &lt;em&gt;sections&lt;/em&gt; is almost completely unrelated to the others.&lt;/p&gt;


	&lt;h3&gt;&lt;span class="caps"&gt;H3RALD&lt;/span&gt; Web Site v8.0&lt;/h3&gt;


	&lt;p&gt;It&amp;#8217;s the time of the year, again. It doesn&amp;#8217;t happen &lt;em&gt;every&lt;/em&gt; year but it&amp;#8217;s definitely a trend (hence the high version number): I&amp;#8217;m going to redesign &amp;#38; redevelop my web site.&lt;/p&gt;


	&lt;p&gt;This time is not the usual &amp;#8220;Let&amp;#8217;s pick another language and another framework and start from scratch&amp;#8221;, but a rather more radical shift, and yet at the same time less painful. The idea is to transform &lt;span class="caps"&gt;H3RALD&lt;/span&gt;.com into a 100% static web site, without losing anything in functionality (gaining, if anything!).&lt;/p&gt;


	&lt;p&gt;&lt;a href="/http://tom.preston-werner.com/"&gt;Tom Preston-Werner&lt;/a&gt; is definitely &lt;em&gt;not&lt;/em&gt; the first person to &lt;a href="http://tom.preston-werner.com/2008/11/17/blogging-like-a-hacker.html"&gt;blog like a hacker&lt;/a&gt;, and his very own &lt;a href="http://www.jekyllrb.com/"&gt;Jekyll&lt;/a&gt; is definitely not the first static web site generator our there, nevertheless, he inspired me to embrace what seems to be one of the latest trend in developer&amp;#8217;s blogs.&lt;/p&gt;


	&lt;p&gt;The idea is simple: turn all the blog posts and pages into static content, and rely on third party web services for things like comments, search etc. For a rather extreme by very interesting example, see &lt;a href="http://tagaholic.me/"&gt;Tagaholic&lt;/a&gt;.&lt;/p&gt;


The advantages of this approach are many:
	&lt;ul&gt;
	&lt;li&gt;Free yourself from a database.&lt;/li&gt;
		&lt;li&gt;Free yourself from a resource-hungry, server-side app (&lt;a href="http://wiki.github.com/fdv/typo/"&gt;Typo&lt;/a&gt;, in this case).&lt;/li&gt;
		&lt;li&gt;Increase speed and reliability, without using caching or similar artifacts.&lt;/li&gt;
		&lt;li&gt;Keep everything under version control.&lt;/li&gt;
		&lt;li&gt;Don&amp;#8217;t worry about breaking things when upgrading (even if the static content generator changes, it shouldn&amp;#8217;t really break things).&lt;/li&gt;
		&lt;li&gt;Unleash the power of client-side scripting (namely, JQuery).&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;For now, I&amp;#8217;m just brainstorming a little bit on &lt;a href="http://github.com/h3rald/h3rald-website/issues"&gt;GitHub&lt;/a&gt;, feel free to participate. The first step is obviously choosing a static content generator, and atm Jekyll seems to be slightly ahead of Webby. Opinions?&lt;/p&gt;


	&lt;h3&gt;Glyph&lt;/h3&gt;


	&lt;p&gt;Did you ever want to write a short manual or a book, or even a long article? If so, chances are you gave LaTeX a shot and either fully embraced its philosophy or totally refused it. Sadly, I belong to the second category: I believe sequential documents like manuals or books should be easier to create simply by using &lt;span class="caps"&gt;HTML&lt;/span&gt;.&lt;/p&gt;


Whever I have a chance to actually start working on it, Glyph will become a &lt;em&gt;document authoring framework&lt;/em&gt;, i.e. a way to create visually appealing documents in a simple way. All the ingredients are there, it&amp;#8217;s only necessary to glue them together in a pretty form:
	&lt;ul&gt;
	&lt;li&gt;Textile (and &lt;a href="http://redcloth.org/"&gt;RedCloth&lt;/a&gt;) to produce clean &lt;span class="caps"&gt;HTML&lt;/span&gt; code from a human-readable markup&lt;/li&gt;
		&lt;li&gt;&lt;span class="caps"&gt;CSS3&lt;/span&gt; to specify page rules&lt;/li&gt;
		&lt;li&gt;A few rake scripts to produce a standalone &lt;span class="caps"&gt;HTML&lt;/span&gt; file, &lt;span class="caps"&gt;TOC&lt;/span&gt;, Index etc.&lt;/li&gt;
		&lt;li&gt;An internal &lt;span class="caps"&gt;DSL&lt;/span&gt; for the document structure and metadata&lt;/li&gt;
		&lt;li&gt;&lt;a href="http://www.liquidmarkup.org/"&gt;Liquid&lt;/a&gt; for control flow, snippets and filters &lt;/li&gt;
		&lt;li&gt;&lt;a href="http://www.princexml.com/"&gt;PrinceXML&lt;/a&gt; to generate a &lt;span class="caps"&gt;PDF&lt;/span&gt; from &lt;span class="caps"&gt;HTML&lt;/span&gt;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;This project is still in planning stage, feel free to have a look at the &lt;a href="http://github.com/h3rald/glyph/issues"&gt;issues/features page&lt;/a&gt; on GitHub. Feedback is appreciated, as usual.&lt;/p&gt;


	&lt;h3&gt;Vim files &amp;#38; &lt;em&gt;the Stash&lt;/em&gt;&lt;/h3&gt;


	&lt;p&gt;If you read the previous two sections of this post, you may have noticed that I&amp;#8217;m growing more and more fond of git (and GitHub). Besides the repositories I already mentioned earlier on, I also created a personal &lt;a href="http://github.com/h3rald/stash"&gt;stash&lt;/a&gt;, which I&amp;#8217;m using mainly to store some of my Linux dotfiles, article drafts and &amp;#8230;Vim customizations.&lt;/p&gt;


	&lt;p&gt;If you&amp;#8217;re looking for a color scheme for Vim, check out my very own &lt;a href="/herald-vim-color-scheme"&gt;herald.vim&lt;/a&gt;, and tell me what you think.&lt;/p&gt;


	&lt;h3&gt;Getting ready for the Big Step&lt;/h3&gt;


	&lt;p&gt;This will probably be my last post as a free man, as I&amp;#8217;m getting married (civilly) on July 2nd and (religiously) on July 11th. 
Luckily the photographer agreed to give us a CD with all the pictures taken on the big day, with no copyright restrictions attached to it (believe it or not, some photographers don&amp;#8217;t allow you to republish &lt;em&gt;your own&lt;/em&gt; photos unless you ask them first), so I&amp;#8217;ll probably write a long post with pictures when we come back from our (half) honeymoon.&lt;/p&gt;


	&lt;p&gt;Everything is pretty much organized. We had troubles with the waistcoats we got from eBay: they were cut almost randomly to &lt;em&gt;resamble&lt;/em&gt; waistcoats, but they weren&amp;#8217;t so we had to re-order another lot of 7 sets (waistcoat, cravat &lt;em&gt;and&lt;/em&gt; shirt this time) from another seller, this time UK-based. I seriously hope to get them in time.&lt;/p&gt;


	&lt;p&gt;On the 24th we&amp;#8217;re having a party at our house. If you were invited, feel free to drop by, otherwise be prepared to be thrown out of the window (4th floor) by one of our ushers (Roxanne&amp;#8217;s &lt;em&gt;big&lt;/em&gt; brother). It&amp;#8217;s probalby going to be about 30-40 people in the end, mainly because most of my office can&amp;#8217;t come due to holidays they booked in advance.&lt;/p&gt;


What&amp;#8217;s left to do now? Well:
	&lt;ul&gt;
	&lt;li&gt;Send the bomboniere over to Ireland&lt;/li&gt;
		&lt;li&gt;Make sure my dad actually ships the 96 specially-bottled bottles of our own wine to uncle John, in Ireland.&lt;/li&gt;
		&lt;li&gt;Make sure uncle John doesn&amp;#8217;t drink all the 96 bottles of wine before the wedding reception.&lt;/li&gt;
		&lt;li&gt;Make sure my best man understood that the speech he has do make &lt;em&gt;must&lt;/em&gt; be in English, at least 3 minutes long and not too offensive to the groom.&lt;/li&gt;
		&lt;li&gt;Pay a huge, colossal heap of money for the whole thing. It&amp;#8217;s going to cost us (and my dad) quite a bit, in the end. But it&amp;#8217;s a once-in-a-lifetime experience, after all (getting totally trashed in a fancy hotel with all your family, including 2nd and 3rd grade cousins).&lt;/li&gt;
	&lt;/ul&gt;</description>
      <pubDate>Mon, 29 Jun 2009 02:24:00 -0000</pubDate>
      <guid isPermaLink="false">urn:uuid:60181c12-3ed0-4519-8c5c-ec28e74d037f</guid>
      <author>h3rald@h3rald.com (Fabio Cevasco)</author>
      <comments>http://www.h3rald.com/articles/log-jun-2009#comments</comments>
      <category>Blog</category>
      <category>personal_log</category>
      <category>vim</category>
      <category>ruby</category>
      <category>wedding</category>
      <trackback:ping>http://www.h3rald.com/trackbacks?content=articles&amp;permalink=log-jun-2009</trackback:ping>
      <link>http://www.h3rald.com/articles/log-jun-2009</link>
    </item>
    <item>
      <title>Herald (Vim Color Scheme)</title>
      <description>&lt;p&gt;I use &lt;a href="http://www.vim.org"&gt;Vim&lt;/a&gt; a lot. It&amp;#8217;s my editor of choice when I code (mainly in Ruby), and also when I write my blog post and articles (mainly in Textile).
One thing I always liked about Vim was it powerful syntax highlighting: there&amp;#8217;s probably a syntax highlighting file for every programming language ever created, even the new ones (&lt;a href="http://force7.de/nimrod/index.html"&gt;Nimrod&lt;/a&gt;? Sure, &lt;a href="http://www.vim.org/scripts/script.php?script_id=2632"&gt;here&lt;/a&gt;!).&lt;/p&gt;


	&lt;p&gt;Furthermore, Vim allows you to create color schemes, and that&amp;#8217;s surprisingly easy to do. Everything you need to do is in the &lt;a href="http://vimdoc.sourceforge.net/htmldoc/syntax.html"&gt;docs&lt;/a&gt;, but that may put you off, so you can just start by editing an existing one&amp;#8212;that&amp;#8217;s what I did.&lt;/p&gt;


	&lt;h3&gt;InfiniteRed Black&lt;/h3&gt;


	&lt;p&gt;I&amp;#8217;ve been using the &lt;a href="http://blog.infinitered.com/entries/show/8"&gt;ir_black&lt;/a&gt; color scheme for near enough a year. It&amp;#8217;s an excellent color scheme, recommended especially for writing Ruby code:&lt;/p&gt;


	&lt;p style="float:center"&gt;&lt;img src="/images/herald.vim/ir_black_vim_example.png" alt="" /&gt;&lt;/p&gt;


	&lt;p&gt;I honestly thought this was the best Vim color scheme until I discovered Moria&amp;#8230;&lt;/p&gt;


	&lt;h3&gt;Moria&lt;/h3&gt;


	&lt;p&gt;Recently I switched to &lt;a href="http://www.vim.org/scripts/script.php?script_id=1464"&gt;moria&lt;/a&gt;, mainly because I find it easier on the eyes. It&amp;#8217;s a matter of taste, of course:&lt;/p&gt;


	&lt;p style="float:center"&gt;&lt;img src="/images/herald.vim/moria_vim_example.png" alt="" /&gt;&lt;/p&gt;


	&lt;p&gt;The trick is in the background: it&amp;#8217;s not completely black. Still, I didn&amp;#8217;t quite like the colors, so I decided to write my own&amp;#8230;&lt;/p&gt;


	&lt;h3&gt;Herald&lt;/h3&gt;


	&lt;p&gt;Meet &lt;strong&gt; &lt;a href="/files/herald.vim"&gt;herald.vim&lt;/a&gt; &lt;/strong&gt; (this is a direct link to the raw file, but you may also want to check my &lt;a href="http://github.com/h3rald/stash/tree/master"&gt;stash&lt;/a&gt; on GitHub or the &lt;a href="http://www.vim.org/scripts/script.php?script_id=2684"&gt;script page&lt;/a&gt; on Vim.org):&lt;/p&gt;


	&lt;p style="float:center"&gt;&lt;img src="/images/herald.vim/herald_vim_example.png" alt="" /&gt;&lt;/p&gt;


To sum up, here&amp;#8217;s the &lt;em&gt;features&lt;/em&gt; offered by this new color scheme:
	&lt;ul&gt;
	&lt;li&gt;It&amp;#8217;s easier to differentiate syntax elements; in particular reserved words like &lt;code&gt;if&lt;/code&gt; or &lt;code&gt;end&lt;/code&gt;, constants (symbols) and identifiers (instance variables).&lt;/li&gt;
		&lt;li&gt;Operators are highlighted and easier to notice.&lt;/li&gt;
		&lt;li&gt;Dark gray background and black column/row selectors.&lt;/li&gt;
		&lt;li&gt;Added highlight for titles (useful for Textile)&lt;/li&gt;
		&lt;li&gt;Comments do not stand out, unlike in most color schemes&lt;/li&gt;
		&lt;li&gt;Support for 256 color terminal (special thanks to &lt;a href="http://www.frexx.de/xterm-256-notes/"&gt;Wolfgang Frisch&lt;/a&gt; for providing all the info and tools required)&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;So what do you think? Is it tool colorful perhaps? How would &lt;strong&gt;you&lt;/strong&gt; improve it?&lt;/p&gt;</description>
      <pubDate>Wed, 17 Jun 2009 06:11:00 -0000</pubDate>
      <guid isPermaLink="false">urn:uuid:a0718d6a-2e70-451a-bb3c-3c44dbc89f5f</guid>
      <author>h3rald@h3rald.com (Fabio Cevasco)</author>
      <comments>http://www.h3rald.com/articles/herald-vim-color-scheme#comments</comments>
      <category>Blog</category>
      <category>programming</category>
      <category>vim</category>
      <trackback:ping>http://www.h3rald.com/trackbacks?content=articles&amp;permalink=herald-vim-color-scheme</trackback:ping>
      <link>http://www.h3rald.com/articles/herald-vim-color-scheme</link>
    </item>
    <item>
      <title>Personal Log - May 2009</title>
      <description>&lt;p&gt;Yet another extremely busy month, as you can see from the total absence of blog posts and lack of tweets even. Things are getting pretty hectic at work now I guess: less people, more work, more responsibility, same money. They call it &lt;cite&gt;contingency&lt;/cite&gt;; it&amp;#8217;s the latest trend in the Western World, didn&amp;#8217;t you know? I&amp;#8217;m really not impressed. I can&amp;#8217;t complain though I guess: I still enjoy my job very much and I know it could be much worse, so it&amp;#8217;s just a matter of enduring until autumn&amp;#8212;or so they say.&lt;/p&gt;


	&lt;h3&gt;Star Trek Premiere&lt;/h3&gt;


	&lt;p&gt;The month started with an event I&amp;#8217;d been looking for for months: the &lt;em&gt;premiere&lt;/em&gt; of Star Trek XI, aka &amp;#8220;Star Trek&amp;#8221;. It&amp;#8217;s not that J.J. Abrahms couldn&amp;#8217;t come up with a more original name (&lt;em&gt;Star Trek: Academy&lt;/em&gt; used to be the working title, at one point), he simply wanted to tell the world that this movie was a new beginning, an elaborate way to start from scratch, to reboot what was more than once dubbed &lt;em&gt;a dying franchise&lt;/em&gt;.&lt;/p&gt;


	&lt;p&gt;The movie was enjoyable &amp;#8211; daring and a bit flamboyant &amp;#8211; but still enjoyable nonetheless. I consider myself a Star Trek fan, and although it was &lt;em&gt;not&lt;/em&gt; the usual Star Trek movie, I somehow liked Abrahms&amp;#8217; bold revisitation of Roddenberry&amp;#8217;s universe. Take a bunch of unknowns (Chris Pine) or semi-unknowns (Zachary Quinto), then add some spicy British humor (Simon Pegg) and some old friend (Leonard Nimoy) and throw in an awful lot of &lt;span class="caps"&gt;XXI&lt;/span&gt; century special effects: what you get is not the usual, let&amp;#8217;s-all-rock-because-we&amp;#8217;re-hit traditional Star Trek, of course, it&amp;#8217;s an &lt;em&gt;alternate&lt;/em&gt; version of it.&lt;/p&gt;


	&lt;p&gt;That&amp;#8217;s precisely what the movie is meant to be: what Star Trek would have look like if it had been created in the &lt;span class="caps"&gt;XXI&lt;/span&gt; century. The timeline feels disrupted since the very first minute (nevermind the end!), with a Jim Kirk stealing his stepfather&amp;#8217;s car. Chris Pine is an [&lt;a href="http://memory-alpha.org/en/wiki/James_T._Kirk_(alternate_reality"&gt;alternate&lt;/a&gt;)] Kirk, quite different from the original one, but not that bad. Zachary Quinto, on the other hand, is a true revelation: he definitely is the new Spock, and he couldn&amp;#8217;t have been cast better. So is Simon Pegg as Scotty, but unfortunately he&amp;#8217;s not involved enough.&lt;/p&gt;


	&lt;p&gt;The baddies were a bit of a letdown. Nero is a bit too flat, and his ship is way too fancy, no matter where it comes from. Clearly some Hollywood junkie wanted a big, invulnerable dark ship to bring havoc in the galaxy, but that is &lt;span class="caps"&gt;NOT&lt;/span&gt; a Romulan ship, period.&lt;/p&gt;


	&lt;p&gt;At any rate, I enjoyed the movie and I&amp;#8217;m looking forward to the second one, which I hope it will be followed by many others.&lt;/p&gt;


	&lt;p&gt;Unfortunately in Italy Star Trek is not worshiped in Italy as in it is the US, which is very unfortunate&amp;#8230; Roxanne and I decided to play along and go to the cinema half-dressed-up, but our friends Elora and Michelle came with a full-blown Uhura uniform! The whole cinema kept staring at us. It was a bit freaky, but fun (check out the pics on Facebook&amp;#8212;if you can, that is, I won&amp;#8217;t post them here!).&lt;/p&gt;


	&lt;h3&gt;Wedding Planning&lt;/h3&gt;


Just over a month to my wedding. Scared? You bet. Stressed out? Indeed. Roxanne and I managed to get most of the things organized in the end, luckily. In particular, this month:
	&lt;ul&gt;
	&lt;li&gt;We went to the British Consulate in Milan, and applied to get Roxanne&amp;#8217;s legal documents.&lt;/li&gt;
		&lt;li&gt;I bought and had the 7 vest sets delivered to Roxanne&amp;#8217;s brother&amp;#8217;s (Caspar) place, in London.&lt;/li&gt;
		&lt;li&gt;I ended up buying 8 (buy three, get one free) morning suits from &lt;a href="http://www.marksandspencer.com/gp/product/B000N65ELG?extid=pg_msf&amp;#38;247SEM"&gt;Marks and Spencer&lt;/a&gt;, and had them delivered to Caspar&amp;#8217;s place. He&amp;#8217;ll be sending all the stuff over soon, hopefully.&lt;/li&gt;
		&lt;li&gt;Roxanne got the dresses for the maids of honor, and apparently we have to collect them on monday.&lt;/li&gt;
		&lt;li&gt;We sent all the invites we needed to send, but we&amp;#8217;re still waiting for confirmations. It looks like it won&amp;#8217;t be a big wedding, probably around to 60-70 people mark.&lt;/li&gt;
		&lt;li&gt;We ordered the &lt;a href="http://weddings.about.com/cs/glossary/g/Bomboniere.htm"&gt;bomboniere&lt;/a&gt;, they should come through soon.&lt;/li&gt;
		&lt;li&gt;Uncle John told us he had the music for the church and the reception sorted out.&lt;/li&gt;
		&lt;li&gt;We got the rings!&lt;/li&gt;
	&lt;/ul&gt;


We &lt;em&gt;still&lt;/em&gt; have to organize a few things, namely:
	&lt;ul&gt;
	&lt;li&gt;Write and print the prayer books&lt;/li&gt;
		&lt;li&gt;Book the flight for one of my ushers&lt;/li&gt;
		&lt;li&gt;Get some fancy gifts for the bestman and the rest of the people involved in the ceremony&lt;/li&gt;
		&lt;li&gt;Get married civilly here in Genoa&lt;/li&gt;
		&lt;li&gt;Organize a party at our place for the people who can&amp;#8217;t come to the wedding&lt;/li&gt;
		&lt;li&gt;Do something else I can&amp;#8217;t remember right now&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Yes, we are still busy as hell. I&amp;#8217;m looking forward to it all, but I&amp;#8217;ll definitely be much more relaxed when it&amp;#8217;s all over!&lt;/p&gt;


	&lt;h3&gt;Home Internet: Epilogue?&lt;/h3&gt;


I got broadband at home, finally, after five months. Let&amp;#8217;s do a quick recap:
	&lt;ol&gt;
	&lt;li&gt;Last December I signed up to Libero Infostrada, and told them I wanted to disconnect from Telecom&lt;/li&gt;
		&lt;li&gt;In January I actually got disconnected from Telecom, got a new phone line contract, but the Internet was never activated.&lt;/li&gt;
		&lt;li&gt;I kept calling clueless operators on both ends pointlessly for 2-3 months.&lt;/li&gt;
		&lt;li&gt;I got pissed off with Libero, so in April I signed up to Tele2, telling them to disconnect me from Libero. They told me it would take at least 4 weeks.&lt;/li&gt;
		&lt;li&gt;Meanwhile, I signed up to 3g, and got an Internet &lt;span class="caps"&gt;USB&lt;/span&gt; key. At least I can go online, even if with a crappy &lt;span class="caps"&gt;UMTS&lt;/span&gt; connection.&lt;/li&gt;
		&lt;li&gt;After a month, Telecom rings me asking if I want to come back to them, promising I&amp;#8217;ll have the Internet back on &lt;em&gt;soon enough&lt;/em&gt;. Out of desperation, I accept and tell them to disconnect me from Tele2.&lt;/li&gt;
	&lt;/ol&gt;


	&lt;p&gt;Just when I was about to write a long post cursing Telecom and their perverted schemes to force their customers to stay with them, I receive a call from Libero and they tell me that the Internet is now activated! Unbelievable. Now all I have to do is send letters to all the other ISPs (they don&amp;#8217;t do these things on the phone&amp;#8212;clueless operators, remember?) telling them I don&amp;#8217;t want anything to do with them anymore.&lt;/p&gt;


	&lt;p&gt;This is how broadband Internet works in Italy. Jealous?&lt;/p&gt;


	&lt;h3&gt;Nimrod&lt;/h3&gt;


	&lt;p&gt;Last month I decided I would stop programming until after the wedding and so I did (at least at home). Nevertheless, I still keep strive to keep up-to-date with everything concerning technology and in particular programming.&lt;/p&gt;


	&lt;p&gt;Out of all the tech news I came across throughout this month, the &lt;a href="http://force7.de/nimrod/"&gt;Nimrod&lt;/a&gt; programming language definitely struck me the most. A German guy came up with a new language&amp;#8212;that&amp;#8217;s not a big news, new programming languages are born every week, if not every day.&lt;/p&gt;


I believe Nimrod is different though. Basically, here&amp;#8217;s why:
	&lt;ul&gt;
	&lt;li&gt;It&amp;#8217;s a mixture of Lisp, Python and C. It looks a bit like Python and it behaves like it (indentation matters), it allows the creation of macros, like in Lisp, and &amp;#8211; this is what &lt;em&gt;really&lt;/em&gt; matters to me &amp;#8211; it compiles to plain C (which can then be compiled using &lt;span class="caps"&gt;GCC&lt;/span&gt; or whatever).&lt;/li&gt;
		&lt;li&gt;It is open source and can be used to produce commercially distributed executables.&lt;/li&gt;
		&lt;li&gt;The &lt;a href="http://force7.de/nimrod/manual.html"&gt;manual&lt;/a&gt; is simple to read (but with a few rough edges), and the language looks simple to learn. &lt;/li&gt;
		&lt;li&gt;The language is not yet complete, but it&amp;#8217;s getting close to a 1.0 release. It works as advertised, nonetheless.&lt;/li&gt;
		&lt;li&gt;It offers a comprehensive standard library, and a &lt;em&gt;huge&lt;/em&gt; amount of libraries and wrappers from everything from Windows &lt;span class="caps"&gt;API&lt;/span&gt; to &lt;span class="caps"&gt;GTK&lt;/span&gt; and Cairo.&lt;/li&gt;
		&lt;li&gt;It is cross platform, the Windows version even comes with a one-click installer.&lt;/li&gt;
		&lt;li&gt;It has garbage collection &lt;em&gt;and&lt;/em&gt; it supports manual memory management, if you need it.&lt;/li&gt;
		&lt;li&gt;It&amp;#8217;s statically typed, with type inference&lt;/li&gt;
		&lt;li&gt;It can generate standalone executables, with very little overhead (90KB for an hello world program).&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;A language like this has been my secret dream for a long time. I thought no one would ever come up like this. I am really looking forward to give it a proper try someday. What&amp;#8217;s wrong with it? For now, a few bits are missing (like native serialization), other than that someone pointed out the weird, rather extreme case insensitiveness of the language. Basically, case &lt;em&gt;and underscores&lt;/em&gt; are ignored to &lt;cite&gt;allow programmers to use their own programming conventions&lt;/cite&gt;. 
Personally I don&amp;#8217;t think this is that bad. After all, if you name your variables &amp;#8220;a_thing&amp;#8221; and &amp;#8220;aThing&amp;#8221; and you want them to mean different things, that&amp;#8217;s bad programming style anyway. Nevertheless, as far as I know it&amp;#8217;s the only language I know which offers such an extreme degree of flexibility in this sense.&lt;/p&gt;


	&lt;h3&gt;Learning new things&lt;/h3&gt;


This month I also found myself to be extremely eager to learn about new things. I&amp;#8217;m still faithful to Ruby and all that, but I&amp;#8217;m opening up to new possibility, for different things:
	&lt;ul&gt;
	&lt;li&gt;I decided to start listening to slightly more technical podcasts, which are _not_related to tech news. In this way, I don&amp;#8217;t have the pressure of having to listen to them on a regular basis. Other than &lt;a href="http://twit.tv/FLOSS"&gt;&lt;span class="caps"&gt;FLOSS&lt;/span&gt; Weekly&lt;/a&gt;, which is probably the best show about Open Source Software out there, I&amp;#8217;m going to try out &lt;a href="http://www.se-radio.net/"&gt;Software Engineering Radio&lt;/a&gt; and &lt;a href="http://thecommandline.net/"&gt;The Command Line&lt;/a&gt;, both slightly more technical.&lt;/li&gt;
		&lt;li&gt;Because I decided to put my personal programming projects on hold, I&amp;#8217;m having all sort of new ideas about even &lt;em&gt;more&lt;/em&gt; projects I could start as soon as I can. No anticipations until after my wedding, of course.&lt;/li&gt;
		&lt;li&gt;I&amp;#8217;m using Vim all the time now, both at work and at home. I feel confident with it, but I feel I still have a lot to learn, especially when it comes to marks, registers, etc. And I&amp;#8217;m not yet ready to write an article about it&amp;#8212;not the kind of article I&amp;#8217;d like to write, anyway.&lt;/li&gt;
		&lt;li&gt;I&amp;#8217;d like to learn more about Javascript and JQuery. I played around with it and &lt;em&gt;loved it&lt;/em&gt;, but I really never used it for anything serious yet. This, however, may change in the future.&lt;/li&gt;
	&lt;/ul&gt;</description>
      <pubDate>Sun, 31 May 2009 06:35:00 -0000</pubDate>
      <guid isPermaLink="false">urn:uuid:f2df4c22-5b2a-4e3f-b6b9-26c907168e23</guid>
      <author>h3rald@h3rald.com (Fabio Cevasco)</author>
      <comments>http://www.h3rald.com/articles/log-may-2009#comments</comments>
      <category>Blog</category>
      <category>personal_log</category>
      <category>programming</category>
      <category>wedding</category>
      <trackback:ping>http://www.h3rald.com/trackbacks?content=articles&amp;permalink=log-may-2009</trackback:ping>
      <link>http://www.h3rald.com/articles/log-may-2009</link>
    </item>
    <item>
      <title>Personal Log - April 2009</title>
      <description>&lt;p&gt;April is tratidionally a rather busy month: Easter, public holidays, and &amp;mdash; always &amp;mdash; some deadline to meet at work. Moreover, my birthday is also in April which makes it even more busy! Let&amp;#8217;s see what happened this year&amp;#8230;&lt;/p&gt;


	&lt;h3&gt;Using Ruby in a corporate environment&lt;/h3&gt;


	&lt;p&gt;I&amp;#8217;ve been using Ruby at work for a while now. I started off writing some automation script for my own needs, then someone noticed it and asked me if by chance I could develop some scripts for them, for automating part of their own job, and so on. My boss ultimately noticed it, and she liked the idea of me investing a small portion of my time to make other people save huge amount of &lt;em&gt;their&lt;/em&gt; time, so now I am &lt;em&gt;officially&lt;/em&gt; in charge of workflow improvements and automation (it&amp;#8217;s even in my job description!).&lt;/p&gt;


	&lt;p&gt;This month a colleague of mine and I had to figure out a way to write some documents &lt;strong&gt;once&lt;/strong&gt; in &lt;span class="caps"&gt;XML&lt;/span&gt; format and then produce different kind of outputs (other &lt;span class="caps"&gt;XML&lt;/span&gt; files, PDFs, etc.) using the &lt;a href="http://dita-ot.sourceforge.net/"&gt;&lt;span class="caps"&gt;DITA&lt;/span&gt; Open Toolkit&lt;/a&gt;. Originally we thought the toolkit would do most of the job, but we soon realized we needed to tweak and change a lot more than what we usually expected.&lt;/p&gt;


	&lt;p&gt;We ended up hacking together a &lt;em&gt;system&lt;/em&gt; using:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;&lt;a href="http://office.microsoft.com/en-us/infopath/default.aspx"&gt;Microsoft Infopath&lt;/a&gt; as &lt;span class="caps"&gt;XML&lt;/span&gt; editor for the end users (the company buys it by default, so no worries there)&lt;/li&gt;
		&lt;li&gt;A Ruby program to parse and manipulate the original &lt;span class="caps"&gt;XML&lt;/span&gt; and produce &lt;span class="caps"&gt;DITA&lt;/span&gt;-compatible &lt;span class="caps"&gt;XML&lt;/span&gt; files.&lt;/li&gt;
		&lt;li&gt;Some &lt;a href="http://ant.apache.org/"&gt;Apache Ant&lt;/a&gt; tasks available in the open toolkit to produce an &lt;span class="caps"&gt;XSL&lt;/span&gt;-FO file&lt;/li&gt;
		&lt;li&gt;&lt;a href="http://xmlgraphics.apache.org/fop/"&gt;Apache &lt;span class="caps"&gt;FOP&lt;/span&gt;&lt;/a&gt; to produce the &lt;span class="caps"&gt;PDF&lt;/span&gt; from the &lt;span class="caps"&gt;XSL&lt;/span&gt;-FO file&amp;#8230;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;The thing seems to work fine (after a lot of tweaking), and I really enjoyed creating the Ruby program to &lt;em&gt;glue&lt;/em&gt; everything together. I even got a chance to introduce my colleagues to the wonderful world of &lt;a href="http://hobix.com/textile/"&gt;Textile&lt;/a&gt; (they are so happy that they don&amp;#8217;t want to use &lt;span class="caps"&gt;WYSIWYG&lt;/span&gt; editors anymore!).&lt;/p&gt;


	&lt;h3&gt;Easter in London&lt;/h3&gt;


	&lt;p&gt;As usual, Roxanne and I spent our Easter holidays in London, at her brother&amp;#8217;s place. This year we actually had 9 days to go around &lt;del&gt;squandering money&lt;/del&gt;  spending &lt;em&gt;wisely&lt;/em&gt; in food, books, clothes and entertainment.&lt;/p&gt;


	&lt;p&gt;Most notably, I managed to drag Roxanne to &lt;a href="http://www.foyles.co.uk/"&gt;Foyles&lt;/a&gt; and I got myself a copy of &lt;a href="http://www.pragprog.com/the-pragmatic-programmer"&gt;The Pragmatic Programmer&lt;/a&gt;, which I&amp;#8217;m reading avidly. If it was up to me I was going to buy half of the computing section, but Roxanne &lt;em&gt;kindly pointed out&lt;/em&gt; that I could get all of them from Amazon for half the price. 
And she was right: for my birthday I preordered a copy of &lt;a href="http://www.amazon.com/Programming-Language-Pragmatics-Third-Michael/dp/0123745144"&gt;Programming Language Pragmatics, 3rd Ed.&lt;/a&gt;, which should be shipped soon.&lt;/p&gt;


	&lt;h3&gt;Wedding planning&lt;/h3&gt;


	&lt;p&gt;My spreadsheets for the wedding guests, wedding expenses (!) and &amp;#8230;suit sizes are getting bigger and bigger. We managed to book a lot of flights to Ireland to my parents, us, relatives etc., but there are still quite a few things to do for the wedding. The most urgent thing to do right now is sending the invites: we had them printed with the words &lt;em&gt;&lt;span class="caps"&gt;RSVP&lt;/span&gt; within May&lt;/em&gt; on them, so they &lt;em&gt;have&lt;/em&gt; to be out in one or two weeks at most.&lt;/p&gt;


	&lt;p&gt;The other thing which must be sorted soon are the suits. According to English (and Irish) tradition, the groom, the bestman, the father of the groom, the father  of the bride and the ushers have to wear the same type of suit, with minor differences (the color of the waistcoats?). In my case, this means getting 7 (SEVEN) &lt;em&gt;morning suits&lt;/em&gt; off eBay, in the right sizes! Hopefully I&amp;#8217;ll be able to get them by the end of next week (if my bestman manages to let me know his sizes).&lt;/p&gt;


	&lt;h3&gt;XBox 360 Gaming&lt;/h3&gt;


	&lt;p&gt;Now that our new XBox 360 finally came through, Roxanne and I have a lot of hours of hard core week end gaming ahead of us! This, added to the physiological increase of stress due to the wedding, may result in a temporary slowdown of my coding and writing activities.
Right now we&amp;#8217;re playing &lt;a href="http://xbox360.ign.com/objects/949/949455.html"&gt;Mirror&amp;#8217;s Edge&lt;/a&gt;, &lt;a href="http://xbox360.ign.com/objects/718/718963.html"&gt;Mass Effect&lt;/a&gt;, and &lt;a href="http://xbox360.ign.com/objects/746/746631.html"&gt;Unreal Tournment &lt;span class="caps"&gt;III&lt;/span&gt;&lt;/a&gt;. The last one was a special surprise present from Roxanne (&lt;em&gt;&amp;#8221;&amp;#8230;so we can kill each other!&amp;#8221;&lt;/em&gt; &amp;mdash; she&amp;#8217;s really lovely at times!).&lt;/p&gt;


	&lt;h3&gt;Other tech-related tidbits&lt;/h3&gt;


	&lt;ul&gt;
	&lt;li&gt;I can&amp;#8217;t wait to go to the cinema to watch &lt;a href="http://www.imdb.com/title/tt0796366/"&gt;Star Trek XI&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;I started using &lt;a href="http://www.shelfari.com/"&gt;Shelfari&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;I started using &lt;a href="http://start.io"&gt;Star.io&lt;/a&gt; as my personal, bare-bones start page.&lt;/li&gt;
		&lt;li&gt;I recently &lt;a href="http://www.h3rald.com/articles/concatenative-020"&gt;released Concatenative 0.2.0&lt;/a&gt;.&lt;/li&gt;
		&lt;li&gt;I&amp;#8217;m currently evaluating the possibility to create a Ruby-based &lt;em&gt;Document Authoring Framework&lt;/em&gt;. Stay tuned.&lt;/li&gt;
	&lt;/ul&gt;</description>
      <pubDate>Tue, 28 Apr 2009 06:11:00 -0000</pubDate>
      <guid isPermaLink="false">urn:uuid:e2ecc3ac-0afd-4d18-b7cc-d2c64944a108</guid>
      <author>h3rald@h3rald.com (Fabio Cevasco)</author>
      <comments>http://www.h3rald.com/articles/log-apr-2009#comments</comments>
      <category>Blog</category>
      <category>personal_log</category>
      <category>ruby</category>
      <category>books</category>
      <category>wedding</category>
      <trackback:ping>http://www.h3rald.com/trackbacks?content=articles&amp;permalink=log-apr-2009</trackback:ping>
      <link>http://www.h3rald.com/articles/log-apr-2009</link>
    </item>
    <item>
      <title>Holiday house for rent</title>
      <description>&lt;p&gt;&lt;img src="/images/sessarego/outside.jpg" style="float:left; border: 1px solid #B80000; margin-right: 10px;" /&gt;&lt;/p&gt;


	&lt;p&gt;Part of my family house in the countryside is now available for rent! It&amp;#8217;s located in the small village of &lt;a href="http://italia.indettaglio.it/eng/liguria/genova_bogliasco_sessarego.html"&gt;Sessarego&lt;/a&gt;, a few minutes away from the coast, on the Italian Riviera.
We&amp;#8217;ve been living there recently for 6 months when I started working and then moved to the city in order to be nearer to my workplace, but we still go there on holidays or on the odd week end, sometimes.&lt;/p&gt;


	&lt;p&gt;The house is fully furnished, it has been recently renovated, and offers all major comforts and services (utilities, TV, internet, phone, etc.). It can be ideal as a holiday house for writers, programmers, or anyone who would like to take a break from the chaotic city life without giving up all the commodities of modern life, such as the Internet.&lt;/p&gt;


&lt;div style="padding: 30px"&gt;&lt;/div&gt;

	&lt;p&gt;&lt;strong&gt;For more information, see &lt;a href="/holidays"&gt;this page&lt;/a&gt; and feel free to &lt;a href="/about"&gt;contact me&lt;/a&gt; if you want to book your stay or you needmore details!&lt;/strong&gt;&lt;/p&gt;</description>
      <pubDate>Fri, 24 Apr 2009 01:54:00 -0000</pubDate>
      <guid isPermaLink="false">urn:uuid:cbe34626-16fc-4269-b3dc-c02a5939d86a</guid>
      <author>h3rald@h3rald.com (Fabio Cevasco)</author>
      <comments>http://www.h3rald.com/articles/holiday-house-for-rent#comments</comments>
      <category>Blog</category>
      <category>personal</category>
      <trackback:ping>http://www.h3rald.com/trackbacks?content=articles&amp;permalink=holiday-house-for-rent</trackback:ping>
      <link>http://www.h3rald.com/articles/holiday-house-for-rent</link>
    </item>
    <item>
      <title>Concatenative 0.2.0 released</title>
      <description>&lt;p&gt;Version 0.2.0. of the &lt;a href="/concatenative"&gt;Concatenative&lt;/a&gt; DSL has been &lt;a href="http://rubyforge.org/frs/?group_id=8068&amp;#38;release_id=33575"&gt;released&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;Here are some highlights from the changelog:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;Implemented new combinators:
	&lt;ul&gt;
	&lt;li&gt;binrec&lt;/li&gt;
		&lt;li&gt;split&lt;/li&gt;
		&lt;li&gt;twodip&lt;/li&gt;
		&lt;li&gt;threedip&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
		&lt;li&gt;Performance improvements:
	&lt;ul&gt;
	&lt;li&gt;Stack is never copied.&lt;/li&gt;
		&lt;li&gt;No symbol/string conversion when processing words.&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
		&lt;li&gt;Pseudo-namespace support (e.g. :kernel/:while and :math/:factorial)&lt;/li&gt;
		&lt;li&gt;~ and &amp;lt;= operators to unquote and define words, respectively.&lt;/li&gt;
		&lt;li&gt;No more uppercase words!&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Oddly enough, I realized that it is possible to defined methods named after reserved words like &amp;#8220;while&amp;#8221; or &amp;#8220;if&amp;#8221;, so now all the concatenative words (combinators) in &lt;code&gt;kernel.rb&lt;/code&gt; are now defined &lt;em&gt;without&lt;/em&gt; a leading undersore. Similarly, there&amp;#8217;s no real need to use &lt;span class="caps"&gt;UPPERCASE&lt;/span&gt; symbols, so as a result, method lookup is significantly faster and will use less resources.&lt;/p&gt;


	&lt;p&gt;Here&amp;#8217;s how the lookup works. Say you have the following program:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="punct"&gt;[[&lt;/span&gt;&lt;span class="number"&gt;1&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt;&lt;span class="number"&gt;2&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt;&lt;span class="number"&gt;3&lt;/span&gt;&lt;span class="punct"&gt;],&lt;/span&gt; &lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="number"&gt;4.5&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="number"&gt;6&lt;/span&gt;&lt;span class="punct"&gt;],&lt;/span&gt; &lt;span class="symbol"&gt;:concat&lt;/span&gt;&lt;span class="punct"&gt;]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;If &lt;code&gt;:concat&lt;/code&gt; has been defined by the user (&lt;code&gt;:concat &amp;lt;= [...]&lt;/code&gt;), that definition will be used, otherwise the &lt;code&gt;Concatenative::Kernel&lt;/code&gt; combinator &lt;code&gt;concat&lt;/code&gt; will be called. If you want to use the corresponding Ruby method, all you have to do is specifying the arity explicitly using the &lt;code&gt;|&lt;/code&gt; operator.&lt;/p&gt;


	&lt;p&gt;To remove any ambiguity, it is now possible to specify the &lt;em&gt;namespace&lt;/em&gt; of a word explicitly, e.g. :kernel/:concat or :ruby/concat. The &lt;code&gt;/&lt;/code&gt; operator simply concatenates the two symbols together (&lt;code&gt;:"kernel/concat"&lt;/code&gt;) and sets the namespace (&lt;code&gt;:kernel&lt;/code&gt;) and name (&lt;code&gt;:concat&lt;/code&gt;) of the new symbol. &lt;code&gt;:kernel&lt;/code&gt; and &lt;code&gt;:ruby&lt;/code&gt; are not meant to be used when defining new words, but you can use anything else you like, for example :math/:factorial or :local/:a, etc.&lt;/p&gt;


	&lt;p&gt;As I pointed out in the &lt;a href="/articles/concatenative-programming-in-ruby"&gt;first article&lt;/a&gt; about concatenative, even with the new performance improvement a concatenative program still runs slower than a standard Ruby program, but at least now you won&amp;#8217;t run out of stack space (the &lt;em&gt;Ruby&lt;/em&gt; stack, in this case) too soon.&lt;/p&gt;


	&lt;p&gt;If you have any issues to report, feature requests, etc., feel free to use &lt;a href="http://github.com/h3rald/concatenative/issues"&gt;GitHub&lt;/a&gt; to do so.&lt;/p&gt;</description>
      <pubDate>Sun, 19 Apr 2009 09:42:00 -0000</pubDate>
      <guid isPermaLink="false">urn:uuid:5406217b-f4f3-4417-b82d-38f5a34d88a6</guid>
      <author>h3rald@h3rald.com (Fabio Cevasco)</author>
      <comments>http://www.h3rald.com/articles/concatenative-020#comments</comments>
      <category>Articles</category>
      <category>ruby</category>
      <category>concatenative</category>
      <trackback:ping>http://www.h3rald.com/trackbacks?content=articles&amp;permalink=concatenative-020</trackback:ping>
      <link>http://www.h3rald.com/articles/concatenative-020</link>
    </item>
    <item>
      <title>Personal Log - March 2009</title>
      <description>&lt;p&gt;Another month &lt;em&gt;without&lt;/em&gt; the Internet at home. This is getting really annoying, and I decided to change provider, &lt;strong&gt;again&lt;/strong&gt;, hoping that I&amp;#8217;ll eventually get my broadband back, someday. Luckily I can still go online at work, but of course it&amp;#8217;s not the same thing: my time on Twitter and Facebook is now basically limited to weekends only, when Roxanne and I go down to Tuscany to stay with her parents.&lt;/p&gt;


	&lt;h3&gt;Concatenative programming&lt;/h3&gt;


	&lt;p&gt;For some weird reason I became fond of the &lt;a href="http://en.wikipedia.org/wiki/Concatenative_programming_language"&gt;Concatenative programming paradigm&lt;/a&gt;. I started reading about &lt;a href="http://www.latrobe.edu.au/philosophy/phimvt/joy/j00rat.html"&gt;Joy&lt;/a&gt; and then started to work on a Ruby &lt;span class="caps"&gt;DSL&lt;/span&gt; able to do the similar things: &lt;a href="/concatenative/"&gt;Concatenative&lt;/a&gt;. Another pet project &amp;mdash; as if I didn&amp;#8217;t have enough things to do already!&lt;/p&gt;


	&lt;p&gt;Some people seemed pleased about it, especially on &lt;a href="http://www.reddit.com/r/ruby/comments/887kn/concatenative_programming_in_ruby"&gt;Reddit&lt;/a&gt; and &lt;a href="http://dzone.com/links/concatenative_programming_in_ruby.html"&gt;dzone&lt;/a&gt;. The downside of it is that it&amp;#8217;s still fairly slow if compared to Ruby code (which is not exactly fast, either!), so if I had some spare time I should really try to implement it as a C extension, maybe.&lt;/p&gt;


	&lt;h3&gt;Learning new programming languages?&lt;/h3&gt;


	&lt;p&gt;Incidentally, I&amp;#8217;m still fighting with myself on whether to learn another programming language or not. At this point, learning &lt;a href="http://www.factorcode.org"&gt;Factor&lt;/a&gt; could turn out to be more natural than months ago. However, I would only learn new programming languages as a hobby, as I don&amp;#8217;t need to do so for profit: luckily I&amp;#8217;m still a happy technical writer and I enjoy my job.&lt;/p&gt;


	&lt;p&gt;I admit, I&amp;#8217;m still looking for &lt;em&gt;the&lt;/em&gt; perfect programming language which is fun to learn (not easy: fun), elegant, minimalist, fast, general purpose and cross platform (meaning Linux, Windows, and Windows Mobile as well). Of course there is no such thing out there and there will never be, so I&amp;#8217;m still evaluating the current alternatives. Possible candidates are Haskell, Factor, some dialect of Lisp or C. 
Why C? Well, because I didn&amp;#8217;t do much with it since my first year at uni, and it could still be useful to write Ruby extensions or implement something at a lower level. After so much time getting spoiled by high level languages, I kinda miss the low level stuff. Ahhh where are all the pointers gone?!&lt;/p&gt;


	&lt;p&gt;On the other hand, I&amp;#8217;m getting married soon, and I should use these months to help my wife-to-be a bit more with wedding planning (see next section). After all, I can always learn a new programming language &lt;em&gt;after&lt;/em&gt; getting married, right? &amp;#8230;&lt;em&gt;right?!&lt;/em&gt;&lt;/p&gt;


	&lt;h3&gt;Wedding planning&lt;/h3&gt;


	&lt;p&gt;Roxanne and I are slowly getting more and more things done for the wedding. Every attempt I made to introduce her to &lt;a href="http://en.wikipedia.org/wiki/Getting_things_done"&gt;&lt;span class="caps"&gt;GTD&lt;/span&gt;&lt;/a&gt; failed miserably so far, or better, it worked too well: she is now getting used to make lists and deciding on our &lt;em&gt;next actions&lt;/em&gt; for the weekend. 
This weekend we booked our flights to Ireland, looked at cottages and hotels for the three days after the wedding (not the honeymoon yet, we&amp;#8217;ll have a late honeymoon in autumn), chose the waistcoats for me, my bestman and the ushers, and &amp;#8230;booked the wedding car!
Now, this turned out to be good fun! Take a look at &lt;a href="http://www.alleventslimos.com/Wedding/rolls_silver_cloud.html"&gt;Ruby&lt;/a&gt; (yes, yes, I know&amp;#8230; ), a Silver Cloud &lt;span class="caps"&gt;II 1961&lt;/span&gt; Rolls Royce which will be ours for (less than) one day!&lt;/p&gt;


	&lt;h3&gt;Other tech-related tidbits&lt;/h3&gt;


	&lt;ul&gt;
	&lt;li&gt;I successfully migrated to Ubuntu 9.0.4 Jaunty. Everything works, except the flash plugin for Firefox.&lt;/li&gt;
		&lt;li&gt;I&amp;#8217;m now using TweetDeck as my main Twitter client on both Windows and Linux.&lt;/li&gt;
		&lt;li&gt;I&amp;#8217;m thinking of buying (after the wedding) an Eee PC (no Macs: Ubuntu is sleek and powerful enough &amp;emdash;and free, too).&lt;/li&gt;
		&lt;li&gt;We finally got an XBox 360 from eBay, this time it came through the post.&lt;/li&gt;
		&lt;li&gt;Roxanne is thinking of buying a big &lt;span class="caps"&gt;LCD TV&lt;/span&gt; to go with it &amp;emdash; I&amp;#8217;m politely (and sadly) postponing till after the wedding.&lt;/li&gt;
		&lt;li&gt;After listening a &lt;span class="caps"&gt;FLOSS&lt;/span&gt; Weekly episode featuring it, I think I&amp;#8217;ll get myself an &lt;a href="http://arduino.cc/"&gt;Arduino Board&lt;/a&gt; for my birthday.&lt;/li&gt;
	&lt;/ul&gt;</description>
      <pubDate>Mon, 30 Mar 2009 06:04:00 -0000</pubDate>
      <guid isPermaLink="false">urn:uuid:e9f9cb2d-68d0-40f4-9863-d6d76fe78d98</guid>
      <author>h3rald@h3rald.com (Fabio Cevasco)</author>
      <comments>http://www.h3rald.com/articles/log-mar-2009#comments</comments>
      <category>personal_log</category>
      <category>wedding</category>
      <category>ruby</category>
      <trackback:ping>http://www.h3rald.com/trackbacks?content=articles&amp;permalink=log-mar-2009</trackback:ping>
      <link>http://www.h3rald.com/articles/log-mar-2009</link>
    </item>
    <item>
      <title>Concatenative programming in Ruby</title>
      <description>&lt;p&gt;A while ago, I sat down examining a few &lt;a href="http://www.h3rald.com/articles/10-programming-languages"&gt;alternative programming languages&lt;/a&gt; I might decide to learn someday. Each of those languages has its own peculiarities, and I didn&amp;#8217;t choose them randomly, I chose them based on their popularity, power, paradigm and how actively they are developed.&lt;/p&gt;


	&lt;p&gt;I included &lt;a href="http://factorcode.org/"&gt;Factor&lt;/a&gt; as the only representative for &lt;em&gt;concatenative programming&lt;/em&gt;, an interesting way to write programs, but seldom used in &amp;#8220;recent&amp;#8221; languages (except for Factor and a few others).&lt;/p&gt;


	&lt;h3&gt;The Joy of concatenative programming&lt;/h3&gt;


	&lt;p&gt;If you have absolutely no clue on what I&amp;#8217;m talking about, you should consider looking at the home page for the &lt;a href="http://www.latrobe.edu.au/philosophy/phimvt/joy.html"&gt;Joy Programming Language&lt;/a&gt;, or maybe just the &lt;a href="http://www.latrobe.edu.au/philosophy/phimvt/joy/j00ovr.html"&gt;overview&lt;/a&gt;: it should be enough to tikle your curiosity.&lt;/p&gt;


	&lt;p&gt;Joy is often considered the &lt;em&gt;canonical&lt;/em&gt; concatenative programming language: a basic &amp;mdash;but working&amp;mdash; implementation of a simple programming language to illustrate the fundamentals of concatenative programming. Joy looks like this:&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;2  3  +  dup  *&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;This simple programs computes the sum of 2 and 3, pushes it on the stack, duplicates it (using the &lt;code&gt;dup&lt;/code&gt; combinator) and then multiplies the two values, obtaining 25 as a result.&lt;/p&gt;


	&lt;p&gt;Let&amp;#8217;s slow down a second. Here&amp;#8217;s what happens, exactly:&lt;/p&gt;


	&lt;table&gt;
		&lt;tr&gt;
			&lt;th&gt;Element entered &lt;/th&gt;
			&lt;th&gt;Stack contents&lt;/th&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; 2 &lt;/td&gt;
			&lt;td&gt; [2] &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; 3 &lt;/td&gt;
			&lt;td&gt; [2 3] &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; + &lt;/td&gt;
			&lt;td&gt; [5] &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; dup &lt;/td&gt;
			&lt;td&gt; [5 5] &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; * &lt;/td&gt;
			&lt;td&gt; [25] &lt;/td&gt;
		&lt;/tr&gt;
	&lt;/table&gt;




	&lt;p&gt;Got it? Let&amp;#8217;s take it one step further. When you enter &lt;code&gt;dup&lt;/code&gt; and then &lt;code&gt;*&lt;/code&gt;, you are effectively computing the square of a number, so we can define the function &lt;code&gt;square&lt;/code&gt; simply as:&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;square == dup *&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;In Ruby, this would be:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;square&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;x&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;
  &lt;span class="ident"&gt;x&lt;/span&gt;&lt;span class="punct"&gt;*&lt;/span&gt;&lt;span class="ident"&gt;x&lt;/span&gt;
&lt;span class="keyword"&gt;end&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;What&amp;#8217;s unusual here? &amp;mdash; Simple, there are no &lt;em&gt;variables&lt;/em&gt; involved. Joy doesn&amp;#8217;t need any explicit variable or &lt;em&gt;formal parameters&lt;/em&gt; of any sort.&lt;/p&gt;


	&lt;p&gt;There&amp;#8217;s more. Take the following code:&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;[1 2 3 4]  [dup *]  map&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;The &lt;code&gt;map&lt;/code&gt; combinator expects a list and a &lt;em&gt;quoted program&lt;/em&gt; (the same one used to compute the square) and produces a new list containing the result of that program applied to each element of the original list. Basically the equivalent of:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="number"&gt;1&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt;&lt;span class="number"&gt;2&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt;&lt;span class="number"&gt;3&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt;&lt;span class="number"&gt;4&lt;/span&gt;&lt;span class="punct"&gt;].&lt;/span&gt;&lt;span class="ident"&gt;map&lt;/span&gt; &lt;span class="punct"&gt;{&lt;/span&gt; &lt;span class="punct"&gt;|&lt;/span&gt;&lt;span class="ident"&gt;e&lt;/span&gt;&lt;span class="punct"&gt;|&lt;/span&gt; &lt;span class="ident"&gt;e&lt;/span&gt;&lt;span class="punct"&gt;*&lt;/span&gt;&lt;span class="ident"&gt;e&lt;/span&gt; &lt;span class="punct"&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;Do you notice anything different? &amp;mdash; Yes, Joy doesn&amp;#8217;t need blocks or lambdas either, it uses &lt;em&gt;quoted programs&lt;/em&gt; instead, which are nothing but slightly fancier lists (or arrays, as you like).&lt;/p&gt;


	&lt;p&gt;Let&amp;#8217;s recap then, Joy doesn&amp;#8217;t need of:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;lambda functions or blocks (quotation does the trick)&lt;/li&gt;
		&lt;li&gt;explicit parameters (everything you need is on the stack)&lt;/li&gt;
		&lt;li&gt;variable assignments (same as above)&lt;/li&gt;
		&lt;li&gt;explicit recursion (provided you can use combinators like linrec, primrec, binrec, etc.)&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;I would consider this one of the best examples of &lt;em&gt;programming minimalism&lt;/em&gt;: an incredibly simple syntax, a very small set of rules, but a good deal of power.&lt;/p&gt;


	&lt;h3&gt;Ruby objects on the stack&lt;/h3&gt;


	&lt;p&gt;After reading about Joy, I realized that implementing something similar in Ruby would be an interesting mini-project (let&amp;#8217;s say a week of lunch breaks) to understand more about concatenative programming. It would also be pointless, too: a stack-based programming language implemented on top of one of the most high-level programming languages you can find isn&amp;#8217;t going to be fast, is it? Nevertheless, it would still be interesting.&lt;/p&gt;


	&lt;p&gt;Ruby offers everything you need to build a Joy-like &lt;span class="caps"&gt;DSL&lt;/span&gt;:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;You can use arrays as &amp;#8230;arrays, but also as quoted programs, and to model the stack itself.&lt;/li&gt;
		&lt;li&gt;You can use integers, strings, etc. as themselves&lt;/li&gt;
		&lt;li&gt;You can use Symbols as functions (we&amp;#8217;ll get to this in a minute)&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;If you think about the following expression in postfix notation:&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;2 2 +&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;We &lt;em&gt;could&lt;/em&gt; translate it into infix notation (&lt;code&gt;2 + 2&lt;/code&gt;), because Ruby supports it, but it&amp;#8217;s not general enough. What you could do is this though:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="number"&gt;2&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;send&lt;/span&gt;&lt;span class="punct"&gt;(:+,&lt;/span&gt; &lt;span class="number"&gt;2&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;Message sending. I can see all the SmallTalk sympathizers drooling already. Well yes, In Ruby, &lt;em&gt;everything&lt;/em&gt; is an object, so &lt;em&gt;everything&lt;/em&gt; has a receiver and maybe some parameters. In other words, every method call can be reduced to the following syntax:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="ident"&gt;receiver&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;send&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;method&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="punct"&gt;*&lt;/span&gt;&lt;span class="ident"&gt;params&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;In this way, it is safe to assume that everything has a receiver, which could be understood as a function parameter, and may have 0 or more parameters. Take the following then:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="number"&gt;2&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="number"&gt;2&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="punct"&gt;:+]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;It&amp;#8217;s not too different from Joy, and it&amp;#8217;s still Ruby code. All you have to do is use something to do the following:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;Take an array, and examine each item:
	&lt;ul&gt;
	&lt;li&gt;If it&amp;#8217;s an object (non-Symbol), then push it on top of the stack.&lt;/li&gt;
		&lt;li&gt;If it&amp;#8217;s a Symbol, then do something different, i.e.:
	&lt;ul&gt;
	&lt;li&gt;Find its receiver and its parameters and call a method.&lt;/li&gt;
		&lt;li&gt;Manipulate something on the stack.&lt;/li&gt;
	&lt;/ul&gt;&lt;/li&gt;
	&lt;/ul&gt;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;In this case, we have to find :+&amp;#8217;s receiver and its parameter and we&amp;#8217;re sorted.&lt;/p&gt;


	&lt;p&gt;Unfortunately Ruby&amp;#8217;s &lt;code&gt;arity&lt;/code&gt; method isn&amp;#8217;t that reliable. For example: &lt;code&gt;"test".instance_method(:sub).arity&lt;/code&gt; returns -1, while it should return &amp;#8220;2&amp;#8221; to be useful. So we have no choice but find a way to pass the method&amp;#8217;s arity explicitly, in some cases.&lt;/p&gt;


	&lt;p&gt;For example like this:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="punct"&gt;[&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;Ciao, Fabio&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;,&lt;/span&gt; &lt;span class="punct"&gt;/&lt;/span&gt;&lt;span class="regex"&gt;Ciao&lt;/span&gt;&lt;span class="punct"&gt;/,&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;Hello&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;,&lt;/span&gt; &lt;span class="symbol"&gt;:sub&lt;/span&gt;&lt;span class="punct"&gt;|&lt;/span&gt;&lt;span class="number"&gt;2&lt;/span&gt;&lt;span class="punct"&gt;]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;If we define a | operator for the Symbol class, it&amp;#8217;s not too bad after all. It&amp;#8217;s heavy, but in this way we can use &lt;em&gt;any&lt;/em&gt; Ruby method in postfix notation.&lt;/p&gt;


	&lt;h3&gt;Introducing the Concatenative Ruby &lt;span class="caps"&gt;DSL&lt;/span&gt;&lt;/h3&gt;


	&lt;p&gt;&lt;a href="/concatenative"&gt;Concatenative&lt;/a&gt; is a simple Ruby &lt;span class="caps"&gt;DSL&lt;/span&gt; for concatenative programming. You can write concatenative programs inside ordinary Ruby arrays and execute them by calling either &lt;code&gt;Array#execute&lt;/code&gt; or &lt;code&gt;Kernel#concatenate&lt;/code&gt;, like this:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="ident"&gt;require&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;concatenative&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;

&lt;span class="ident"&gt;concatenate&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;
  &lt;span class="number"&gt;10&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt;
  &lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="number"&gt;0&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="punct"&gt;:==],&lt;/span&gt;
  &lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="number"&gt;1&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="punct"&gt;:+],&lt;/span&gt;
  &lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="symbol"&gt;:dup&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="number"&gt;1&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="punct"&gt;:-],&lt;/span&gt;
  &lt;span class="punct"&gt;[:*],&lt;/span&gt;
  &lt;span class="symbol"&gt;:linrec&lt;/span&gt;
 &lt;span class="punct"&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;This simple program calculates the factorial of 10. As you can see, no matter how unusual it may look, it is perfectly valid Ruby code and it is equivalent to the following Joy code:&lt;/p&gt;


&lt;code&gt;
10 [0 =] [1 +] [dup 1 -] [*] linrec
&lt;/code&gt;

	&lt;p&gt;Granted, Joy looks better, but that&amp;#8217;s the tradeoff for not writing a parser for Joy syntax, after all. 
Looking at the code above, there are a few things to keep in mind when programming with Concatenative:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;You are using Ruby arrays, so you have to use commas, at least&lt;/li&gt;
		&lt;li&gt;functions, operators and combinators (let&amp;#8217;s just call them &lt;em&gt;words&lt;/em&gt;) are available as Ruby symbols&lt;/li&gt;
		&lt;li&gt;The arity of all Ruby infix operators has been already set to &amp;#8220;1&amp;#8221; by concatenative using the &lt;code&gt;set_arity&lt;/code&gt; method (which simply stores the arity of a particular symbol in a constant hash)&lt;/li&gt;
		&lt;li&gt;You can specify explicit arities using the | operator (&lt;code&gt;:gsub|2&lt;/code&gt;, or &lt;code&gt;:join|1&lt;/code&gt;)&lt;/li&gt;
		&lt;li&gt;Unless the arity has been specified, an arity of 0 is assumed.&lt;/li&gt;
		&lt;li&gt;You can define your own concatenative functions using the &lt;code&gt;Symbol#&amp;lt;=&lt;/code&gt; method, which expects a quoted concatenative program.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;h3&gt;Performance issues&lt;/h3&gt;


	&lt;p&gt;In its current form, Concatenative can be very slow, as show the &amp;#8220;benchmarks&amp;#8221; provided in the /examples folder, especially if you use recursive combinators. This is understandable because everything is implemented in pure Ruby, which is totally unsuitable for low level stuff.&lt;/p&gt;


	&lt;p&gt;If you are interested, you are more than welcome to submit patches and suggestions to improve Concatenative&amp;#8217;s performance, or, if you feel brave enough, you could help me create a C extension instead: things would become much faster then.&lt;/p&gt;


	&lt;p&gt;At any rate, feel free to play with it. You can get the source from &lt;a href="http://github.com/h3rald/concatenative/tree/master"&gt;GitHub&lt;/a&gt;, you can get the gem from &lt;a href="http://rubyforge.org/projects/concatenative/"&gt;RubyForge&lt;/a&gt; and you can submit ticket through &lt;a href="http://github.com/h3rald/concatenative/issues"&gt;GitHub&lt;/a&gt; as well.&lt;/p&gt;</description>
      <pubDate>Sat, 28 Mar 2009 07:24:00 -0000</pubDate>
      <guid isPermaLink="false">urn:uuid:6a672fdd-53ef-40c8-8232-6e5cbeac549d</guid>
      <author>h3rald@h3rald.com (Fabio Cevasco)</author>
      <comments>http://www.h3rald.com/articles/concatenative-programming-in-ruby#comments</comments>
      <category>Articles</category>
      <category>ruby</category>
      <category>concatenative</category>
      <category>programming</category>
      <trackback:ping>http://www.h3rald.com/trackbacks?content=articles&amp;permalink=concatenative-programming-in-ruby</trackback:ping>
      <link>http://www.h3rald.com/articles/concatenative-programming-in-ruby</link>
    </item>
    <item>
      <title>Real-world Rawline usage</title>
      <description>&lt;p&gt;So I finally decided to update &lt;a href="/rawline"&gt;RawLine&lt;/a&gt; last week, and I added a more Readline-like &lt;span class="caps"&gt;API&lt;/span&gt;. When I first started the project, I was determined &lt;em&gt;not&lt;/em&gt; to do that, because the current Readline wrapper shipped with Ruby is not very Ruby-ish: it&amp;#8217;s a wrapper, after all!&lt;/p&gt;


	&lt;p&gt;The good thing of having a new &lt;span class="caps"&gt;API&lt;/span&gt; compatible with Readline is that now people can use RawLine in their Readline-powered scripts, with very minor modifications.&lt;/p&gt;


	&lt;p&gt;Let&amp;#8217;s have a look at some examples (they are also shipped with &lt;a href="http://rubyforge.org/projects/rawline"&gt;Rawline v0.3.1&lt;/a&gt;):&lt;/p&gt;


	&lt;h3&gt;Rush&lt;/h3&gt;


	&lt;p&gt;&lt;a href="http://rush.heroku.com"&gt;Rush&lt;/a&gt; is an excellent gem which provides a cross-platform shell environment, entirely written in Ruby.
Being a shell, it obviously uses Readline for tab completion, and that does the job on Linux. On Windows though, things aren&amp;#8217;t that easy:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;text gets garbled if you write long lines&lt;/li&gt;
		&lt;li&gt;you can&amp;#8217;t type certain characters if they use some key modifiers like &lt;RIGHT-ALT&gt;, etc.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;RawLine doesn&amp;#8217;t have these problems (that&amp;#8217;s the very reason why I created it), so here&amp;#8217;s a simple script which launches a Rawline-enabled Rush shell:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="ident"&gt;require&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;rubygems&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
&lt;span class="ident"&gt;require&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;rush&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
&lt;span class="ident"&gt;require&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;rawline&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;

&lt;span class="keyword"&gt;class &lt;/span&gt;&lt;span class="class"&gt;RawlineRush&lt;/span&gt; &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt; &lt;span class="constant"&gt;Rush&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;Shell&lt;/span&gt;

    &lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;initialize&lt;/span&gt;
        &lt;span class="constant"&gt;Rawline&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;basic_word_break_characters&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; 
        &lt;span class="constant"&gt;Rawline&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;completion_proc&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="ident"&gt;completion_proc&lt;/span&gt;
        &lt;span class="keyword"&gt;super&lt;/span&gt;
    &lt;span class="keyword"&gt;end&lt;/span&gt;

    &lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;run&lt;/span&gt;
        &lt;span class="ident"&gt;loop&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt;
            &lt;span class="ident"&gt;cmd&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="constant"&gt;Rawline&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;readline&lt;/span&gt;&lt;span class="punct"&gt;('&lt;/span&gt;&lt;span class="string"&gt;rawline_rush&amp;gt; &lt;/span&gt;&lt;span class="punct"&gt;')&lt;/span&gt;
            &lt;span class="ident"&gt;finish&lt;/span&gt; &lt;span class="keyword"&gt;if&lt;/span&gt; &lt;span class="ident"&gt;cmd&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;nil?&lt;/span&gt; &lt;span class="keyword"&gt;or&lt;/span&gt; &lt;span class="ident"&gt;cmd&lt;/span&gt; &lt;span class="punct"&gt;==&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;exit&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
            &lt;span class="keyword"&gt;next&lt;/span&gt; &lt;span class="keyword"&gt;if&lt;/span&gt; &lt;span class="ident"&gt;cmd&lt;/span&gt; &lt;span class="punct"&gt;==&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;
            &lt;span class="constant"&gt;Rawline&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;HISTORY&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;push&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;cmd&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;
            &lt;span class="ident"&gt;execute&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;cmd&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;
        &lt;span class="keyword"&gt;end&lt;/span&gt;
    &lt;span class="keyword"&gt;end&lt;/span&gt;
&lt;span class="keyword"&gt;end&lt;/span&gt;

&lt;span class="ident"&gt;shell&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="constant"&gt;RawlineRush&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;new&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;run&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;What happens here? Nothing much really, all I had to do was:&lt;/p&gt;


	&lt;ol&gt;
	&lt;li&gt;Derive a new class from Rush::Shell&lt;/li&gt;
		&lt;li&gt;Set &lt;code&gt;Rawline.basic_word_break_characters&lt;/code&gt; to the same value used in the original Rush code&lt;/li&gt;
		&lt;li&gt;Set &lt;code&gt;Rawline.completion_proc&lt;/code&gt; to &lt;em&gt;the same&lt;/em&gt; completion Proc used in the original Rush code&lt;/li&gt;
		&lt;li&gt;Rewrite the original &lt;code&gt;run&lt;/code&gt; replacing &lt;code&gt;Readline&lt;/code&gt; with &lt;code&gt;Rawline&lt;/code&gt;&lt;/li&gt;
	&lt;/ol&gt;


	&lt;p&gt;And it works as it was intended to, i.e. typing &lt;code&gt;root['b&amp;lt;TAB&amp;gt;&lt;/code&gt; will expand to &lt;code&gt;root['bin/&lt;/code&gt;, etc.
Note that I didn&amp;#8217;t write the completion Proc from scratch: it was already there.&lt;/p&gt;


	&lt;h3&gt;&lt;span class="caps"&gt;IRB&lt;/span&gt;&lt;/h3&gt;


	&lt;p&gt;After trying out Rush, the next logical step was trying &lt;span class="caps"&gt;IRB&lt;/span&gt; itself: I could never use it properly on Windows, and that was really frustrating.
After a few minutes trying to figure out how to start &lt;span class="caps"&gt;IRB&lt;/span&gt; programmatically, I quickly came up with a similar example:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="ident"&gt;require&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;irb&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
&lt;span class="ident"&gt;require&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;irb/completion&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
&lt;span class="ident"&gt;require&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;rubygems&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
&lt;span class="ident"&gt;require&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;rawline&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;

&lt;span class="constant"&gt;Rawline&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;basic_word_break_characters&lt;/span&gt;&lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt; &lt;span class="escape"&gt;\t\n\&amp;quot;\\&lt;/span&gt;'`&amp;gt;&amp;lt;;|&amp;amp;{(&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; 
&lt;span class="constant"&gt;Rawline&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;completion_append_character&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="constant"&gt;nil&lt;/span&gt;
&lt;span class="constant"&gt;Rawline&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;completion_proc&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="constant"&gt;IRB&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;InputCompletor&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;CompletionProc&lt;/span&gt;

&lt;span class="keyword"&gt;class &lt;/span&gt;&lt;span class="class"&gt;RawlineInputMethod&lt;/span&gt; &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt; &lt;span class="constant"&gt;IRB&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;ReadlineInputMethod&lt;/span&gt;
    &lt;span class="ident"&gt;include&lt;/span&gt; &lt;span class="constant"&gt;Rawline&lt;/span&gt;
    &lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;gets&lt;/span&gt;
        &lt;span class="keyword"&gt;if&lt;/span&gt; &lt;span class="ident"&gt;l&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="ident"&gt;readline&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="attribute"&gt;@prompt&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="constant"&gt;false&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;
            &lt;span class="constant"&gt;HISTORY&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;push&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;l&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt; &lt;span class="keyword"&gt;if&lt;/span&gt; &lt;span class="punct"&gt;!&lt;/span&gt;&lt;span class="ident"&gt;l&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;empty?&lt;/span&gt;
            &lt;span class="attribute"&gt;@line&lt;/span&gt;&lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="attribute"&gt;@line_no&lt;/span&gt; &lt;span class="punct"&gt;+=&lt;/span&gt; &lt;span class="number"&gt;1&lt;/span&gt;&lt;span class="punct"&gt;]&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="ident"&gt;l&lt;/span&gt; &lt;span class="punct"&gt;+&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;&lt;span class="escape"&gt;\n&lt;/span&gt;&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;
        &lt;span class="keyword"&gt;else&lt;/span&gt;
            &lt;span class="attribute"&gt;@eof&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="constant"&gt;true&lt;/span&gt;
            &lt;span class="ident"&gt;l&lt;/span&gt;
        &lt;span class="keyword"&gt;end&lt;/span&gt;
    &lt;span class="keyword"&gt;end&lt;/span&gt;
&lt;span class="keyword"&gt;end&lt;/span&gt;

&lt;span class="keyword"&gt;module &lt;/span&gt;&lt;span class="module"&gt;IRB&lt;/span&gt;
    &lt;span class="attribute"&gt;@CONF&lt;/span&gt;&lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="symbol"&gt;:SCRIPT&lt;/span&gt;&lt;span class="punct"&gt;]&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="constant"&gt;RawlineInputMethod&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;new&lt;/span&gt;
&lt;span class="keyword"&gt;end&lt;/span&gt;
&lt;span class="constant"&gt;IRB&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;start&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;In this case, Rawline is included in the &lt;code&gt;RawlineInputMethod&lt;/code&gt; class, derived from the original &lt;code&gt;ReadlineInputMethod&lt;/code&gt; class, i.e. the class &lt;span class="caps"&gt;IRB&lt;/span&gt; uses to define (guess&amp;#8230;) how to input characters.
Again, all I had to do was set a few Rawline variables to match the ones used in Readline, and then redefine the function used to get characters. All done.&lt;/p&gt;


	&lt;p&gt;It works as expected (only with inline completion, of course): typing &lt;code&gt;"test".ma&amp;lt;TAB&amp;gt;&lt;/code&gt; will give you &lt;code&gt;"test".map&lt;/code&gt;, &lt;code&gt;"test".match&lt;/code&gt;, etc.&lt;/p&gt;


	&lt;p&gt;You also get all Rawline key mappings for free (CTRL-K to clear the line, &lt;span class="caps"&gt;CTRL&lt;/span&gt;-U and &lt;span class="caps"&gt;CTRL&lt;/span&gt;-R to undo and redo, etc.), and you can define your own.&lt;/p&gt;</description>
      <pubDate>Sat, 07 Mar 2009 04:54:00 -0000</pubDate>
      <guid isPermaLink="false">urn:uuid:f24b9039-da89-455a-8e8b-e8f6db755c2a</guid>
      <author>h3rald@h3rald.com (Fabio Cevasco)</author>
      <comments>http://www.h3rald.com/articles/real-world-rawline-usage#comments</comments>
      <category>Blog</category>
      <category>ruby</category>
      <category>RawLine</category>
      <trackback:ping>http://www.h3rald.com/trackbacks?content=articles&amp;permalink=real-world-rawline-usage</trackback:ping>
      <link>http://www.h3rald.com/articles/real-world-rawline-usage</link>
    </item>
    <item>
      <title>RawLine 0.3.0 released &#8212; now with Readline emulation</title>
      <description>&lt;p&gt;&lt;a href="/rawline"&gt;RawLine&lt;/a&gt; 0.3.0 has been &lt;a href="http://rubyforge.org/projects/rawline"&gt;released&lt;/a&gt;. This new milestones fixes some minor bugs and adds some new functionalities, must notably:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;Ruby 1.9 support&lt;/li&gt;
		&lt;li&gt;A filename completion function&lt;/li&gt;
		&lt;li&gt;A new &lt;span class="caps"&gt;API&lt;/span&gt; very similar to the one exposed by the Ruby wrapper for &lt;span class="caps"&gt;GNU&lt;/span&gt; Readline&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Some of you asked for Readline compatibility/emulation and that was actually not too difficult to implement: all the bricks were already there, I just had to put them together in the right place.&lt;/p&gt;


	&lt;p&gt;The &lt;code&gt;RawLine&lt;/code&gt; module (you can spell it &amp;#8220;Rawline&amp;#8221; as well, if you wish) now behaves like &lt;code&gt;Readline&lt;/code&gt;. This means that you can now use RawLine like this (taken from examples/readline_emulation.rb):&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="ident"&gt;include&lt;/span&gt; &lt;span class="constant"&gt;Rawline&lt;/span&gt;

&lt;span class="ident"&gt;puts&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;*** Readline Emulation Test Shell ***&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;
&lt;span class="ident"&gt;puts&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt; * Press CTRL+X to exit&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;
&lt;span class="ident"&gt;puts&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt; * Press &amp;lt;TAB&amp;gt; for file completion&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;

&lt;span class="constant"&gt;Rawline&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;editor&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;bind&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="symbol"&gt;:ctrl_x&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt; &lt;span class="punct"&gt;{&lt;/span&gt; &lt;span class="ident"&gt;puts&lt;/span&gt;&lt;span class="punct"&gt;;&lt;/span&gt; &lt;span class="ident"&gt;puts&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;Exiting...&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;;&lt;/span&gt; &lt;span class="ident"&gt;exit&lt;/span&gt; &lt;span class="punct"&gt;}&lt;/span&gt;

&lt;span class="constant"&gt;Dir&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;chdir&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;..&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;

&lt;span class="ident"&gt;loop&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt;
    &lt;span class="ident"&gt;puts&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;You typed: [&lt;span class="expr"&gt;#{readline(&amp;quot;=&amp;gt; &amp;quot;, true).chomp!}&lt;/span&gt;]&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;
&lt;span class="keyword"&gt;end&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;Basically you get a &lt;code&gt;readline&lt;/code&gt; method, a &lt;code&gt;HISTORY&lt;/code&gt; constant like the one exposed by Readline (Rawline&amp;#8217;s is a RawLine::HistoryBuffer object though &amp;mdash; much more manageable), and a &lt;code&gt;FILENAME_COMPLETION_PROC&lt;/code&gt; constant, which provides basic filename completion. Here it is:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;    &lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;filename_completion_proc&lt;/span&gt;
            &lt;span class="ident"&gt;lambda&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt; &lt;span class="punct"&gt;|&lt;/span&gt;&lt;span class="ident"&gt;word&lt;/span&gt;&lt;span class="punct"&gt;|&lt;/span&gt;
                &lt;span class="ident"&gt;dirs&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="attribute"&gt;@line&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;text&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;split&lt;/span&gt;&lt;span class="punct"&gt;('&lt;/span&gt;&lt;span class="string"&gt;/&lt;/span&gt;&lt;span class="punct"&gt;')&lt;/span&gt;
                    &lt;span class="ident"&gt;path&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="attribute"&gt;@line&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;text&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;match&lt;/span&gt;&lt;span class="punct"&gt;(/&lt;/span&gt;&lt;span class="regex"&gt;^&lt;span class="escape"&gt;\/&lt;/span&gt;|[a-zA-Z]:&lt;span class="escape"&gt;\/&lt;/span&gt;&lt;/span&gt;&lt;span class="punct"&gt;/)&lt;/span&gt; &lt;span class="punct"&gt;?&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;/&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="punct"&gt;:&lt;/span&gt; &lt;span class="constant"&gt;Dir&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;pwd&lt;/span&gt;&lt;span class="punct"&gt;+&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;/&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;
                &lt;span class="keyword"&gt;if&lt;/span&gt; &lt;span class="ident"&gt;dirs&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;length&lt;/span&gt; &lt;span class="punct"&gt;==&lt;/span&gt; &lt;span class="number"&gt;0&lt;/span&gt; &lt;span class="keyword"&gt;then&lt;/span&gt; &lt;span class="comment"&gt;# starting directory&lt;/span&gt;
                    &lt;span class="ident"&gt;dir&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="ident"&gt;path&lt;/span&gt;
                &lt;span class="keyword"&gt;else&lt;/span&gt;
                    &lt;span class="ident"&gt;dirs&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;delete&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;dirs&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;last&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt; &lt;span class="keyword"&gt;unless&lt;/span&gt; &lt;span class="constant"&gt;File&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;directory?&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;path&lt;/span&gt;&lt;span class="punct"&gt;+&lt;/span&gt;&lt;span class="ident"&gt;dirs&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;join&lt;/span&gt;&lt;span class="punct"&gt;('&lt;/span&gt;&lt;span class="string"&gt;/&lt;/span&gt;&lt;span class="punct"&gt;'))&lt;/span&gt;
                    &lt;span class="ident"&gt;dir&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="ident"&gt;path&lt;/span&gt;&lt;span class="punct"&gt;+&lt;/span&gt;&lt;span class="ident"&gt;dirs&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;join&lt;/span&gt;&lt;span class="punct"&gt;('&lt;/span&gt;&lt;span class="string"&gt;/&lt;/span&gt;&lt;span class="punct"&gt;')&lt;/span&gt;
                &lt;span class="keyword"&gt;end&lt;/span&gt;
                &lt;span class="constant"&gt;Dir&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;entries&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;dir&lt;/span&gt;&lt;span class="punct"&gt;).&lt;/span&gt;&lt;span class="ident"&gt;select&lt;/span&gt; &lt;span class="punct"&gt;{&lt;/span&gt; &lt;span class="punct"&gt;|&lt;/span&gt;&lt;span class="ident"&gt;e&lt;/span&gt;&lt;span class="punct"&gt;|&lt;/span&gt; &lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;e&lt;/span&gt; &lt;span class="punct"&gt;=~&lt;/span&gt; &lt;span class="punct"&gt;/&lt;/span&gt;&lt;span class="regex"&gt;^&lt;span class="escape"&gt;\.&lt;/span&gt;&lt;/span&gt;&lt;span class="punct"&gt;/&lt;/span&gt; &lt;span class="punct"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="attribute"&gt;@match_hidden_files&lt;/span&gt; &lt;span class="punct"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="ident"&gt;word&lt;/span&gt; &lt;span class="punct"&gt;==&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;&lt;/span&gt;&lt;span class="punct"&gt;')&lt;/span&gt; &lt;span class="punct"&gt;||&lt;/span&gt; &lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;e&lt;/span&gt; &lt;span class="punct"&gt;=~&lt;/span&gt; &lt;span class="punct"&gt;/&lt;/span&gt;&lt;span class="regex"&gt;^&lt;span class="expr"&gt;#{word}&lt;/span&gt;&lt;/span&gt;&lt;span class="punct"&gt;/&lt;/span&gt; &lt;span class="punct"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="ident"&gt;e&lt;/span&gt; &lt;span class="punct"&gt;!~&lt;/span&gt; &lt;span class="punct"&gt;/&lt;/span&gt;&lt;span class="regex"&gt;^&lt;span class="escape"&gt;\.&lt;/span&gt;&lt;/span&gt;&lt;span class="punct"&gt;/)&lt;/span&gt; &lt;span class="punct"&gt;}&lt;/span&gt;
            &lt;span class="keyword"&gt;end&lt;/span&gt;
        &lt;span class="keyword"&gt;end&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;You can find this function as part of the &lt;code&gt;RawLine::Editor&lt;/code&gt; class. The result is not exactly the same Readline, because completion matches are not displayed underneath the line but inline and can be cycled through &amp;mdash; which is one of Readline&amp;#8217;s completion modes anyway.&lt;/p&gt;


	&lt;p&gt;A few methods of the &lt;code&gt;RawLine::Editor&lt;/code&gt; class can now be accessed directly from the &lt;code&gt;RawLine&lt;/code&gt; module, like with Readline:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;&lt;code&gt;Rawline.completion_proc&lt;/code&gt; &amp;mdash; the Proc object used for &lt;span class="caps"&gt;TAB&lt;/span&gt; completion (defaults to &lt;span class="caps"&gt;FILENAME&lt;/span&gt;_COMPLETION_PROC).&lt;/li&gt;
		&lt;li&gt;&lt;code&gt;Rawline.completion_matches&lt;/code&gt; &amp;mdash; an array of completion matches.&lt;/li&gt;
		&lt;li&gt;&lt;code&gt;Rawline.completion_append_char&lt;/code&gt; &amp;mdash; a character to append after a successful completion.&lt;/li&gt;
		&lt;li&gt;&lt;code&gt;Rawline.basic_word_break_characters&lt;/code&gt; &amp;mdash; a String listing all the characters used as word separators.&lt;/li&gt;
		&lt;li&gt;&lt;code&gt;Rawline.completer_word_break_characters&lt;/code&gt; &amp;mdash; same as above. &lt;/li&gt;
		&lt;li&gt;&lt;code&gt;Rawline.library_version&lt;/code&gt; &amp;mdash; the current version of the Rawline library.&lt;/li&gt;
		&lt;li&gt;&lt;code&gt;Rawline.clear_history&lt;/code&gt; &amp;mdash; to clear the current history.&lt;/li&gt;
		&lt;li&gt;&lt;code&gt;Rawline.match_hidden_files&lt;/code&gt; &amp;mdash; whether &lt;span class="caps"&gt;FILENAME&lt;/span&gt;_COMPLETION_PROC matches hidden files and folders or not.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;I bet you didn&amp;#8217;t know these methods were even in the Readline wrapper, did you? Probably because of lack of documentation.
Anyhow, another very important difference beween Rawline and Readline is &lt;code&gt;Rawline.editor&lt;/code&gt;, i.e. the default instance of RawLine::Editor used by the Rawline module itself.&lt;/p&gt;


	&lt;p&gt;This makes things easier if you want more control over the line which is being edited and the previously-edited lines. Sure, &lt;code&gt;Readline#completion_proc&lt;/code&gt; exposes the current &lt;em&gt;word&lt;/em&gt; being typed before hitting tab, and so does &lt;code&gt;Rawline#completion_proc&lt;/code&gt; the difference is that if you access &lt;code&gt;Rawline.editor.line&lt;/code&gt; you get a &lt;code&gt;RawLine::Line&lt;/code&gt; object with all the information you could possibly need about the current line: the position of the cursor, the text, the order the characters were entered, etc. etc. 
Now you can imagine why it took me a few minutes to write the &lt;code&gt;filename_completion_proc&lt;/code&gt; method (and why it will take you even less time to write your own similar method if you wanna do something different): you can access not only the last word being typed but also the current &lt;em&gt;and previous&lt;/em&gt; lines (through &lt;code&gt;Rawline.editor.history&lt;/code&gt; or just &lt;code&gt;Rawline::HISTORY&lt;/code&gt;)!&lt;/p&gt;


	&lt;p&gt;It must be said, as usual, that Rawline is &lt;em&gt;not&lt;/em&gt; a complete replacement for the Readline library yet (and it will probably never be, as Readline is huge!), but it&amp;#8217;s a good cross-platform, more Ruby-esque alternative to what&amp;#8217;s currently available by the Readline wrapper for Ruby.&lt;/p&gt;


	&lt;p&gt;It&amp;#8217;s not as fast, of course, especially when completing long words, but it&amp;#8217;s quite usable. The following libraries are not required but recommended:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;&lt;code&gt;win32console&lt;/code&gt; (on Windows)&lt;/li&gt;
		&lt;li&gt;&lt;code&gt;termios&lt;/code&gt; (on *nix)&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;They basically make Rawline faster. If you don&amp;#8217;t use them, Rawline will fall back on its pure-Ruby implementation to move left and right (i.e. printing backspaces and spaces character codes instead of &lt;span class="caps"&gt;ASCII&lt;/span&gt; escape codes).&lt;/p&gt;


	&lt;p&gt;Unfortunately, there&amp;#8217;s no &lt;code&gt;vi_editing_mode&lt;/code&gt; or &lt;code&gt;emacs_editing_mode&lt;/code&gt; yet (for time constraints: they &lt;em&gt;can&lt;/em&gt; be implemented!) but patches are very welcome. Also, if you need more features, all you have to do is ask :-)&lt;/p&gt;


	&lt;p&gt;P.S.: Check out the new &lt;a href="/rawline"&gt;Project Page&lt;/a&gt; and especially its Resources section!&lt;/p&gt;</description>
      <pubDate>Sun, 01 Mar 2009 07:47:00 -0000</pubDate>
      <guid isPermaLink="false">urn:uuid:0652ceca-892a-435d-8da1-33d397b569d5</guid>
      <author>h3rald@h3rald.com (Fabio Cevasco)</author>
      <comments>http://www.h3rald.com/articles/rawline-030#comments</comments>
      <category>Blog</category>
      <category>ruby</category>
      <category>OpenSource</category>
      <category>RawLine</category>
      <trackback:ping>http://www.h3rald.com/trackbacks?content=articles&amp;permalink=rawline-030</trackback:ping>
      <link>http://www.h3rald.com/articles/rawline-030</link>
    </item>
  </channel>
</rss>
