2009-05-05

kelvSYC on Cocoa and Java

One of the more interesting exercises is how to program a Mac program
using the Cocoa framework while keeping all of your core program logic
in Java. It used to be trivial, but has gotten much less with the
deprecation of the Cocoa Java bridge (people are simply told to "use
JNI", which is still quite vague).

Now Cocoa relies on MVC - the model-view-controller paradigm. The
model (core program logic) would be in Java, and the view is basically
your Cocoa nib. The controller is pretty much where you use JNI. The
basic idea is that your controller object (in Objective-C) would be
associated with a Java object, and any IBActions that you write in
your controller effectively result in method calls on the Java object
(then, the Java object further interacts with the model).

Seems like a bunch of boilerplate, and there has to be a way to
automate this. My first thought is to write an annotation processor.
Given the Java source to the object's class file, could it be possible
to annotate this source in such a way so that the annotation processor
can write the necessary Objective-C classes and headers?

My idea is basically to have something like

@Controller
public class MyController {
@IBOutlet NSButton button;
@IBAction public void action(ID sender);
}

and have the annotation processor create a MyController.h which might
look something like this

@interface MyController {
IBOutlet NSButton* button;
}
- (IBAction) action:(id) sender;
@end

and a MyController.m with the necessary glue code (which is pretty
much changing the Objective-C message to a Java method call - I'm
going to go under the assumption that the generated code will also
create the association between Objective-C and Java objects by, say,
creating the Java object in -init). ID and NSButton in Java would be
interfaces/abstract classes standing in for their Objective-C
counterparts, using something like Rococoa[1].

Clearly, this idea hasn't been fully fleshed out (in particular, I
probably haven't properly dealt with "ID and NSButton in Java" part).
If anyone can pitch in with their input, that would be great.

[1] http://rococoa.dev.java.net

2008-06-27

Canadian cell phones

I've had it with Canadian cell phone companies recently. It's getting
to a point in which I can't even afford a cell phone for the most
basic of activities, like letting your loved ones know that you are in
a safe place.

Allow me to explain. GSM is the world "standard" for cell phones, and
I use it because I have to travel. Canada has only one such provider:
Rogers (you could say two, but the other would be Rogers' subsidiary
Fido, to which I currently have a contract). As such, they have a
monopoly, per se, on international-capable cell phone service
(technically CDMA is international-capable, but where I travel the
local providers only use GSM), and that's why they can jack the prices
as high as they want. Consider the reveal of Fido's iPhone price
plans as an example:

For $60, you will get 150 minutes, 75 SMS messages, and a 400MB
download cap. A Rogers representative says that 400MB will get you
"up to" 200,000 emails, 3100 web pages, or 1360 photos. Now 400MB
divided by 200,000 emails gives you 2K per email. Consider the fact
that this blog post, which I am submitting by email, is already more
than 2K of content alone - and that's just plain text. Some people
might get images and rich text and HTML, which bloats it even more.
Then there are the email headers that one receives. Now, with all
that considered, your 200,000 is more like 2000. For a better gauge,
consider "3100 web pages". That works out to 129K per web page.
That's fine and dandy for "just the web page", but your average web
page contains images and other "rich media". Facebook, for example,
is 1.2MB with all that rich media - and for a lot of cases, 1.2MB is
ridiculously low. 3100 would probably be closer to 350. So no web
surfing sessions or streaming media for you, I'm afraid. As for the
1360 photos, that's roughly 300K per photo. Last time I checked, when
I digitized my print photo collection, each photo is 1.4MB. Again,
there's no way you can reach 1360 - 350 is probably more realistic.

Then there are the minutes. Oh god is that low. My current plan has
250 minutes for $25. Ignoring SMS (which is a total ripoff IMO),
that's 400MB of data for $45, say - or 11.25 cents per megabyte. (If
you factor in SMS that number goes up) That is a complete insult when
you consider that many carriers charge less than a tenth of that.
Even metered ISPs charge less per megabyte. Oh well, that's what you
get when you pay broadband prices for dialup speeds in this country
(that's another thing altogether - Canada's telecommunications
industry needs a serious wakeup call).

Furthermore, according to the plan on their site essentials such as
call display costs extra. No other GSM provider I can think of
charges for call display. Then again, no other provider charges a
$6.95 access fee which is more or less a "hidden charge". Then
there's the three-year contract, which is standard practice in Canada
(among both CDMA and GSM providers), but it is so for the longest
iPhone contract out of the plans around the world being offered.

To add insult to injury, for $60US you could get an American iPhone
plan with unlimited data. There is no plan that offers unlimited data
by Rogers - partially because apparently it likes to traffic shape
your internet, and possibly throttle it. (This is another issue
altogether)

How does this all add up? The 8GB iPhone will set you $199, plus $60
* 36 = $2160 for the plan itself, plus $6.95 * 36 = $250.20 in "system
access fees", $0.90 * 36 = $32.40 for "911 Access Fee", gives you
$2442.60 before taxes. Assuming you live in Alberta, that amounts to
$2564.73 with taxes. That's nearly double of a comparable plan from
Britain, and the British plan from O2 has more features to boot (like
call display).

Sure, you could try to buy the iPhone without contracts elsewhere,
unlock it (or buy it from a place where it is illegal to lock phones),
and get a Canadian plan, right? Nope. Due to the upcoming C-61
(which I will assume will pass just because the Liberals are gutless),
it will be illegal to unlock phones in Canada (or, for that matter, to
sell unlocked phones, contrasting places where it's illegal to lock
phones or sell locked phones), and possession of an unlocked phone
won't be too far behind. This is just another manifestation of P5,
which I hate to the core (more on P5 at a later time).

It's been a long time that I've had to deal with this kind of crap, it
seems. But the reveal of the iPhone price plans was the straw that
broke the camel's back. I do not plan on renewing my cell phone
contract, and unless they slash their prices by 75%, I'm not getting
another cell phone from Canada - it's cheaper in the long run to buy
phones and plans elsewhere and use them in Canada. And you get better
service too.

2008-06-20

Welcome to my blog!

This is actually more of a welcome for me than anything else - it's my first blog post, and my first blog. All those of you out there, welcome, enjoy, and hope you like what I have in store...