a glob of nerdishness

March 31, 2010

Taking Pills

written by natevw @ 1:19 pm

My name is Nathan and I have ADD.

I know it’s vogue to glorify our overloaded lives and our craving for instant happiness with a generic “Whee, I’m so ADD!” It’s a fair enough analogy, but that’s not what I mean. There’s also a tendency to romanticize the effects of real ADHD. My disorder has its moments, but contributed greatly to my depression through college and my frustration at work since:

  • ADHD is killing precious time because what I need to be doing is boring.
  • ADHD is wasting extra time because what I am doing is too exciting to just finish.
  • ADHD is rambling on and on instead of listening to others.
  • ADHD is buying into lust for possessions that shouldn’t own me.
  • ADHD is brainstorming a thousand ideas when I should be sleeping.
  • ADHD is chasing an emotional high with no regard to its consequences.
  • ADHD is staying consumed by unfinished projects while my family yearns for my missing attention.

ADHD is trying to overcome all that, while being undermined by all that, while the past grows ever larger and the future arrives ever faster. After trying “on my own” for way too long, I read Reaching for a New Potential. It’s a well-written book about adult ADHD, and convinced me of its thesis: “It is the combination of treating the disability specifically and strengthening the non-disabled parts generally that helps us succeed.”

By “treating the disability specifically”, the author means: medication. As a kid, I took ritalin every school day. I was still hyper, but could channel my creativity and close my mouth often enough to make most teachers proud. After 8th grade I stopped taking the pills; my high school provided enough challenge, emotion and structure to compensate. I began to look at medication as something like cheating. You know, the New Yorker published this article about how stimulants are being exploited as study drugs, neuroenhancers used to get ahead in the rat race.

The fact is, ritalin and a few of the other medication options are stimulants. They can be used like caffeine, they can be abused like cocaine. But decades of proper prescription have shown that ritalin can provide an additional, special effect against ADHD. I’ve come to accept that — along with needing glasses to see clearly, and lactase supplements to digest dairy products — I need pills to respond properly to extrinsic motivation.

And if a meandering fifteen page exposé of “study drugs” implies that pills make my accomplishments phony? Well, Easter weekend tells just how God swallowed up all my broken failures and phony triumphs and gave the final success to Jesus. If taking Ritalin is a constant reminder to claim his accomplishments and not my own, so be it.

March 15, 2010

Android isn’t for me (yet?)

written by natevw @ 12:35 pm

Tim Bray wants to learn how developers approach the Android platform. Pouring disproportionate effort into things that don’t matter and don’t make money is what Tiggers do best, so I lost the entire morning agitating a few quick notes into an essay that would then swallow my lunch break for rewording. But hey, free blog post, right?


Greetings Mr. Bray,

I enjoyed your post about how you’ve joined Google to promote Android. I’m watching with interest as the platform improves, but I still can’t imagine myself spending any time on Android development. Here’s why:

Java

This one’s probably the most ridiculous, so I’ll get it out of the way. Java makes the Android feel more accessible to many coders, but I decided long ago that I’m not going to learn this era’s diploma homework. I’m stubborn, idealistic, and I’m going to stick with C++ as the only language bureaucracy I navigate. Can I develop for Android without learning Java or dealing with bloated Eclipse?

User interface

Surely the Nexus Two will fix the spacebar issue, just like the Nexus One fixed the Droid’s issues and the Droid fixed the “Android sucks” issue. But seeing the ugly little plus and minus zoom buttons in Maps was a huge shocker. It made me realize just how much multitouch matters. I’m glad Google is finally starting to step up in this area, but am worried the trend has been set for interfaces cluttered for finger-as-stylus, rather than direct manipulation.

Culture

I’ve only seen Android phones in the hands of Windows power users. Others try Android devices but get fed up with the platform’s overall sloppiness and leave. Who stays? It’s great that some people love rooting their open source phones, but I’m worried my carefully considered interface simplifications will be a liability in that kind of Android Marketplace.

Skynet

I don’t want to pour my life story into Google Calendar, Google Reader, Google Docs, Google Picasa, Google Mail, Google Finance, Google Health, Google Politics, Google Faith… just to keep my laptop in sync with my pocket. What’s really worse: a centralized developer app store, or a centralized user data store?

HTML5 / iPad

