Tuesday, August 31, 2010

Parisian driving

(saving a comment I wrote on a boards.ie thread)

I thought we had some crappy driving here (in Ireland), but visiting Paris for a week really put things in perspective.

Firstly, if you're a pedestrian walking at a crossing, even if it's a signalled one with a green light in your favour, drivers will happily continue to fly around corners and barrel through the crossing. Get in their way and either get knocked down or beeped into deafness.

Secondly, remember that two-second clearance rule here? The TV safety ads suggest that when the car in front passes a point, you should be able to say "only a fool breaks the two second rule" before you pass the same point. In Paris it's "only a foo- ARGHHH!", with cars overtaking you (from any side) and diving into your lane after having barely cleared your car. This happens all the time. The cars behind don't even brake when it happens, so the tacit understanding seems to be a) one or two metres of clearance is an acceptable distance at 100kph and b) overtaking drivers will never have to suddenly brake while directly in front of my car. Weird.

The two and a half hour trip from Amboise back to Paris really made this clear: drivers will gladly overtake a bus and pull in front with about two metres' clearance. Not only that, but the bus driver starts to pull into the lane they just left, while they're still moving into our lane with two metres' clearance.
All of this is completely normal there.

And as probably everyone knows, parking there means gently (or not) backing into the car behind you, then forward into the next one, then back and forth repeatedly bashing the surrounding cars until your car is wedged into a space with two inches to spare on one side, with bumpers touching on one side. Almost every car's registration plate and bumper is dented, scratched or missing.

So I arrived back in Dublin airport thinking "I guess the standard over here isn't so bad really", just as a shitestain of a taxi driver in a silver Merc floored it as soon as the green man started to flash, as I was already running across the pedestrian crossing pushing a trolley full of bags which missed his car by about two inches as it screamed past me.
If that thing didn't have its own brakes, you were getting a heavy iron trolley in the rear left wing. I was sorely tempted to just let it happen too, but settled for a rapidly-shouted "my light's still green, you stupid fucking bastard!"

Sunday, August 22, 2010

Does the free software movement represent "true freedom"?

Someone commented on a Youtube video that:
Actually, free software represents freedom. The Open Source Movement just supports the benefits of source code being available. The Free Software Foundation supports true freedom."

To which my response was:

It doesn't support the freedom to sell software though, does it?

Almost all of the software I use is open-source, and I've made (miniscule) contributions to open-source software in the past, but I don't think it's fair to demonise those who wish to make money from writing software by selling it.

Stallman seems to characterise closed-source as unethical, but is it really wrong for someone to release a program without the source code so that they can profit a bit from their work?

I'd be interested to hear any insight from others on this issue. Free software provides some freedom, but obviously removes the freedom to sell that software, even by the author. As a big fan and user of free software, but also a programmer and tradesman, I recognise that other people may want to do programming as a living by selling their work (rather than doing unenjoyable coding tasks for a large financial company they dislike, say).
I don't see anything wrong with that, unless there are superior models that allow them to still get paid reasonably well for their work as well as allowing them to release as open source. For example, many open source project pages have a donation link which allows happy users to send any amount of money to the developer if they wish, but I'd expect that this isn't a hugely profitable source of income compared to selling the software (which would kind of require it being closed source or at least with a horrible restricted semi-free license).


Friday, August 20, 2010

Why does Applescript suck so badly?

It's not like Apple is lacking developers or time or money or experience. Not only is the syntax for Applescript simultaneously verbose and vague, the API documentation sucks and the implementation appears to be buggy.
Not the language implementation per se, but the underlying hooks that allow it to do its job. For some reason, certain programs fail to respond to Applescript correctly, so scripts like the following don't work properly (and worse, the problem is sporadic):

tell application "Mnemosyne"
end tell

Fine, maybe the Python wrapper for Mnemosyne is a bit dodge. But why should it matter?

In Windows there are free third party scripting/automation languages like AutoHotKey and AutoItScript. I've never had a problem bringing an application window into focus with them - why would you? Perhaps Applescript's hooks are at a higher level, while those of AutoIt etc operate on a low level Windows message scheme: instead of applications responding (or ignoring, or bolloxing up) Applescript requests, they simply receive normal window/GUI events, just like when a user is manually clicking and typing.

