1
Dec
2008

Announcing Blog*spark

(cross-posted from Blog*spark)

As I wrote on my personal blog, I am working on an iPhone app named Note*spark with a guy named Mike Schiff. We’ve decided call ourselves Meta*spark, which is a name that only a programmer could love (which reminds me of a story that Andy Hertzfeld used to tell, in which Bill Atkinson supposedly loved the name “General Magic” because it could be used no matter what the company ended up doing).

Anyway, the new entity has a new blog, called Blog*spark. Mike and I will be posting somewhat frequently about Note*spark and any other things we end up doing. Among other things, we’ll try to post about things we’ve learned while developing an iPhone app that others might find useful. In the meantime, I’ll still continue to post infrequently about other stuff over at my personal blog. And while the transition happens, I will cross-post interesting things between the two.

As we have been developing Note*spark, I’ve been downplaying Note*spark to friends and family as “the smallest iPhone application we could think of that would actually be somewhat useful.” Because iPhone development is so new, we frankly don’t know if we’ll end up making $5/month or $5000/month on this piece of software, which is why we wanted to start small.

That having been said, it is very exciting to be so close to releasing our first piece of software. If you are interested in following our news in detail, subscribe to blog.metaspark.com. And if you’re not, feel free to just read kuwamoto.org, where I will try to cross-post the interesting bits.

21
Oct
2008

Need beta testers for a new iPhone app

Hi folks. Well, it’s time for me to break my radio silence. I’ve been away from Adobe for a year, and I’ve now worked on three projects since then.

The first project was a big project. The kind that you end up trying to build a startup around. I’m still interested in getting back to that project at some point, and I’m not ready to talk about it yet.

The second one was a smallish project. The kind of thing that one person does in his basement for a year. I might do something with this project at some point like publish it or give it out as shareware, but I’m not sure. This project was more along the lines of the kind of thing I did a lot at Macromedia: tools for web developers.

The third project is a tiny project. Coincidentally enough, it’s also the one that we managed to finish. (go figure).

So now we need beta testers.

The program is called Note*spark, and it’s very modest, but we think it’s useful. Basically, it allows you to take notes on your iPhone/iPod Touch and access them over the web. It also goes the other way: type in notes while you are at your desktop machine and you’ll find them on your phone.

Your phone keeps its own copy of the notes so you can access them even when you don’t have network connectivity.

It also allows you to share notes with others. My wife and I now use this for things like keeping track of the things we need to do before our relatives come visit for Thanksgiving. As each of us adds new items, the other person sees it automatically.

We wanted to keep the UI pretty clean and simple, although it does handle some pretty gnarly things like conflict situations, with visual diffs, etc.

So like I said, it’s a tiny app, but we think it’s useful. If you’d be interested in beta testing, we would be very grateful. Just visit the form at:
http://notespark.wufoo.com/forms/notespark-beta-program/

2
Jul
2008

Objective C, readability, and language design

For the last several months, I’ve been teaching myself Objective C and Cocoa. On the plus side, the framework is well designed. It’s the Objective C syntax that still has me tearing my hair out.

Square brackets

The biggest difference between Objective C and C++/Java/C#/ActionScript is the syntax for sending messages to objects. Instead of using dots or arrows, you use square brackets:

ActionScript / JavaScript
foo=object.method()

Objective C
foo=[object method]

Looking at it like this, the syntax doesn’t look half bad. The problem comes when you start chaining these methods together.

Let’s say you want to get the screen bounds of the window that holds a view object:

NSRect screenRect = [[[myView window] screen] frame]

Reading this syntax isn’t bad, but writing it is a pain. Every time you want to add a new method call at the end, you have to go all the way to the beginning of the line to add an open square bracket.

Long names

To compound matters, most of the method names are much longer than above:

sortedDocuments = [[[documents allKeys] filteredArrayUsingPredicate:predicate] sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];

By shortening some names (e.g., filteredArrayUsingPredicate -> filter) and using dots and parentheses instead of square brackets, you might end up with something like this:

sortedDocuments = documents.keys.filter(predicate).sort(caseInsensitive);

Strings and collections

Some languages, such as C# and ActionScript define string classes as an integral part of the language. This allows those languages to add common operations like string concatenation directly into the language. Others, like C++, do not define strings directly in the language, but allow class designers to override operators to, in effect, extend the syntax of the language.

In Objective C, string objects are only barely integrated into the language. The only concession to usability is that there is a syntax to define string literals (@”xxx”).

In order to concatenate strings, you end up doing something like this:

ActionScript / JavaScript
"The file " + filename + " could not be found."

Objective C
[[@"The file " stringByAppendingString:filename] stringByAppendingString: @" could not be found."]

The same is true of collection classes, such as arrays and hash tables.

Objective C
[wordMap setObject:[words objectAtIndex:i] forKey:key]

ActionScript / JavaScript
wordMap[key] = words[i]

Frankenstein – Not 100% object-oriented

