Archives for October 2008

Why no choice?

I'm just going to keep on saying this because it's true.

  • ADSL sucks.

Three years ago I had a good, fairly reliable, 8mbps cable internet connection from Telewest.

Then I moved to Maidenhead and was forced to switch to 1mbps (and later 2mbps) ADSL over a BT line (forcing me also to take a line from BT, a company I never wanted to do business with again).

In my new house I have an ultra-flaky 3.5mbps line. In 6 months I have experienced more dropped connections, high latency, and performance drops than I would expect to get in 10 years.

Today I've had a BT engineer to the house to try and diagnose some kind of exchange fault. Will my service improve now? Based on the dropped connection and still highly variable noise margins my DG834 is reporting I am not getting my hopes up.

In the same time Virgin Media (who swallowed NTL and Telewest up) have upped the speed of their fast cable service to 20mbps. I'm more than ready to try my luck and hand them my cash but I can't because, throughout this whole time, they report that I am in their "analogue area".

My only choice is ADSL which means the stupid copper cable between me and the BT exchange.

I'm 30 miles West of London not in the Outer Hebrides. Why the hell are Virgin not here offering me digital service?

Why is there no choice?

Update: Talking to ntl:Telewest (the business arm of Virgin Media) there maybe some chance of cable service. They are at least willing to send an engineer to do a site survey providing a sign a 24-month business contract.

It's not cheap at £30/mth for 4mbps service (with a likely drop in upstream speed to 512kbps), £40/mth for 10mbps service, or £50/mth for 20mbps (with likely 1mbps upstream).

My current broadband offer is £20 plus whatever I am paying for the BT line rental.

Something to think about. But if I am going to commit to 24mth's service I'd like to know what Virgin Media are like as an ISP. Anyone have any experience?

21/10/2008 09:56 by Matt Mower | Permalink | comments:

Choices ahead

According to The Times Online the government now proposes that anyone who wants to use a mobile phone will need to provide their passport and that the details of every one of us using a mobile phone will be held on a database by the security service, MI5. According to the same article GCHQ is already spending £1 billion of tax payers money on a database to hold the details of all telephone calls as well as email and web traffic.

I think we are close to reaching a bifurcation point in the development of our society.

We are, I would say, pretty close to having accepted that we will be monitored in our every activity with such monitoring being routinely stored in a database for analysis by officials. And that the scope of such monitoring and databases will be widened by officials more or less as they see fit.

