05.01.2013 Views

Mac OS X Leopard - ARCAism

Mac OS X Leopard - ARCAism

Mac OS X Leopard - ARCAism

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

478<br />

CHAPTER 25 MAC <strong>OS</strong> X DEVELOPMENT: THE TOOLS<br />

Property List Editor<br />

Property lists, known colloquially as plists, are files originally designed for storing properties,<br />

which is to say, preferences. When you set the preferences of a program in its preference panel,<br />

or via the command line’s defaults command, you’re editing that application’s property list.<br />

However, with the introduction of the XML plist format, these have become a handy way to<br />

store standard data structures, such as arrays and dictionaries, in an external, human-readable<br />

format. The Property List Editor is a convenient, schema-aware way to create and edit plists. It’s<br />

also the only way to make heads or tails out of the older, but still useful, binary plist format.<br />

Shark<br />

Every developer wants their application to be fast, but the biggest mistake a programmer can<br />

make is writing their code for speed. Fast code is optimized code, and the lower a language is, the<br />

more opportunity for optimization there will be. Java offers few chances for optimization compared<br />

to C, and C is a snail compared to assembly language.<br />

As fast as they might be, low-level languages are harder to read and take much longer to<br />

write. Even if you don’t change languages, it’s a shame to pick a library or function based on it<br />

being faster instead of it being easier. Worse than all of that, all those optimizations that took<br />

forever to do will probably end up making the program slower.<br />

Why? Because humans are surprisingly bad at guessing where performance bottlenecks are.<br />

The only way to know for sure is by using a specialized sampling tool. This tool will watch the<br />

application and figure out what it’s doing and for how long. Shark (shown in Figure 25-28),<br />

which comes with the free developer tools, is one of the best optimization programs available.<br />

Figure 25-28. Bare Bones’s blazing fast BBEdit profiled by Shark<br />

Avoiding blind optimizations makes the development cycle faster, because it lets programmers<br />

choose code based on ease of writing and readability. That leaves plenty of time for<br />

profiling with Shark, and then pinpointing bottlenecks and performing optimizations only where<br />

they will make the biggest difference.<br />

Hard rules are anathema to programmers, but here’s one even the most stubborn of hackers<br />

should follow: never, ever do something “because it’s faster,” until you run Shark.

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

Saved successfully!

Ooh no, something went wrong!