Like all of the C-based languages, there are weird cracks in the language where the object-oriented and non-OO worlds meet. In Objective C, you can define structs and objects, which work totally differently. You can define both functions (denoted by parentheses) and methods (denoted by square brackets). To confuse matters further, Objective C 2.0 defines getters and setters, which are accessed using dot notation, even though the implementation is done through methods, which normally don’t use dots.

One of the classic ways in which the OO and non-OO worlds meet is in dealing with primitive numeric types. Should an int be represented in the most efficient way possible (e.g., 4 bytes of raw data), or should it be a full-fledged object, so it can be used in places that expect objects (e.g., collection classes).

Many languages provide both primitive and object versions of things like integers, and Objective C is no exception. Modern languages like Java 5 and C# simplify this through automatic boxing/unboxing, which means that these languages automatically convert between primitive types (e.g., int) and the object types (e.g., Integer).

Here is a line of actual code that I wrote the other day:

Objective C
[dict setObject:[NSNumber numberWithInt:prio++] forKey:[NSNumber numberWithInt:matcher.type]]

Now you might look at that line of code and say that it is too complicated to put on a single line. Well, if the language (a) had built-in hashes, and (b) did auto-boxing/unboxing, the above line would look like this:

Hypothetical Objective C with hashes and boxing/unboxing
dict[matcher.type] = prio++

Syntax is important

From a mathematical point of view, the specific syntactic choices are not all that important in defining what a language can do. But from a human point of view, the purpose of a language is to make it easy to express and communicate ideas. Computer programs are hard enough to read and write as it is. To the extent that a syntax makes it hard to express ideas clearly, it makes the task of programming harder than it needs to be.

For those of you who like Objective C, I know… I know… every language has its warts. I spent a good chunk of my life working in C++, and I know that a badly written C++ program is as hard to read as the worst Perl program.

To be fair to the other side, maybe the issue is that I know the warts of C++, whereas I am only now learning new warts in Objective C. So maybe I’m just overreacting when I tear my hair out and throw things across the room.

Yeah, right.

14
Jun
2008

Aquavit deathwatch?

Last night, jean and I went to Aquavit in Manhattan. The food was phenomenal. The service was great. The decor was good. So why was the place more than half empty at 9pm on a friday night?

There is a sadness to eating delicious food in a half empty restaurant, which is preferable to the indignation I feel when eating lousy food in a crowded restaurant. (Actually, let me correct that. Half empty restaurants don’t have to be sad. The most joyful experience is to eat great food at a place that is half empty because it hasn’t been discovered yet. Why is that? Is it the snobbish joy of being “in”?)

The whole experience left us shaking our heads wondering what went wrong. Are new yorkers just over the herring and lingonberries? Is itthe lack of foam and xanthan gum? To be fair, the place has been arpund for 20 years and maybe people just want something new.

Was it worth it? I think so. For us San Francisco hicks, a chance to eat upscale Swedish like this is a treat. All of the dishes were great, and some were mind-blowing. One of the standout dishes was a combination of foie gras, duck confit covered in crisped rice, arugula sorbet, and apple puree.

Tonight, we eat at Degustation, which, being a 16 seat restaurant, had better not be half empty!

10
Jun
2008

Ack! I’ve been blocked by Google! (and what to do about it)

A few weeks ago, I got an email from Google saying that my site was full of spam, and that my site was being removed from the indexes. The email contains a sample of the spam words (in my case, it was viagra, cialis, etc) Sure enough, it turned out that my blog had been hacked to include lots of words/links that were made invisible via CSS. Pretty distressing stuff.

For those of you in the same boat, here’s what I did to remedy the situation:

1) Most of the damage was in the form of obfuscated code that made use of base64_decode(xxxx). To find this code, go to the root of your site and do a grep base64_decode -Rl ./* It should be pretty easy to use your judgment about what code to remove. This code was inserted into my theme files (found in wp-content/themes/ThemeName).

2) To be extra sure, do a Google search for the offending words on your site. (e.g., viagra site:kuwamoto.org). For me, this turned up another problem with the site, which was that URLs of the form http://kuwamoto.org/?aff=1234 were being redirected to a different site (selling pharmaceuticals, natch). This code wasn’t obfuscated with base64, so I didn’t catch it in step 1. In my case, it was an extra file, so I just blew it away.

3) Look through your posts, pages, comments, etc. In my case, one of the links on my blogroll had been compromised.

4) Upgrade your WordPress installation. As recommended in the WordPress documentation, I used the automated upgrade plugin which worked like a charm.

5) Follow the recommendations at http://www.noupe.com/how-tos/wordpress-security-tips-and-hacks.html and http://sitening.com/blog/2008/04/08/wordpress-security-vulnerabilities/.

6) If you are using a hand-rolled theme (as I was), make a copy of it somewhere so it is easier to restore if it ever gets hacked again.

7) Change your passwords, and make a promise to yourself to be good from now on (keep WP and other software updated to the latest version, use SFTP instead of FTP, etc).