I’m young in the Mac development world, but waving goodbye as all the Xcoders board boats they’ll burn on the shores of the App Store. The iPad’s siren call has already lured back many who had gotten fed up with iPhone development. Despite being a compiled code, native API, local data junkie, I’m being driven towards HTML5 to avoid being left behind. There are many exciting things going on in HTML that make it viable for even anti-centralized apps. If Android gets sued into oblivion or Windows Mobile-ed into irrelevance, then Chrome OS is the future in a nutshell.

Cost

I write shareware and do contract work to scratch a living in rural WA. (When I say rural, I don’t mean “a suburb with trees”. I mean, corn and cows and lousy internet.) Given all the other points above, paying $529 just to kick the Android tires is a bad investment, especially when I could permanently lease one of Steve’s Safari Pads for thirty dollars less.

March 13, 2010

Numbers spreadsheet for 2009 IRS Form 1040 tax preparation

written by natevw @ 1:58 pm

I shared a Numbers template two years ago that helped me estimate my 2007 taxes. In 2008, I co-founded Calf Trail Software, LLC, and let an accountant do the filing. That luxury ended up being a major financial setback, so the spreadsheet is back:

Sample scenery from the 2009 federal tax Numbers worksheet

I’m sharing my efforts under a Creative Commons license again, so you can download my 2009 Federal Tax Form 1040 worksheet as a Numbers.app template.

Reminder: Don’t trust the results of this unofficial spreadsheet. It is not a substitute for the official forms, instructions, tax tables, or the advice of a certified accountant. Please do let me know if you find any errors, though.

January 29, 2010

A story NOT about iBooks.app

written by natevw @ 10:35 am

Some fellow perfects the bound book. He threatens to have drawn and quartered anyone who tries to make a similarly improved book. Then he says to the writers, “If I like what you write, I’ll bind it as one of my books and give you most of the profits.”

Some experienced writers say, “Silly books, clay tablets are so much better at knocking sense into people. Part ye from my paddock, fellow!”

But this man’s books are very well made. And so long as you don’t write a sequel to one of his own stories, or speak against his friend the mayor, you can make a good bit of money writing bound books. Most writers respond, “Books are clearly the future, and look how good they are for the readers!”

But there’s this other crowd. They’re not really writers, because they spend most of their time patting themselves on the back and talking about politics and how the future isn’t clay tablets or bound books, because papyrus scales so much better. Some of them are stitching their scrolls together so they can be read kind of like books. These scroll-books are a bit awkward to page through, but you can read them in any library branch and even sign some of them out for a few weeks.

Now the interesting part of this story is that scrolls and, by extension, scroll-books can actually be used on clay tablets and between any sort of book cover, including our book-binding fellow’s. The analogy is falling apart now, so I’ll finish explaining my previous post more directly.

No cheap, flimsy Chrome OS netbook will have more necessary features or be more pleasant to use than the iPad. I am also sure that native, platform-specific applications will always be superior to web-apps. What I am saying is this: until we can develop native iPhone/iPod/iPad/iPony applications with our First Amendment rights intact, making “native Chrome OS applications” (i.e., web apps) is the only way to publish independent software for Apple’s newest and best devices.

January 28, 2010

A Gradual Divestment

written by natevw @ 10:13 pm

I’ve been thinking about the last two years’ investment on a number of levels. Regarding the platform I chose, I’ve been struggling to find the right words for several months. I came across them today, at the end of a dead-on post by Alex Payne:

Wherever we stand in digital history, the iPad leaves me with the feeling that Apple’s interests and values going forward are deeply divergent from my own.

I’m most energetic while inventing a self-contained tool to improve some aspect of life. Writing native software for OS X was a dream come true. I hope the Mac’s open platform has many good years left, but it’s time I learn to enjoy building native software for Chrome OS as well.

January 22, 2010

Busyness

written by natevw @ 8:33 pm

It’s been a busy week!

The biggest event was announcing the departure of my friend and Calf Trail co-founder Hjon from the company. It’s been in the works for a while, but this week we officially transferred the iPhone half of our work over to Hjon’s new LLC: Pseudorandom Software. (If you use FogBugz, be sure to check out his great Inbugz app. Despite keeping busy with other jobs, he’s got some useful new features in the works.)

The other big announcement was Sesamouse, a free utility to send real gestures and touches from the Magic Mouse. Translation into dev-speak: Sesamouse gives legitimate applications access to the Magic Mouse’s otherwise-crippled multitouch hardware features. It contains the private/undocumented API gunk within its own process, interpreting gestures and sending the system its results. Applications that use the publicly supported NSEvent and NSTouch APIs then work with the Magic Mouse automatically. Accomplishing this involved many hours staring at hex dumps and learning to read assembly, with a helpful boost of UTSL. Quite a fun challenge!