Now we are presented with the beginning of routine registration. Those of us with a passport have already registered ourselves but international travel is still not so routine that you can't be part of society if you haven't travelled (more's the pity) but a mobile phone is, for all practical purposes a requirement. If you doubt this consider that, according to the times, there are 72 million phones in this country. 12 million more than there are people.

Once we accept that we need to be registered and our details held on a database when buying a mobile phone it will be a short step to registering us for other things. Why not start by registering anyone buying say fertilizer, or electrical components, or taking certain courses and expand outward from there? And all of this information being secretly pooled to detect "suspicious" patterns.

This despite the available evidence suggesting that such databases are prone to becoming less valuable the bigger they get because of false positives (unless you imagine there are more terrorists than non-terrorists). I doubt, however, such concerns will get in the way of the officials tilting at this particular windmill. It's a great way of spending vast gobs of tax payers money after all.

It's not that our society was free and is now not, it's a matter of degree. We seem to be in the middle of a period of relative fear and insecurity with too many looking to the state to protect them. A role the state, and it's officials, are only too happy to take on.

Where will we be in ten years do you think?

19/10/2008 10:49 by Matt Mower | Permalink | comments:

Incompatible with a free country

Is there nothing this government won't do? From a BBC report:

Details of the times, dates, duration and locations of mobile phone calls, numbers called, website visited and addresses e-mailed are already stored by telecoms companies for 12 months under a voluntary agreement.

Okay I'm already pretty shocked. When did it become okay for telco's to store all this information?

Worse yet we're now going to turn this over to the government? A government that has shown, time and time again, that they cannot be trusted with our information.

I'm with Chris Huhne:

"Ministers claim the database will only be used in terrorist cases, but there is now a long list of cases, from the arrest of Walter Wolfgang for heckling at a Labour conference to the freezing of Icelandic assets, where anti-terrorism law has been used for purposes for which it was not intended."
"Our experience of the Regulation of Investigatory Powers Act suggests these powers will soon be used to spy on people's children, pets and bins.
"These proposals are incompatible with a free country and a free people."

These proposals are incompatible with a free country and a free people.

I agree that it's important to protect lives but find another way.

15/10/2008 23:14 by Matt Mower | Permalink | comments:

Can't we all just get along?

Like a lot of folks these days I write all my Objective-C code, like I write my Ruby code, using TextMate instead of Xcode. Xcode has more tricks these days but they don't much up for it's deficiencies and, well, there is an argument for having one editor and knowing it well.

However I still use Xcode to manage my project files & dependencies and to build & run my code (even if I am starting to use command-line gdb because it seems more reliable that way). I find the Xcode build results easier to use than the built-in TextMate approach and Xcode knows how to manage Cocoa projects and their dependencies.

Up until now I've been writing in TextMate then switching to Xcode and hitting Cmd+B, Cmd+R, or Cmd+Y depending on whether I want to build, run, or debug. But it irked me because I would keep using Cmd+B in TextMate. To begin with this would trigger TextMate's use of xcodebuild which annoyed me and I quickly disabled that.

This morning in one of those facepalm moments it occurred to me to ask why I hadn't checked if Xcode was Applescriptable. Of course, it is.

So one script (saved as ~/Applications/BuildWithXcode.scpt) later:

tell application "Xcode"
    activate
    build
end tell
tell application "TextMate"
    activate
end tell

and I have Cmd+B bound to oscript ~/Applications/BuildWithXcode.scrpt and I'm away. Similar for run and debug:

tell application "Xcode"
    activate
    launch
end tell

TextMate and Xcode working together nicely.

Update: My run script wasn't working because I used run instead of launch. I guess the app must already have been running without me noticing. Works now though :)

15/10/2008 11:17 by Matt Mower | Permalink | comments:

Oh please let me go back to Windows, please!

"But there's also productivity value that you get on Windows Vista that you can't get on a Mac. You can't get Outlook, you can't get Visio, you can't get Project. And when you do get applications such as that, they're usually stripped-down versions that don't have nearly the amount of features, or the usability like the ribbon on Office. Those types of things just don't come with a Mac. And that you don't get the best in terms of hardware experiences, you don't get high-definition playback on Blu-ray DVD on a Mac. You can't do it, can't get it, it's just not there." -- [Brad Brooks, vice president of Windows Consumer Product Marketing via cnet news]

Hahahahahahahahahahahahahahahahahahahahahahahahahahaha ha.

14/10/2008 11:25 by Matt Mower | Permalink | comments:
More about:

It's always just after you write

Well Laurent did tell me that several people were working on Javascript/Cocoa bridges. I got word this morning about JSCocoa which looks pretty interesting. If I'd come across this before speaking to Laurent about MacRuby I might well have tried it.

It looks interesting although I am puzzled by the ugly instance initialization syntax when using GC. And here is a clear advantage to JSCocoa. If you are not using Leopard GC you can't use MacRuby (because MacRuby replaces the Ruby GC with the Leopard GC) and a lot of Cocoa developers are not using GC for various good reasons (like wanting to support Tiger).

On the other hand if you are using Leopard GC then using JSCocoa you end up with two GC's running at the same time (since JSCore has it's own GC).

Right now, despite the rough edges, I am pretty happy with how MacRuby is working out. I have to see how well it will perform, Ruby is not the fastest language out there. MacRuby should probably perform as fast as the current JSCore. We'll have to see what things look like when SquirrelFish becomes the official JSCore (probably in 10.6).

10/10/2008 09:00 by Matt Mower | Permalink | comments:
More about:

Scripting Elysium using MacRuby

For a couple of months now my hobby has been working on a Cocoa application, code name "Elysium" for generating music. If you want to read a little of the background I posted about it earlier.

Something I've had in mind, almost from the beginning, was that Elysium should be scriptable. That, through the ability to script parts of the application, you can have more control over the musical strategy. For example a script might regulate how often new playheads are generated in order to control the "energy" of a piece.