These Windows automation/scripting languages "just work" - you can assume that a window is just a window and if you can activate one by clicking or alt-tabbing to it, you can activate it via a script - and the syntax is simple and intuitive for most programmers (although AHK's is a bit ugly IIRC).

If they can do that, surely Apple can do much better than Applescript.

Addendum: It seems that you can't even move the mouse from Applescript, without installing extra 3rd party software. Boo-urns!

Addendum 2: Well, it's not giving me error -9874 anymore when trying to activate the window. Also it's become apparent that when activating the Mnemosyne window with a modal dialog open (the "Add cards" window), focus will be on the application's main window, unless the mouse cursor is hovering over the main window. This happens when you manually cmd-tab to the application. Very odd - perhaps the GUI event loop isn't processed properly until the mouse cursor is moved over the main window? Ah well. The rest of my diatribe stands (or crouches) though - I still dislike Applescript in more ways than one.

Tuesday, August 17, 2010

Why is speeding so commonplace?

The root problem seems more that people are expected to drive at least at the speed limit, if not over. When a driver travels at 3-5kph under the speed limit, following cars tend to overtake as soon as possible or get angry and start behaving dangerously. There are very large number of people out there who will consider you to be a lunatic for doing 48km/h with a 50km/h limit. In Dublin at least, a 50km/h limit is tacitly interpreted as a 60km/h limit, a 60 as an 80, etc.

And it's not purely a social problem; it starts in the Rules of the Road, which says things like:

You must progress at a speed and in a way that avoids interference with other motorway traffic.

Avoid driving too slowly

In normal road and traffic conditions, keep up with the pace of the traffic flow while obeying the speed limit. While you must keep a safe distance away from the vehicle in front, you should not drive so slowly that your vehicle unnecessarily blocks other road users. If you drive too slowly, you risk frustrating other drivers, which could lead to dangerous overtaking.

While it does remind you to obey the speed limit, this comes into conflict with the greater message here: "keep up with the pace". Since it seems like the majority of other road users are almost constantly speeding, this reinforces the notion that you should never travel below the speed limit, and if anything, increase speed to match traffic in front.

It's frustrating - if you're driving within a city, given the time spent in traffic or stopped at lights and the relatively short distance, it doesn't really matter if you travel at 45 or 55. But it's considered a greater crime to err on the low side. Why?

Thursday, August 05, 2010

Java verbosity again

(Repost of a comment I made somewhere on the topic of the verbosity of Java, and particularly its APIs)

The Reflection API is a fairly shocking example of the needless verbosity of Java. And I would consider the official API to be part of Java.

Here's a simplistic example in Java and Ruby, replacing characters in a string ("putty" => "puppy") first directly and then via reflective invocation:

// Java
String s = "putty";
System.out.println(s.replace('t', 'p'));
try {
Class c = s.getClass();
Method m = c.getMethod("replace", char.class, char.class);
System.out.println(m.invoke(s, 't', 'p'));
} catch (Exception e) {

# Ruby
s = "putty"
puts s.gsub("t", "p")
puts s.send("gsub", "t", "p")

This kind of verbosity is prevalent in Java's standard libraries, particularly when (anonymous) inner classes are involved. At the moment I'm struggling with "doPrivileged" blocks in some Java code which deals with sandboxing, and it is syntactically very unpleasant.

Ok, we could chain the Java calls together and knock some lines off, but it's still not nice:
try {
System.out.println(s.getClass().getMethod("replace", char.class, char.class).invoke(s, 't', 'p'));
} catch (Exception e) {

Tuesday, August 03, 2010

Ankimini audio on the iPod: can I hear it now?

Yes! But a small amount of manual muckery is required.

Here are the rough steps that I followed to get an Anki deck working with audio on my iPod Touch (2nd gen, on IOS4):
  1. Jailbreak the iPod. This was actually so easy that it will be hard to suppress an ear-to-ear grin. Just going to that link and opening a cleverly broken PDF file exploits a bug (presumably a stack smash) to execute arbitrary code and install Cydia. You don't even need to reboot the device! Very different from the iPhone OS 3 jailbreak that I used last time, but this will probably become impossible soon (until someone finds the next suitable vulnerability).

  2. Install Ankimini from the Cydia or Rock package managers. Easy peasy.

  3. Create or download the deck in Anki (desktop). Get your deck working on a desktop machine as normal, then sync it with an online account.

  4. Sync your deck in Ankimini. This should be straightforward.

  5. Copy across the media files. From my Mac, the command to do so was scp -r ~/Documents/Anki/deckname.media/ mobile@ipod_ip_address:~/.anki

I then stopped and started Anki via an SBSettings button, but I don't think this step is necessary. Now I can learn and listen to spoken Chinese in "dead time" (i.e. when I'm on a bus or taking a shite). Brilliant!

On a related note, I would like to try the new AnkiMobile, but it's just a bit too expensive for me at the moment. I think the developer may be pricing himself out of the market - you don't see (proportionally) many iPhone applications that cost €20. At an uneducated, not-thought-through guess, I'd wager that more than twice as many people would buy the program if the price was halved. Hopefully it works out anyway, after the tremendous work he's put into Anki.