In the midst of all this, I also made some great strides on another iPhoto-related app this week. It currently lacks the finishing touches, but my wife and I already have fun testing it. Plans call for a beta release next week.

I’m hoping to give Calf Trail’s lineup of Mac products a big boost during the early part of this year. That way, even if sales don’t pick up, I’ll have some good stuff sitting out there while I’m busy finding paid work. I’ve been thinking a lot about the last two years’ investments…but that’s a topic for another post.

January 5, 2010

Jorb application

written by natevw @ 6:20 pm

It’s a gracious privilege to be reminded of the coming of our Savior one week before a new year begins. I needed a silent, holy night to shed a little light into my valley between decades.

Despite all that’s on my mind, I’m not ready to write. Even — no, especially — about past and future technological investment. I remain incredibly fortunate in many many ways, but there’s this malaise. Frustrated undertones host subtle lies. So in lieu of 2009 in review or resolutions for 2010, here’s a message from the sponsor here at a glob of nerdishness. DON’T TOUCH THAT DIAL.

Not code monkey nor offshore,
I build software: Hear me roar!
Servers, browsers, small chips and multicore —
Cocoa's great but I shun The App Store.

My rates are low, I'll tell you why:
I live and learn and time sneaks by.
Give me freedom to explore;
you'll find that I deliver more.

I cannot work the nine to five
'cause I've got other things to keep alive.
But if by email the tasks arrive
I could help your project thrive.

It’s cheesy because it’s true. Contact support@calftrail.com if you’re in need of some custom programming work and think I might be good fit. *cue outro jingle*

November 19, 2009

Twitter context bookmarklet

written by natevw @ 2:03 pm

Sometimes I’ll end up on an individual Twitter post that is obviously a continuation of a previous train of thought and wish I could see the context without having to re-find the tweet way back in the user’s stream. According to the interwebs, Twitter has been hiding a solution to this for a while, but I just noticed it today.

I’d be surprised if someone hasn’t already done this, but I’ve whipped up a bookmarklet that makes it easy to jump to a tweet in its context:

Tweet context

Just drag that link to your toolbar, and click to go from a standalone tweet to the stream of posts leading up to it.

November 18, 2009

Go Unicode

written by natevw @ 3:27 pm

I’ve been eagerly learning about Go lately. It’s a nascent systems programming language with a nice design and some great features.

I have also gotten back into reading through my Unicode 5.0 book during the past weeks, so when I saw that Go had a built in string type I was immediately curious as to what that meant. My initial conclusion was not good.

Then I realized one of the Go team’s earlier inventions was UTF-8, a Unicode encoding with many pragmatic properties. After a little more research, here’s the skinny.

Go’s strings:

This last point could be seen as a drawback, because it means that <LATIN SMALL LETTER E WITH ACUTE> will not compare equal to the equivalent <LATIN SMALL LETTER E> + <COMBINING ACUTE ACCENT>. However, to do this natively in Go would require each standalone binary to include a large set of character code table information. Furthermore, there are two equivalence forms defined by Unicode. I have an opinion on which one the Go compiler itself should eventually use for token comparison, but for runtime use neither could serve as the one meaning of the string comparison operator.

Like so much of Go’s design, the way strings work is an elegant compromise that encourages useful idioms without making decisions a programming language shouldn’t. Normalization goes beyond settling the encoding question, and begins a climb up the tall stack of human language concerns. (Check out the ICU project for a sampling of basic Unicode toppings.)

One final note about the implications of Go’s string type: In C, it can be tempting to use string functions on binary data known to contain no inner ‘\0′ bytes. Go’s type system should make this obvious, but use uint8 slices — and never strings — for binary data in Go. Even if your bytes have no terminating ‘\0′ characters, trying to iterate over binary data as string characters will not yield what you expect due to the way UTF-8 encoding works.

October 28, 2009

A moderate improvement to Cocoa’s Key-Value Observing

written by natevw @ 3:55 pm

The background

Key-Value Observing (KVO) allows Objective-C instances to track changes in the properties of other objects. It is a powerful programming tool and is implemented in an interesting manner. But the API to use it is lamentable — Apple’s interfaces usually stand out as shining examples of object-oriented design; the interface for registering and unregistering a KVO observer feels like an accident that can’t even be fully documented.

