rubyann – for people too lazy to write Ruby

At last, I’ve written my own jQuery plugin.

My plugin tries to help lazy people (a noble cause) to write Ruby. It’s called rubyann which is short for ruby annotation.

But you have to understand something about Ruby… hardly anyone knows about it – it’s quite obscure.

Ruby is part of XHTML 1.1 – and now part of HTML 5. Ruby characters are small reading aids that are placed on top of characters. They can be useful for any language, but my interest comes from Japanese furigana – here’s what Ruby looks like:

The 1st example uses Ruby to explain a translation and the 2nd uses furigana
ruby example
And yes, that really is a translation – the word “kill” is not needed to say “kill 2 birds with 1 stone” – it’s obvious!

To get this seemingly simple annotation you must type XML into your HTML:

And that’s just for the 1st character! Multiply that XML by the number of ruby characters you want… and you’d better have an automated HTML ruby generator or rubyann

rubyann inserts the required ruby XML where it finds markup (I invented), so this:

With rubyann eg: $('.textWithFurigana').rubyann(); becomes this: I’ve written the jQuery plugin in coffeescript and it’s on GitHub – rubyann

Here’s what it looks like in my editor, RubyMine, with the coffeescript plugin


All Your Plural Are Useless

There is an ongoing debate about plurals in the database community – like in this StackOverflow question:  Table Naming Dilemma – Singular vs Plural

And Ruby on Rails users struggle with and sometimes override the obligatory pluralization convention.

But I’m here to tell you that everything good said about plurals is wrong. This is an aside, but it may feed into the debate.Plurals Are UselessPlurals never, in any realistic sentence, provide any additional information.

If you were to eliminate plurals from all of your sentences, no information would be lost – although the sentence may sound daft. But it would only sound daft through lack of familiarity – not because of any meaning lost.

Take this example:

I own 3 cat. I only have 5 dollar.

Exactly what information does the s add when we fix it?

I own 3 cats. I only have 5 dollars.

Nothing. You already know there’s more than one cat, because the number is specified. The plural is redundant.

I own many cats. I saw lots of elephants.

As long as there is a word describing the plurality already, such as many, lots – you don’t need an s to knock you over the head with it. We already know there’s more-than-one (or not) before we read the s.

Those women were talking about you.

Those girl were talking about you.

The second sounds awkward, but if it were spoken by a non-native speaker, it would be easy to understand. Why is that?

Notice I didn’t use the word woman here (for the singular of women). This would make it so awkward as to be almost incomprehensible. But that is because plurals are not only useless, but also hideously inconsistent. If it were just a matter of adding s, they would just be harmlessly useless.

The only sentence I can think of that comes close to having a plural add information is this:

I went to the park today and saw squirrels.


But that sentence is not realistic.

Realistically, it would quantify how many squirrels were seen. Some; heaps; a few; 3 big ones. And as soon as that happens, the s in squirrels immediately becomes…

Did you ever wonder why other languages, such as Japanese, don’t use plurals?


In the squirrel example, it is also obvious through context, that plurality is implied or trivial enough to be irrelevant. Take the s away, and you’ve not lost any meaning.

To see some of the many exceptions for plurals: Fun With Plurals

Some plurals are the same as the singular (eg fish, moose). And some plurals have no singular (eg scissors, cattle). These plurals cannot possibly provide any information – or by confusing the plural, they even detract from any attempt to create meaning. Plurals are a language oddity.

If you know of a useful sentence where the plural adds information that wouldn’t otherwise be known. Let’s have it.

What about the developer singular vs plural debate?

ActiveRecord use plurality to make your code read like an English sentence. Maybe the number of exceptions is low enough to get away with this. But since many plural exceptions are animals (geese, cattle, fish, moose, deer, sheep) – my plans for a web app game featuring a moose that can fish, and 3 sheep that trade with local deer – is looking like a lot of work.

Some plurals are also up for debate and this Ruby on Rails bug report on the plural of penis has been closed wontfix. It’s labelled as an enhancement, probably just to make it a penis enhancement, with a comment: “You guys should probably investigate a plugin to handle this

All this suggests to me that in the programming world of precision, an unreliable language-oddity like English plurals should not be relied on to convey any meaning – if possible.

Running CoffeeScript In-Browser

One of the ways to run CoffeeScript (other than processing on the server or using the command line to pre-compile) is to run CoffeeScripts, directly, in-browser.
This simply means that you can write coffeescript inside the HTML document. It has the disadvantage of being near impossible to debug as the running code will be encased in a very large javascript eval statement.
Running CoffeeScript in-browser is therefore not encouraged by the Author of CoffeeScript (jashkenas) – to the extent that he preferred not to include my submission (or pull-request as it is known on GitHub) to improve the documentation for it. This may be reasonable, however I would like to put the documentation here.

To run your coffeescript inline:

  1. Tag your coffeescript with the type “text/coffeescript”
  2. Include coffee-script.js after all coffeescript on the page (this is the compiler that will evaluate and compile all coffeescript in order)
  • The text contents of remote scripts (those referenced via src=””) cannot be accessed from the browser unless they are hosted on the same domain, and are capable of being accessed via an XMLHTTPRequest (which is how the compiler loads it)

And the main improvement to the documentation I wanted to make, an example:

<title>In-Browser test</title>
<script type=”text/javascript” src=”;> </script>
<script type=”text/coffeescript”>
-> $(#header).css background-color, green
<script type=”text/javascript” src=”;> </script>
<h1 id=”header” style=”color:white”>CoffeeScript is alive!</h1>

And the corresponding output: