Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It's best to think of Obj-C method call syntax as a sentence, written in english, which happens to also be computer code. If you name your methods and variables succinctly and explicitly, the language is extremely readable and documents itself (assuming you know english).

Obj-C was the first language I learned after Python. I remember the 2nd month in, it went from being difficult to read, to extremely easy.

Obj-C code can be written terribly, like this:

    NSString *someString = @"hello what's up?";
    NSMutableString *anotherString = [NSMutableString stringWithString:@"I have more to say, don't I?"];
    NSArray *stringArray = [NSArray arrayWithObjects:someString, anotherString, nil];
    NSUInteger stringArraySize = [stringArray count];
Messy Obj-C code! Human eyes like simplicity, like right angles, and columns. Same code, more readable:

    NSString        *someString     = @"hello what's up?";
    NSMutableString *anotherString  = [NSMutableString stringWithString:@"I have more to say, don't I?"];
    NSArray         *stringArray    = [NSArray arrayWithObjects:someString, anotherString, nil];
    NSUInteger      stringArraySize = [stringArray count];
Takes an extra few seconds of typing, but goes miles.


If you use the new AppCode Obj-C IDE, you can get formatting like the latter for free.


The same is true of most programming languages. Simple things like layout improve readibility, and thus productivity, immeasurably.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: