Multiple users and the iPad
I promised myself I wouldn’t write a blog post about the iPad. But I’ve been thinking about who would use it, and something’s been puzzling me.
How do multiple users share an iPad?
What’s the equivalent of Twitter’s 140 character limit for non-Latin character sets?
Everyone on Twitter has the same 140 character limit. But if you don’t use English, can you get more into those 140 characters? This weekend, I did some Real Science to find out.
If you speak Japanese (日本語), each character you type is equivalent to several English characters, or even an entire word. For other non-Latin languages, like Russian or Thai, it’s less clear if there’s an inherent advantage.
To get some numbers, I hooked up Twitter’s API to Google’s AJAX Translate API to fetch some tweets, translate them, and measure the equivalent length in English. And so the Tweet Measurer was born, allowing anyone to perform dubious calculations of Tweet Length from the comfort of their own web browser.
Implementing a simple URL shortener with Apache’s mod_rewrite
While there are lots of problems with URL shorteners, they do appear to be here to stay. The popularity of long meaningful URLs (which are thought to prompt search engines to rank the pages higher) combined with the popularity of messaging services like Twitter (which restrict the number of characters) means there’s a need for these short URLs.
A reasonable solution is to run your own shortener for your web site, and hope people use it. For this blog, I’m using a few lines of Apache configuration and a script which generates a mapping file. This is how it’s done using mod_rewrite:
Control untrusted processes with Solaris SMF
If you’re writing a web application which handles files uploaded by your users and does anything more than storing them for download later, then you need to think about security on the server. Even insignificant processing relies on libraries which have bugs, which can range from infinite loops to execution of arbitrary code on the server.
To pick one example, here’s some past security flaws with libpng. No library is going to be bug free, especially if it deals with complicated file formats. Since you’re not going to be the first to know about the bugs, you need to take precautions.
iPhone auto-rotation: out of control
As much as I admire the elegant design of the iPhone, I find the auto-rotate feature infuriating on a daily basis.
Landscape mode is vital for many apps, especially Safari, and it needs to be easily discoverable. Yet the way it’s implemented in the iPhone removes the feeling of control from the user, violating a fundamental UI principle.
Java-style annotations in Ruby
My favourite thing about starting to use another programming language is the new perspective it gives you on programming in general. Experiencing another language’s culture and how it solves problems is a great way to think about the underlying nature of your craft.
After years of avoiding Java, I’ve been writing quite a bit recently to take advantage of the libraries and infrastructure in the JVM. I’ve been pleasantly surprised: it’s like a better C++ with an emphasis on avoiding the treacherous details in the language and the C libraries. While its reputation for verbosity is well deserved, there are some nice features.
For instance, Java allows you to annotate methods and classes. If that was a feature of Ruby, it would be a neat solution to an problem I was trying to solve.
Why development should look like deployment
It starts so innocently. You create a new web application, and while developing it you run it on a non-privileged port. But over time the differences between development and production mount up, and one day, the system running in development looks nothing like production.
This means the application you’re developing is very different from the one which is running in production, and there’s the potential for things to become interesting when you deploy. I have come to realise that you must make a conscious effort to keep development mode as close to production as possible.
Going off the Rails
My project, OneIS, was started using an early version of Ruby on Rails. Over two years of development, there’s been an ever growing mismatch between what I need and how Rails works, so I’ve been writing a replacement framework which does exactly what I need.
I’ve found Rails is great for smaller applications, but a bit painful when the code gets more complex. I think this is largely due to some of the underlying philosophy and the style of coding it promotes.
Speed by design, not by optimisation
A little while ago, we spoke to a significant percentage of everyone who’d used OneIS. Unexpectedly, over 80% commented on how fast OneIS is when asked if they had any general comments on the service.
I consider this a shocking reflection of the current state of web development, rather than anything special about our service. There are very few speedy web sites out there, and it’s becoming an issue. Google have recently launched a drive for speed and Yahoo have some well known tools and guides.
Speed is most frustrating on a mobile device. If you’re browsing any of the many news sites which offer links to content over the web, reading an article downloads 100K or more, just to render a couple of K of text. This is very frustrating — almost enough to make me knock up a proxy which strips out the rubbish and just sends the text with readable mobile formatting, sort of Readability on the go.
The Yahoo guidelines are pretty good, but more aimed at large content sites such as Yahoo. If you’re developing a web application, then things are slightly different.
So here’s how I developed OneIS with speed in mind:
JRuby, Java and Ruby
JRuby is an alternative implementation of the Ruby programming language, implemented in Java and running on the JVM. It offers some useful advantages over the standard C interpreter:
- it’s often faster
- it offers easy integration with Java for access to vast amounts of useful Java libraries
- you get real threads, instead of C ruby’s green threads
It’s also a benefit to the Ruby community at large, even if you don’t run it. The various Ruby implementations are all working together on RubySpec, a large test suite which is effectively defining the Ruby language and verifying that all the implementations are compatible.
