I've been working pretty extensively for the last year on an Android Mobile app for Busme! and to hook into my backend Ruby on Rails servers.The app is GIS based and runs over a scrolling map. It's pretty simple for the most part. The complex stuff lies within the logical bits of dealing with the backend and various user interactions.
The Android app has gone through a couple transitions during its time. The big one was a switch to Open Street Maps from Google Maps, mainly because of the $10K "gotcha", and because I'm a big fan of open data. With the use of OSMDroid and the availability of its source code, that transition was fairly straight forward. I am now using MapQuest's generous serving up OSM map tiles, thank you. Most of the other ongoing developments are conceptual in the user interface and interfacing with the back end. The Ruby on Rails side is a wholenuther story, which I will probably leave for a later date. But for the App, it's pretty much a couple of Overlays onto a scrolling map application. Pretty damn simple.
So, back to reality. For this company to go anywhere, I've been emphatically told that I need to have an iPhone app or it won't fly, and "nobody will use it". I happen to think there are a lot of Android users out there, but I like to be inclusive, so what the hell, I gave into the pressure to investigate.
The following experiment took a week and will be condemned as a complete failure. Although I wouldn't call it a *complete* waste of time, it was close to not being worth the stress and the strife, and, my (now X) girlfriend is amazed, disgusted, and flabbergasted at how much time I put into this project subsequently ignoring her for the most part. Call me a little OCD when it comes to architecture, development and programming.
So, I first thought, "Hey, how hard could it be?" Yep, I thought the job would be hard. I thought it hard in the sense that I had to carry tons of bricks from one side of the yard to another by hand -- simple job, just ominous. The Android is written in Java and the iPhone app needs to be written in Objective-C. I had thought, the two languages somewhat similar since they were both "object-oriented" and it might be straight forward. I'd just have to block out a bit of time to carry the bricks.
My conclusion? F8cking ridiculous! My first conclusion was that I should hire some immigrant to do this work, just for the shear tenacity it would take. But I don't have any money, so that won't fly.
First I thought, I'd like to reuse the same code I had in
Java for the Android. A lot of the code deals with the server and
internal data structures that in a MVC sort of pattern really have not a lot to
do with the UI.
Now, I've done a lot of compilers in my time, and figured I could probably get somewhat of a good translator going. But how much time do I have really? My ambition started to wain. Then, one day, there it was! Like playing the barn hay bales with bare feet, I caught the needle in a callus, I came across a Google project called j2objc, and I thought my life would change. These guys used the Eclipse parsers to generate abstract syntactic trees and already had several generations of it. It did translations of Java into some wacked version of Objective-C. They just didn't do any UI stuff, and rightfully so, because the respective UI components can really be different. Anyway, this was the boost I needed. I put everything else on hold to concentrate.
In hind sight of more grey hairs and further withering eyesight, the only thing that I can say about this project is that it helped me clean up my Android code. Just to even *think* about using j2objc, I had to refactor the Android code so that I separated most of the UI code to the "front" end and factor out the communication (HTTP, cough, cough) backend and I'd be set!
I couldn't be further from the truth.
Refactoring the Java code was actually fun. I was using Eclipse for my IDE mainly because it seemed to work well with the Android SDK. All I can say, is that I spent a lot of my academic life studying type systems. Type strict languages are shunned by students today and barely get taught at all any more, but the benefits are so completely obvious. Originally meant to help compilers squeeze as much efficiency out of your code, they are most beneficial especially in *mostly* strictly typed languages in the tools that help us code. The beauty of this Eclipse for Java IDE are the code generation and translation tools, and they are simply fantastic! I mean, gone are the days of that *unfortunate* method or variable name. Just a mouse click an a few keystrokes away, and it's renamed. Whether for better or for worse, but insurmountably so, it is correct and complete! Imagine trying to do that with C or some dynamically typed language, like Ruby (grrrr) for instance.
Anyway, I got the code refactored in about a day and made sure it still ran on the phone. I thought I was halfway there. I had to implement a good portion of the front end thingys like some alert dialogs, a few list UIs, and some text based things. On the other end, I had a couple of methods I needed to do HTTP gets and posts to the server. The process left me with a neat TODO list that manifested itself in the form of abstract method definitions in two classes, one for each end. Okay, I thought. I just put the bricks in a nicely separated pile ready for me to borrow that motorized j2obc wheel barrow and take them to the other side of the yard.
My first problem, I don't own a Mac OSX. Oh I did at one time, but the upsale tactics on the thing got me pissed off, and when my last one died for the second time, it got relegated to the bone yard in the attic. So, I borrowed my girl friend's. Now, talk about pressure, as she actually uses the thing, so time is of the essence. And, she was going away for the Memday weekend for a graduation and was leaving it here. Score! so, I thought.
First problem is that it has OSX 6 Snow Leopard. Nothing iOS on this thing actually worked. I had the biggest problem finding Xcode for it. My gawd, this thing is only a couple years old! I couldn't get Xcode 4, so this thing has got Xcode 3.2, but I went through about 30 blog posts to try to find out how to get a new enough version of the iOS SDK. The highest I could get was iOS4.3, and that wasn't easy. I wasn't shelling out some $120 for Mountain Lion especially on a machine that is working fine for its owner, who isn't a geek like me.
Next, j2objc. Requirements: Xcode 4+, iOS5+, clang 2+, and a few other things. I tried numerous things to get j2objc to compile, from jumping back and forth to Linux, etc. Finally after a couple of days. Remember, this is the tool that is going to do most of the work for me, and there was a slowly developing crevasse in the yard. I installed llvm 3.2 on the Mac, and what some of the kids call today "monkey patched" Xcode into believing it existed and to use it. None of that effort was obvious and easy either. Remember, I don't have any money, or time since the girlfriend will be back on Tuesday, and I'm heading out on a marketing trip (of which I did nothing for) and a kayaking vacation out in Idaho for 10 days. So, there is no time.
I was able to do the j2objc translations on Linux, because that is an all Java implementation. However when it came to linking the results together, it had to be on the Mac Box. I just could not get j2objc's JRE emulator to compile and link on the Mac. For one thing it needed NSRegularExpression, which apparently wasn't introduced until OSX7. I'd though, okay so I won't use them and I'll just cut them out. However, their implementation of other Java classes depended on it heavily. So, in the end, I took the already compiled binary from their site, and with the new LLVM compiler I got one link error, which I solved by creating the following:
void obj_setProperty_nonatomic() {
}
This resolved an unkown symbol of the same name, and no matter if it would make the whole thing crash, I just wanted the project to compile, and it did. We are nowhere near execution.
Then, began my foray into the land of Objective-C. All I can say, is WTFF? This has got to be one of the most hideous, heinous, horrible languages I've ever seen and laid my fingers on! How do people code in this monstrosity? Okay, being a *weakly* typed language, it has some hope with Xcode, but nowhere near the effort you get with Eclipse on Java. And the problem is you can get away without it in Java, in OBJC you need help. WTF? I mean, what caused some language designer to split the method name up among the arguments, as if that were some clever thought that somebody probably awarded with a PhD. I mean, really? I've dealt with some pretty horrible languages, like BCPL, and a few others, but none of them come close to this monstrosity. Who the hell wants to type out names like:
[self eatMyLunchWith:@"Joe" atPlace:@"Chatterbox" atTime:@"12:30" andSubject:@"Life"];
I mean, can you really read that? In most understandable languages that would be something like:
this.eatMyLunch("Joe", "Chatterbox", "12:30", "Life");
or
(eatMyLunch "Joe" "Chatterbox" "12:30" "Life")
The only language that comes close to this is Smalltalk, which would be
self eatMyLunch with: "Joe" place:"Chatterbox" time:"12:30" subject: "life"
However, in cases where it didn't matter those arguments could appear in any order. Not so in the Objective-C case. The above expression is effectively the following in a language that accepts a colon (:) as a literal character:
this.eatMyLunchWith:atPlace:atTime:andSubject:("Joe","Chatterbox","12:30","Life");
So, why not just have that syntax, so it's bloody succinct and understandable? The biggest problem we have here, is that we don't know what the first arugment is, really. Is it "joe", but the definition of that looks like this:
-(id) eatmyLunchWith:(NSString *) person atPlace:(NSString *) place atTime:(NSString *)time andSubject:(NSString *)subject {
};
Anyway, you get my point. I understand the underlying method to the madness is that you are sending messages to the object, but really does the coder really need to know that? Especially when you aren't going at it in a Smalltalk fashion? The only message you can send is 'eatMyLunchWith:atPlace:atTime:atSubject:' You can't split it up, and if you did you'd have to curry it up with brackets, which would make LISP look good. Oh and don't forget the final ":" or you'll get a "Unknown Selector". Sometimes I wonder.
The next thing is Xcode. Granted it is an aging IDE, but it has some serious navigation issues. This may have more to do with my Linux environment is 3 screens wide, and all I have is this lousy Mac laptop, but I couldn't figure out how to use it without getting cluttered really quickly.
Next is the C part of Objective-C. I'd routinely get SIGABRT signals and hardly an indication of where they came from. Back to the days of GDB and reading into the C stack. Gack! And with the Delegate stuff being thrown around it's just confusing. Apparently, there is some convention where the first argument is always the "sender" if the "message", but that's not always the case. This burns you more than getting hit on by your girlfriend's best friend, more than once.
After a while of pulling teeth, nose hairs, drinking way too much coffee, sitting in a chair until my legs hurt and my eyes bled, and my ass swelled, I gave up. I use RubyMine for my Ruby on Rails projects and during the last update, they mentioned something about RubyMotion, which I had thought was just a Javascript tool for iOS Webkit.
Doing a bit more research on it due to needing a break I found that you use it to develop for iOS in Ruby and you may include Ruby gems. I'm sure there are restrictions, but how cool is that? I don't have to code in Objecitve-C? It actually compiles its result directly into the OBJC framework, either into Objective-C or assembly code. I'll take it, and a beer.
So, that is event that made the definite point at which I, bleary eyed, tired, wigged out, frustrated, downtrodden, and worn out, gave up this project. Well, at least until I get back from the kayak trip. Although, I'm sure there are obstacles, RubyMotion might make it easier. I'm not a great fan of Ruby, but there is a ton of support out there, and tools like RubyMine make the job a lot easier and almost palatable, and there are a plethora of GitHub junk out there that is somewhat useful, although you spend a lot of time fixing other peoples' code.
The unfortunate reality is still, you have to pay if you want to play in the iOS biosphere. You still need a Mac OSX7, which can be upwards towards $1K-2K and RubyMotion is $200. They say it's that one price forever. However, if you want updates it's that price per year. Hell, if a Mac goes really goes that obsolete in less than a 2 years, to where nobody will support it, you'll need them. If you want RubyMine, which has support and tools for RubyMotion, *is* worth it at $70/year. However, RubyMine has nothing to do with a Mac and you can use it on as many machines as you want. Why you would want Windows, I have no idea. I tried that as well, and that's another story. Oh, and if you want to put your app on a iPhone or iPad, even for testing and personal use, you need to pay Apple $100/year.
What gets me, is how do people develop anything for this iOS platform? And if so, I hope they are making lots of money, because, it's f&cking painful. Also, I tried looking around for "widgets" and barely none exist that I could use. The ones I did try wouldn't even compile, and most said they were compatible with all versions, but hey, they were not. And some of the code out there is horrible, even as horrible as Objective-C syntax really is. Did these people really get Computer Science degrees in a Cracker Jack box? I know, I know, I'm old, I'm typed, I'm structured, I use vi (not vim, vi).
So, it's time to put away the girlfriend's MacBox in preparation for her return. It hasn't seen that kind of use and probably hasn't rocked the fans that much since it came from the factory, all those many *months* ago. It's time to get back into and enjoy real life, and get ready for this drive across the nation in which I may talk to some people about Busme! and the kayak trip. But first today. A BBQ.