05.01.2013 Views

Mac OS X Leopard - ARCAism

Mac OS X Leopard - ARCAism

Mac OS X Leopard - ARCAism

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Mac</strong> developers have a secret weapon that you’re not going to find in the developer<br />

tools folder. It’s what allows you to do so much with so little, freeing you to think<br />

of all the little things that make <strong>Mac</strong> applications better for your users. It’s what makes the <strong>Mac</strong><br />

the easiest, and yet the most powerful, development platform in the world. It’s our language,<br />

Objective-C, and it has several advantages:<br />

• An innovative syntax makes it far more readable than any other C-like language.<br />

• It is object-oriented, so projects are organized and understandable.<br />

• It is natively compiled, outperforming any interpreted language.<br />

• It has a dynamic runtime, making it is as flexible as a scripting language.<br />

• It augments, rather than replaces, C, letting programmers get close to the machine if<br />

they must.<br />

• It is designed for ease of use, especially Objective-C 2.0.<br />

Objective-C Syntax<br />

Above all else, code must be readable. Elegance, performance, and productivity will follow. The<br />

less time you spend figuring out what you wrote yesterday, the more time you’ll have to work on<br />

it today. The better you can understand what a piece of code is doing, the faster you can add<br />

features and fix bugs. If other programmers can understand your code, they can give you constructive<br />

criticism, making you and your program better.<br />

The first thing people notice about Objective-C is its syntax. Although standard C syntax<br />

remains valid, Objective-C adds new syntax, derived from Smalltalk, the first object-oriented<br />

programming language. Many people are at first wary of this alien syntax, but once they get used<br />

to it, they can’t imagine using anything else. That’s because Objective-C is extremely readable.<br />

Consider this function call in C syntax:<br />

setColor(myObject, 0.4, 0.3, 0.0, 1.0);<br />

CHAPTER<br />

<strong>Mac</strong> <strong>OS</strong> X Development:<br />

Objective-C<br />

26<br />

You can guess it sets a color, but what do those numbers mean? Are those red, green, blue,<br />

and alpha? Or alpha, red, green, and blue? Or cyan, yellow, magenta, and black? Or luminosity,<br />

481

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!