A notch above a monkey

Javascript and i18n

I’ve been looking for Javascript localization resources on Google and came up fairly empty handed. There seems to be little useful information and even less useful code. The only thing I found, that is actually usable, is a library by Guido Wesdorp.

I find this utterly amazing after a decade of Javascript being in wide use, although I probably shouldn’t be. A likely explanation for this is that Javascript is most often used for short scripts inside web pages. If used on a multilingual website, it’s usually fairly easy to have separate javascript files for each language.

I expect this will change with rise of more complicated, involved web applications. However, so far AJAX toolkits that seem to spring up these days like mushrooms after rain, have been busy with obviously more important things like animations.

I could be wrong. In fact, I hope I’m wrong. Is there a javascript i18n library with following characteristics:

  • easy to use
  • supports translation of javascript code and HTML
  • small and relatively fast
  • translations are separated from HTML and javascript code
  • handles properly nodes with superfluous whitespace and those where it can’t be collapsed
  • supports translation of nodes with other HTML tags as ancestors (not only text nodes)

Guido’s library is a good tool that meets many of these needs, but sadly not all of them. Writing my own one seems to be the only solution.

Speed test of PyRSS2Gen, kid and atomixlib

I’ve spent this evening building RSS2 and Atom feeds with PyRSS2Gen , kid and atomixlib , as proposed by helpful people few days ago.

We’d like to add feeds promiscuously to our service (right now we have exactly one). But before we can decide how to tackle this, we need to know how fast we can generate a feed on average.

DISCLAIMER: I tried to generate feeds with same data using what seemed a reasonable python code to do so, but I didn’t try to save every millisecond as I only cared about crude speed approximations. I have no problem believing that someone else might get completely different results. No serious statistical analysis has been made and rigorous scientific approach has been almost completely absent. Better make your own tests, if speed (or anything else really) is important to you. But if dubious numbers delight you, then please continue.

So, here are my results. Time to generate a feed with 10 entries on 1GHz G4 Powerbook:

  • with PyRSS2Gen somewhere around 70ms
  • with atomixlib around 120-140ms
  • and with kid around 30-35ms

In other words, you can generate between 8 and 30 feeds per second on my notebook and (I guess) 2-3x as many on a modern server. This is more than enough for most cases, but I’m afraid it probably won’t be enough for us. Which means either producing feeds by gluing strings together or having a more intelligent approach than building a new one on every request.

As a side note, I found all three packages easy to work with.

Update: Sylvain has released atomixlib 0.3 which makes it even easier to create atom feeds and brings also significant speed improvements. On my computer it takes now around 60-65ms to build a feed.

Another update: I made a couple of quick tests with mixed results on fairly new Opteron server. PyRSS2Gen was actually slower with 80-85ms and I have no idea why. kid was blazing fast with times between 8 and 9ms. Definitely good enough.

But I couldn’t get atomixlib to work, because 4Suite failed to build, so it will have to wait until I can figure out why it chokes on a perfectly legitimate XSLT.

Update 3: 4Suite has been promptly fixed (thanks!) and atomixlib 0.3 takes now 18-19ms. I believe this is an excellent time.

Community development

I’m online again and have been reading news of the last few days. So I’m kind of late to discussion about friendliness of communities.

My personal experience with Python community has been absolutely wonderful. I’ve written posts that could be seen as inflammatory, but the response I’ve got was just amazing. I haven’t been nailed to the cross for it and have learned a lot from people I admire, who took the time to leave a comment on my blog for which I’m really grateful. A couple of days ago I needed help developing atom feeds and got it immediately.

I find Python community very friendly and forthcoming, but I also believe Ian is right that Ruby might feel more friendly simply because a kind of youthful innocence. I wouldn’t really know, since I don’t use the language or follow up their discussions. I have however experienced in other communities the problem of a disconnect between old timers and newer members, who don’t share cultural history just yet. I think this is inevitable, since experience unlike knowledge can’t be easily given.

On the other hand, I have a different problem with web related talks we’re organizing. It’s been our goal from the start to use talks as a conduit for slovenian web community building, which hasn’t happened to the extent I was hoping for. Our talks are well attended, but at the end our audience mostly leaves, which kind of saddens me. I’d like to get them more engaged, but I have no idea if the problem lies with us, organizers, or is just a result of slovenian culture.

I guess community building is just hard.