International Mac Podcast

Blog RSS Subscribe by email

Keaton On : Learning XCode (rant)

Posted on Tuesday, November 11, 2008 by | 9 comments

I, Keaton Brant, am proud to announce that I have finally finished a project that I have been working on for months. It’s been a tough road, I’ve had to devote many hours a day just to ponder the hugeness of this task, but I have finally done it. Yes, I have done what many have tried and failed to do, I have made a “Hello World” app in Xcode!

The scope of this accomplishment is admittedly tiny, but it seriously did take me months of on and off work to figure enough of Xcode out to start writing basic apps. I’m used to coding in REALbasic, a language where you, very simply, drag objects into a window and then write code that tells them what to do. Now, with Xcode, it’s trying to be more than that. It’s trying to make it so every app you write is skin-able, extensible, scriptable, objective, efficient, low-memory, customizable, integrated, 100% secure, and use as little code as possible. Well, all that sounds great, the downside is, to accomplish that, you have to worry less about what your app actually does, and more about all of those things. What if I want to make some stupid little app that plays fart noises? I don’t need all of that, I don’t want to worry about all of that. Sure, professional developers love that stuff, so good, give them the option of using all of these insane concepts so that the app is all of those things. For me, the guy who writes the silly little fart app, let me write like 2 lines of code, drag a button in, and be done with it.

Let me try to sum up some of the stuff I would have to do to make my silly little fart app (and, since I’m still really baffled, I might get some of this wrong). First, I’d have to create a new project from a list of like a jillion different templates that are totally baffling on their own. Then, assuming I chose the right template, I would have to open up the nib file in a new program, Interface Builder, and drag a button in. Then, back in Xcode, I’d have to create a new view controller class, complete with it’s own header file, which I would have to modify to include all of the details for any global variables, methods, and properties I want my code to have. Then, back in interface builder, I would have to import my new class and link it up to the window. Then, I’d have to link up my button, along with any other user elements, to my class so that my class knows they exist. If I were to add another interface element, I’d have to go back to my code, change the header file, then reload it in interface builder and link it up. If I were to have a text field or table or something, I’d have to define my class as a text field or table delegate, which allows it to include some new methods (which you have to look up in the crazy documentation, which I’ll get to later) that are called by that object once it’s I link its delegate property to my class.

Now I can finally get to coding. I want to make the fart noise loop over and over again. But I’m new at this, let me open up the documentation to see what the proper syntax for ‘for loops’ is. Hmm, I searched for ‘for loops’ and it’s telling me how to use emacs to edit my code, that’s not what I wanted. After searching around through the docs manually, I finally figured out for loops are called enumerations in xcode, but unfortunately, the word enumeration seems to mean like 5 different things, so it takes me another 10 minutes to find an article about the type of enumeration I’m looking for. Unfortunately, the article might as well have been written in iambic pentameter, because half of the words were other concepts and methods I didn’t understand. That’s where my 2 different books and 6 hours of video tutorials come in, I have to manually search the index through all of them, but still no luck. Google isn’t much better. So I am still stuck with only a vague knowledge of how to make basic loops.

Now, let’s assume I managed to get all of that worked out, which I still actually have not. I could go to compile, and find I have errors in my code. No biggie, let’s just see what it says and fix it really quick. Unfortunately, Xcode’s error messages are essentially useless, all you can really gain from them is “There’s something wrong around this area”. Usually ‘undefined function declaration’ or something along those lines does not mean you forgot to declare the function, rather, you forgot a semi-colon (which, as an aside, is completely unnecessary in most cases, the enter key will do fine for me) or a closing brace.

I could also go on and on about the syntax of the code. I still do not understand in what situations you can use dot notation (‘object.method(parameters);’) to call a function and in what situations you need to use square brackets (‘[object method:parameters];’). I don’t know why you have to put an asterisks in front of variable names for some types of variables, but not others. I find the fact that you have to synthesize all of the properties of a class annoying and pointless for most users. I don’t know in what situations you have to use alloc and which you don’t. 

The bottom line is, it’s ridiculously confusing. I think anybody who has written an app in Xcode should be given 100 IQ points. And that’s my rant, I kinda doubt anybody will actually have read this far, so I can say whatever I want… hmm… WATCH IEYE!