It is something of a rite-of-passage for Cocoa programmers to to workaround the weaknesses they see in Apple’s provided KVO interface. The inability to unregister an observation without upsetting a potential subclass had bothered me, but only in a theoretical sense, so I mostly ignored it. When I started writing a Garbage Collected app, I realized the time for my workaround had come, and I finally wrote NSObject+TLKVO.

The foreground

As implied by the name, NSObject+TLKVO is a category on NSObject. It replaces Cocoa’s built-in KVO -addObserver and -removeObserver methods with ones that solve two problems:

  • Each class can safely start and stop observing a key path without disturbing its subclasses
  • To run under Garbage Collection, a class does not need to implement some rubbish extra reference counting to safely remove itself from observed objects

As a bonus, it’s not even necessary to remove TLKVO-registered observers in garbage collected code at all. Memory-managed code can conveniently unregister all observations for a given class with one line of code as well.

I keep mentioning how a “class” registers for an observation. This is the key to the TLKVO design: it doesn’t change the overall KVO mechanism, it just refines it by making registration/unregistration for a key path unique to an instance AND a Class, rather than just an instance.

The code

Using it can be very simple:

TLKVORegisterSelf(watchedObject, @"watchedPath.watchedKey", NSKeyValueObservingOptionNew);
TLKVORegisterSelf(watchedObject, @"anotherWatchedKey", NSKeyValueObservingOptionNew);
TLKVOUnregisterSelf(watchedObject, nil);

or:

[watchedObject tl_addObserver:self ofClass:[MyClass class]
forKeyPath:@"watchedPath.watchedKey" options: NSKeyValueObservingOptionNew]
[watchedObject tl_addObserver:self ofClass:[MyClass class]
forKeyPath:@"anotherWatchedKey" options: NSKeyValueObservingOptionNew]
[watchedObject tl_removeObserver:self ofClass:[MyClass class] forKeyPath:nil];

It’s important to note that in second (non-convenience) example, I used [MyClass class] instead of [self class]. This distinction is key. At runtime, [self class] will return the class of the instance, which may be a subclass. Instead, TLKVO needs to know the class which you are currently implementing so it can properly unique the registration and properly target the change observation messages.

Observing the changes is basically, well, unchanged:


- (void)observeValueForKeyPath:(NSString*)keyPath
ofObject:(id)object
change:(NSDictionary*)change
context:(void*)context
{
if (context == &TLKVOContext) {
NSLog(@"Observed %@ of %@", keyPath, object);
}
else {
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}
}

The only difference to what you would write with plain-old KVO is the use of &TLKVOContext instead of your own unique pointer. If your class’s method is asked to observe a change with a context of &TLKVOContext, you can be sure that it is due to an observer registration made by the same class.

The what it doesn’t do

If you thought the context pointer could be useful for passing some extra information to your change observing method, you might be disappointed by not being able to define it yourself. This omission is intentional. Due to the design of Cocoa’s KVO, you can’t do any introspection of the pointer until you are certain that it belongs to your class. If you want to use an NSDictionary instance as this context, you need to keep its pointer accessible to the change observing method anyway.

You might argue that a single class may want to divide itself internally into separate sections and use different unique pointers to help sort out changes observed by each section. In that case, you probably also need more fine-grained registration and unregistration. Your -observeValueForKeyPath method is probably getting pretty complicated, too. At this point, you might want to check out…

The further reading

Another potential shortcoming of Cocoa’s KVO architecture is that all observer notifications get delivered to a single method. This can be convenient if all the changes are related, but sometimes this method becomes a readability bottleneck instead.

Several other developers have shared their improvements to KVO:

MAKVONotificationCenter
Mike Ash explains the problems with KVO much more clearly than I have, and provides an NSNotificationCenter-style replacement. Note that this was written before Garbage Collection, and read the discussion in the comments as well.
KVOBlockNotificationCenter
Jonathan “schwa” Wight has extended Mike’s idea and made it work better with Garbage Collection and blocks.

KVO+Blocks
Andy Matuschak presented a clean, simplified API for having a block fire for every change before 10.6 was released. I’m not sure if he’s released the code yet.

If you just want more information on using KVO as Cocoa provides it, check out Dave Dribin’s article on Proper KVO usage or this Apple framework engineer’s recommendations on the matter.

I may update this post if more KVO extensions or further reading come to my attention.

The random heading

« Previous PageNext Page »