The General Theory of RIAtivity

Pondering the New Fabric of the Web — Rich Internet Applications (RIAs)

Archive for October 2008

Concatenating Strings in Objective-C

with 23 comments

[Update 05-31-2009]
Since posting my original rant on the arcane syntax of Objective-C I’ve actually had a breakthrough in understanding Objective-C, thanks mostly to Evan Doll, of Apple, and his Stanford University lecture (course CS193P) whose notes you can access here. I highly recommend reading the lecture notes and watching the lecture on iTunesU and you too may find Objective-C to be approachable.

[Original Post]
I’ve been spending the past few days delving into Objective-C for an iPhone dev project my partners and I are working on. The single-most challenging thing about Objective-C is the syntax — it’s arcane. And for someone coming from years of JavaScript and Microsoft language-based development (VB, VB.NET, and C#), using Objective-C to do basic tasks is a bit more painful than gouging my eyeballs out with an ice pick.

Case in point: concatenating two strings together.

In JavaScript, it’s a simple matter of:

string1 = "string1Text";
string2 = "string2Text"; 
newString = string1 + string2;

Okay, I hear you — JavaScript is a weakly typed language, blah blah blah. But you must admit, concatenating strings in C# is pretty darn easy too:

string string1 = "string1Text";
string string2 = "string2Text";
string newString;
newString = string1 + string2;

 

Tinselman_Banner

 

Given, C# does alias the concat method with the + operator, making it fairly intuitive. With that sort of ease one would only ever use the concat method for a very limited number of scenarios (readability, etc.).

Now for the painful part. Let’s do the same in Objective-C:

NSString *string1 = @"string1Text";
NSString *string2 = @"string2Text";
NSString *newString;
newString = [string1 stringByAppendingString:string2];

I’m not counting ease by lines of code — they’re obviously all pretty much the same. But the fact that I have to know a method called stringByAppendingString: method is just stupid. Not to mention if I wanted to append a integer to string1, what happens then? More than likely I’d have to cast my integer to a string in an inline method call and then call the unnecessarily verbose stringByAppendingString: method.

Microsoft won the first PC vs Mac war by appealing to developers with good tools and fairly high-level languages. Apple should concentrate on the same now that their hardware and OS adoption is growing at a breakneck pace. Failure to appeal to developers will stunt their growth just as it did in 80’s and 90’s.

Written by riactant

29-October-2008 at 00:05

HVAC Parts Supply and Contractors Racket in Seattle

with 11 comments

Tonight we’re expecting the first really low temps and frost of the season so naturally it’s time to fire up the furnace. Unfortunately, after turning on the heat I noticed no heat was coming out, so I did some troubleshooting and noticed the hot surface ignitor on our Bryant 80 furnace was bad.

The next step was to call some HVAC parts suppliers in the Seattle area. I called three (HADCO, Kirkland, WA, GENSCO Everett, WA and King Heating Snohomish, WA) asking about availability of this $30 part and got the same answer — “we only sell to licensed HVAC contractors.”

Gimme a break. This is a part any DIYer can do; there are videos on YouTube walking you step-by-step how to replace an ignitor safely. I refuse to pay over $100 for a service tech to visit my home and replace this part.

I learned quickly after calling these few parts houses that the HVAC parts suppliers and service contractors are all in bed with one another — I even saw on one parts supplier’s website their bragging about the junkets they take their best contractor customers on yearly — trips to Miami to see NASCAR races for example. Why am I not surprised… dealing with HVAC trade folk is like trying to break into some secret club where you need to know the special vo-tech handshake.

Screw them — I’ll wait two days for my part which I ordered online to arrive and bask in the glory of knowing they didn’t fleece me like they do the rest of the populace.

Written by riactant

9-October-2008 at 15:00

Posted in Uncategorized