9 Responses to “Keaton On : Learning XCode (rant)”

  1. Will says:

    All I have to say is: AppleScript and AppleScript Studio!

  2. Sebastian says:

    Yeah!! I agree with Will. I am an 11 year old and I have a software company called Blue Pyjama (over at http://www.bluepyjama.com). I have an application called PetPhrase that I did with Applescript/Applescript Studio and it took me 30 minutes. There are over 10 different sounds that you can play.

    Sometimes on the Mac you have to take a step back and see if there’s another way to do something.

  3. Jason Martin says:

    I dunno. Applescript is a really easy way to do this stuff, but you don’t get access to some of the things that you do with Cocoa…

  4. AriX says:

    Welcome to real programming. You really can’t compare runtime environments like REALBasic to real applications like ones you can build in Xcode. It’s hard, but it’s powerful. I’m not saying you’re wrong and that Objective-C is a walk in the park, but I don’t think this is something you should rant about.

    As you said, Xcode is designed for creating efficient programs. Cocoa’s features are extremely helpful for those who use them and know how to do so, and once you know how to, it’s quite easy. If you’re writing a fart app, REALBasic might be a better option. When you’re writing large, complex applications, Xcode is the way to go.

    In addition I don’t quite understand the complaint about the fart app at all. It should be QUITE easy to write… Choose the template you’d like (which isn’t hard at all either, and is a completely invalid complaint… “Cocoa Application” is fine for most projects, and it’s first on the list, which should give you a hint…), add ONE LINE to the header file, and drag the items in the right way in IB (I only know how to do this for the iPhone… But I know it’s even simpler on the Mac side of things), and use that object in your code. Apple’s developer documentation from developer.apple.com is fantastic if you’re confused, and there’s a program to use it right inside Xcode.

    As for your syntax questions, the “dot notation” is rarely to never used for functions… It’s only used for getting information about an object. For example, if you want to get the absolute string of an NSURL, you can use nameOfURLObject.absoluteString. This absolute string is synthesized… Just like how you can synthesize a string in your own class, and use self.string to access it. Sometimes square brackets can be used for this too. For example, in the iPhone class UITextField, you can get the text by either [textField text] or textField.text. The square brackets are used for running a method. If you have a method in your code like – (void)eatTooMuchCheese, you can run it with [self eatTooMuchCheese];. Or, if you have an object with a method, for example a UIAlertView, you can show it with [nameOfAlertInstance show];. A little of this may be different because I know Cocoa exclusively for the iPhone, but I’m sure it’s almost the same thing.

    Asterisks represent pointers, which basically means that the object is located in a different part of the memory (which there is more of). Most complicated classes, like NSString and NSURL should be used with pointers… I just guess most of the time, but the convienient thing is that if you declare something without an asterisk and it needs it, the compiler will throw an error (or maybe a warning, I forget)

    Essentially what I’m trying to say is, Xcode is hard, but only because it’s powerful. If you don’t want to put forth enough effort to write great applications, no one is making you, but don’t complain about how hard real programming is… It just is.

  5. Keaton Brant says:

    I know it’s a strange thing to rant about, I think the problem here is that Xcode poses a gigantic barrier to entry for new coders. Think about what would happen if mac development were easy enough for anybody to do it, we’d be getting all sorts of great new ideas and programs. Xcode is very very very very (and so on and so forth) powerful, but as I said, you don’t always need that power, and so being able to just quickly write some code and throw together a UI and not worry about anything else would be great.

    Apples documentation is great once you’ve got the basics down, but from my hours of searching I still can’t find simple explanations of the acceptable syntax for if statements or for loops, for that I need books and online tutorials, most of which aren’t free.

    Also, REALbasic is compiled, not interpreted, just wanted to throw that out there.

  6. AriX says:

    REALbasic is not compiled, it says it’s compiled, but basically it sticks your code on top of an interpreter and you distribute that as a .app or whatever. Also, I don’t understand what you’re talking about with your complaints regarding for loops. C for loops should work as-is in Objective-C…

    • Geoff Perlman says:

      There is NO interpreter in REALbasic nor has their ever been. It has a library that it includes with your app but that's simply providing functionality. Cocoa/Objective-C does the same thing. The only difference is that it is a series of libraries installed in the OS itself.

  7. Keaton Brant says:

    Huh, that explains a lot about REALbasic…

    Also, my problem with loops is that the Apple documentation says very little about them, so you gotta go find other documentation to figure it out.

  8. beeh says:

    That's the way all documentation ( and SW ) is headed these days. Lately, even the microcontroller manufacturers have their documentation split up this way, into "building blocks" or whatever you want to call them. One doc. describes the micro core, there is a doc. for each peripheral ( uart, spi, timers, etc. ), one for the specific micro version ( references certain core, peripheral docs, has register addresses ). Probably 50 or so docs. per micro that all reference each other at some point. For example, to write data out the uart, you have to look at the uart doc, then the specific micro doc ( for the register addresses and global clocks ), then a specific clock peripheral doc. to see which clock is routed to the uart ( for baud rate ). If you want to make your uart code interrupt based, there's another two docs. you have to reference. Sound confusing? Well, it can be confusing and frustrating. What ends up happening is that we create our own documentation as we dig through these documents, so we don't have so many to reference. I loved when everything was in one document, made it very easy. But this building block approach seems to apply to everything now.

    It would be nice if the Apple documentation would at least have all the ObjC documentation references, but you have to look elsewhere for those. They are all available on Apple's website, but it would be nice if some of the more basic stuff was available via Xcode help.

    I think Interface Builder is supposed to help with beginning programmers, but I think it is actually more difficult to use because the programmer still has to connect the GUI objects to the code. I am hoping for something a little more like visual basic in the near future for those beginning programmers that want to create a quick & simple iPhone app. Or the ones that don't care about the inner workings of ObjC and Cocoa, but want to create a small app to get their task done.

    Apple's ultimate goal with the iPhone SDK after all, is for all of us to be creating and selling iPhone Apps.