But how to script a Cocoa application?

My original plan had been to use Nu however, although I still find Nu an interesting idea, I've not spent much time with it recently and it's continued lack of support for Objective-C garbage collection put me off.

With Nu out of the picture I switched my attention to Javascript. It's not perfect but it's pretty good and the JavascriptCore framework comes with Leopard (which is fine since using GC makes my app Leopard only anyway). With all the news of JSCore performance enhancements via SquirrelFish this seemed a solid choice.

Embedding JSCore is simple, just copy the framework into your project. That's when the fun begins though. As soon as I started trying to use it I realized that JSCore is unbridged. This means that, in order to expose Elysium's Objective-C based objects to Javascript I would have had to implement a set of "facades" that would emulate JS classes.

There is an example, JSPong, and while you know it's not impossible it's pretty tedious (and not helped by JSCore very thinly documented, and I'm being generous there) and results in a heavy stink of pollution of your model classes. In short, right now, using JSCore as a Cocoa scripting language is a mess. Worse still I knew, from the Nu experience, that it was totally unnecessary mess.

While casting around for how to bridge Javascript I came across F-Script. F-Script is a Smalltalk like language that is beautifully bridged with Cocoa. In less than an hour I was scripting Elysium. For example here is a callback that tells a note not to play on beats divisible by 7.

[:noteTool :playhead | noteTool hex layer beatCount rem: 7 == 0 ifTrue:[ noteTool setSkip:YES ]]

This is an F-Script block (which will be familiar to anyone who has used Smalltalk or Ruby) where the noteTool and playhead arguments are Cocoa objects being passed, transparently, from Objective-C. Equivalently the F-Script code can call the setSkip: method in the other direction.

The F-Script Block class even used a category on NSString so you could write:

[[@"some f-script code" asBlock] value]

to evaluate arbitrary F-Script code from Objective-C. Very nice.

However as nice as this was F-Script felt very alien and I could see it being a stumbling block to other people playing with Elysium (due out RSN). All the time I was using F-Script I was thinking "If only I could get Javascript bridged like this."

In the end I hunted down the author of the Leopard BridgeSupport tool, Laurent Sansonetti to ask him. His reaction was "Why not use Ruby?"

Why not indeed?

Well because I've done it before and it doesn't work very well.

"But what about MacRuby?"

It turns out that MacRuby is getting pretty real, is bridged just like F-Script, uses Objective-C collections and even shares the Objective-C garbage collector (which JSCore would not have done). Given that I love Ruby and would prefer to write it than F-Script or Javascript I was sold.

So, you've read the boring pre-amble. How is it done?

First you have a choice, use MacRuby 0.3 (the last release) or Trunk. Laurent is still working on the GC code which can make trunk unreliable but, for various reasons, that's where I ended up. While working on this Laurent cooked up a MacRuby API for Objective-C which is a pretty good reason to pick trunk (or wait for 0.4).

So checkout MacRuby trunk:

svn co http://svn.macosforge.org/repository/ruby/MacRuby/trunk MacRuby

By default MacRuby is setup to be installed in /Library/Frameworks which we don't want. We want it ready to embed in an app, so from the command line:

rake BUILD_AS_EMBEDDABLE=true
DESTDIR=/tmp/build rake install

this will "install" MacRuby out of the way so you can pick out the framework and delete the rest. From your Cocoa project, copy the framework in.

cp -R /tmp/build/Library/Frameworks/MacRuby.framework .

So, now you have the framework. In your Xcode project (or wherever) add MacRuby.framework as a linked framework (don't forget to also add it to your copy frameworks build phase).

From here it depends on what you want to do but I will describe what I did.

I wanted the user to be able to edit small snippets of code that would be attached as callbacks in various places (e.g. when a layer runs or has run, or when a tool is about to run). My experience with F-Script told me I wanted some kind of RubyBlock class and a similar category on NSString for making them.

In my code I have an NSWindowController subclass to handle inspectors that allow callback management for example:

#import "RubyBlock.h" // in turn #import <MacRuby/MacRuby.h>

- (void)editWillRunScript:(ELTool *)_tool_ {
  RubyBlock *block;
  if( !( block = [[_tool_ scripts] objectForKey:@"willRun"] ) ) {
    block = [[NSString stringWithFormat:@"do |%@Tool,playhead|\n# write your callback code here\nend\n", [_tool_ toolType]] asRubyBlock];
    [[_tool_ scripts] setObject:block forKey:@"willRun"];
  }
  [block inspect];
}

Here I steal another trick from F-Script in providing inspect on the RubyBlock class and an associated ScriptInspectorController (and Xib) that pops up an editing window. Right now it's no more than an NSTextView with an 'ok' and 'cancel' buttons but it's still a nice to have.

This block encapsulates a Ruby proc and can be called via one of:

[block eval]
[block evalWithArg:x]
[block evalWithArg:x arg:y];

and of course we could add more or a generic that takes an array or something.

Under the hood the RubyBlock class uses one method from Laurents shiny new MacRuby class to generate the proc:

- (void)setSource:(NSString *)_source_ {
  source = _source_;
  NSString *procSource = [NSString stringWithFormat:@"proc %@", source];
  proc = [[MacRuby sharedRuntime] evaluateString:procSource];
}

Pretty simple. We make a proc out of anything we're passed. Now I also added (with a lot of help from Laurent) some methods to MacRuby via category for eval'ing procs. I won't go into the implementation here but it means, for example, that RubyBlock can evaluate as simply as:

- (id)evalWithArg:(id)_arg1_ arg:(id)_arg2_ {
  return [[MacRuby sharedRuntime] evalProc:proc arg:_arg1_ arg:_arg2_];
}

I'll be making the source to RubyBlock and the categories NSString+AsRubyBlock and MacRuby+EvalProcs available either separately or as part of MacRuby itself. If you're in a hurry send me an email and I can share them with you now.

The upshot is that by embedding MacRuby I can now very simply create Ruby procs that can be called from Objective-C using a convenient syntax and that can interact with the Objective-C quite naturally. This is a big usability win, not least because it means I can write Ruby for my scripts.

I'm very grateful to Laurent Sansonetti both for his herculean efforts with MacRuby and for his patient efforts with me.

For those of you who are interested in generative music a public beta release of Elysium is imminent.

09/10/2008 22:14 by Matt Mower | Permalink | comments:

Put some lipstick on the pig

Mike Ash is voicing his opinion about the state of Mac development tools, in particular the de facto standard, Xcode:

Xcode sucks. If you're reading this blog then this is probably like saying "the sky is blue". You know already. Big surprise. The debugger fails all over the place, autocomplete is broken more often than it works, and the editor won't perform acceptably until you throw four Xeon cores at it.

I've already given up on XCode for editing, I use TextMate and relegated Xcode to the task of project & build management (for which purposes it is about adequate) and debugging. I learned last night that gdb is considerably more robust when not run via Xcode. So, in future, I will probably forgo the Xcode interface and learn gdb directly. At this point I am open to replacing XCode even for build management. Some, like Ciaran Walsh, already have.

I have to say that, as good a concept as it is, even the new Interface Builder (as much as it may be better than the version before) also sucks pretty badly with it's own weird behaviours and glitches. The "special relationship" between Xcode and IB probably doesn't help in this regard. I'm pretty sure that when IB decides to hang opening one of my Xibs it is because of Xcode.

What I often wonder is; Do Apple engineers themselves use Xcode and Interface Builder? Despite what I've heard about the number of people working on the Xcode team I find it hard to believe the tools are well used inside Apple. How could they put up with it?

I'm a hobby coder so only using these tools for a few hours at a time and not for critical work. If I was depending on them day in, day out I'd be outside the Xcode team office with a torch, pitchfork, and a mob of angry villagers.

Maybe it would be an idea for the Logic or Final Cut team to job swap with the Xcode & IB team every now and again and try and put some lipstick on these suckers.

09/10/2008 10:11 by Matt Mower | Permalink | comments:

Not quite alert enough for me.

I have a vanity google alert (don't we all) which, every now and again, finds something interesting. Lately though it's been turning up email threads, from 2004. I wish it wouldn't. They keep reminding me I used to write a lot of Java code ;-)

08/10/2008 14:57 by Matt Mower | Permalink | comments:
More about:

The joys of parsing ruby

Ryan Davis on parsing Ruby:

There are 28 cases of my lexer checking lexstate and 63 cases where the lexer is setting lexstate. That by itself is absolutely fine. It is the additional 17 cases where the parser TELLS the lexer what the lexer state is that absolutely terrifies me.

Ruby is such a contradiction. So much of the language is beautiful, yet there is cruft and by god never look at the source.

At this point it's probably impossible to sort it out.

08/10/2008 10:41 by Matt Mower | Permalink | comments:

How many millions to determine this

So, here it is:

A National Research Council report, years in the making and scheduled to be released Tuesday, concludes that automated identification of terrorists through data mining or any other mechanism "is neither feasible as an objective nor desirable as a goal of technology development efforts." Inevitable false positives will result in "ordinary, law-abiding citizens and businesses" being incorrectly flagged as suspects.

Is there any chance that our government (let alone the US govt) will actually listen to this report?

08/10/2008 10:10 by Matt Mower | Permalink | comments:
More about:

Tiring, but good

The last couple of months my health has not been that great and to my dismay I was forced to take a break from doing karate. It had become such a regular facet of my life that it was very hard not going and this, in turn, I think didn't help. I kept putting myself under pressure to go back.

Taking the last few weeks off and relaxing seems to have done me a power of good. I went back tonight and while I am now tired, sore, and sweaty I feel pretty good to be back and am hoping that I can put it all behind me.

Something that this time off has given me is a little perspective on my practice. When I start something I tend to barrel into it, full tilt. Getting a black belt is a visible sign of "progress" but if you think of karate as a lifetime activity it becomes, essentially, meaningless. I hope, in future, to practice a little more diligently focused on the here and now.

07/10/2008 19:35 by Matt Mower | Permalink | comments:
More about:

Back

I'm back to work today after 2 weeks of holiday. My first real holiday (as in, leave behind work, laptop, and worries) in several years.

I went to Philadelphia to see R. No flight problems which, after Paris (yes I still hate you Air France), was a big relief. It's the first time we've seen each other for so long, it was great. I hope it won't be too long before we see each other again. Philadelphia is a lovely city. I thought being so close to Washington, New York , and Boston it might be overshadowed but it has a character of it's own. It's a real walking city as my legs can attest.

After Philly I spent some time in NY and mainly wandering up, down, across, and around Manhattan stopping frequently to read (and fiction by god!), drink coffee, and watch the world go by. I may not be much of a one for sights, or lounging on the beach, but I love observing people. Must be the psychologist in me. I also got to catch up with Bethlet after a year or more. Great to hang out with her again, like old times :)

I bought a Sony PR-505 E-Book Reader before flying off and it's been great. The screen is fantastically readable even in low-light conditions. It has revived the art of reading fiction for me which I was beginning to suppose was entirely dead. It is also encouraging me to read classics that I just never got around to (I just finished 'The Picture of Dorian Gray' which I have been meaning to read for maybe 15 years). I am really sold on this device and looking forward to seeing the next one which is supposed to be touch screen.

Okay, let's get this show on the road.

06/10/2008 09:17 by Matt Mower | Permalink | comments:

O2 should be ashamed to call their network 3G

While I love my iPhone to bits I am afraid the same cannot be said for O2's "3G" network. The phrase "utterly crap" springs most readily to mind. I seem to have inverted my situation while with T-Mobile where their network was fine (I got 3G almost everywhere) but the handset was useless.

What shocks me more than the number of places that I don't get 3G is the number of places where I don't even get Edge but am reduced to GPRS speeds! It's 2008 goddamnit!

I think O2 should be ashamed of the performance of their network, calling it 3G seems to me to be something of a stretch.

Update: and while I am bitching I just got my first bill from O2 and it was for over £70. Turns out calls in the US, even to other US numbers, are charged at a flat rate of £0.90 per minute! Scandalous!

06/10/2008 08:54 by Matt Mower | Permalink | comments: