Will My iPhone App Take a Performance Hit If I Use Objective-C for Low Level Code

Will my iPhone app take a performance hit if I use Objective-C for low level code?

Mike Ash has some hard numbers for performance of various Objective-C method calls versus C and C++ in his post "Performance Comparisons of Common Operations". Also, this post
by Savoy Software is an interesting read when it comes to tuning the performance of an iPhone application by using Objective-C++.

I tend to prefer the clean, descriptive syntax of Objective-C over Objective-C++, and have not found the language itself to be the source of my performance bottlenecks. I even tend to do things that I know sacrifice a little bit of performance if they make my code much more maintainable.

Is Objective C fast enough for DSP/audio programming

The problem with Objective-C and functions like DSP is not speed per se but rather the uncertainty of when the inevitable bottlenecks will occur.

All languages have bottlenecks but in static linked languages like C++ you can better predict when and where in the code they will occur. In the case of Objective-C's runtime coupling, the time it takes to find the appropriate object, the time it takes to send a message is not necessary slow but it is variable and unpredictable. Objective-C's flexibility in UI, data management and reuse work against it in the case of tightly timed task.

Most audio processing in the Apple API is done in C or C++ because of the need to nail down the time it takes code to execute. However, its easy to mix Objective-C, C and C++ in the same app. This allows you to pick the best language for the immediate task at hand.

Better performance with libxml2 or NSXMLParser on the iPhone?

I've generally found for larger chunks of data (like the apple example you reference) libxml2 tends to be faster. For smaller chunks of data, the difference is negligible. One advantage i like about NSXMLParser is that it is an Objective-C based implementation of an XML Parser where libxml2 is C based.

Objective-C vs. C speed

Objective-C is slightly slower than straight C function calls because of the lookups involved in its dynamic nature. I'll edit this answer with more detail on how it works later if nobody else adds in the detail.

However, more importantly, you are optimizing prematurely. There's a VERY high chance that the extra overhead of Objective-C will have zero noticeable impact on your application's performance.

Take advantage of Objective-C's strengths to design the best written, most object-oriented application possible. If, and only if, testing shows performance problems, optimize those particular areas of the application.

Storing data for iPhone app

Hey, the best way to store and manage data is Core Data framework, you can read about it in official docs.

Muscial notation on the iPhone. Any suggestions for example code?

Indeed, MusicKit is an audio tool, not a symbolic tool like you need.

I don't know of any open-source Objective-C music notation programs. However, the recently-released Zong! Viewer is an open-source (GPL) Java program. You can't run Java on the iPhone, of course, but it might give you some ideas for structuring your software. MuseScore is an open source music notation editor that might provide more ideas.

So far the only iPhone music notation application I know is pocketscore. It has the great idea of exporting MusicXML files via e-mail so you can work on your music later with a more full-featured program than you can write on an iPhone.

There might be other open source programs you can check out on the MusicXML software list. Good luck!

Writing clean, performant code for the iPhone

For me it really does come down to maintainability. with good quality code you can maintain the system so much easier.

I have developers who work with me and when i suggest they take short cuts to make a system work, they scorn on me and deliver the project late. and it has paid in the long run every time!!!

if it is an intensive app, using opebGL and what not then performance might become an issue. if it's just a simple utility or data app. i would recommend contiuing with the best code practices you know, and then keep learning them as they are invaluable. Most patterns are domain agnostic and beneficial across all fundemental programing languages.

And if you do blow the stack, then re factor some of those methods/classes into single calls (at least you know it might happen and will notice it as soon as it happens) And if it doesnt then you have awesome code to maintain that is easily readable by any half baked code monkey who has to look at it latter.

Languages for iPhone development

You can use Mono (C# and JavaScript) with the Unity 3D game development kit. It uses ahead of time compilation to get around the iPhone's non-support of dynamically generated code.

The iPhone doesn't need to be jail broken but the license isn't free.



Related Topics



Leave a reply



Submit