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

后端 未结 8 1962
生来不讨喜
生来不讨喜 2020-12-04 07:57

When programming a CPU intensive or GPU intensive application on the iPhone or other portable hardware, you have to make wise algorithmic decisions to make your code fast.

相关标签:
8条回答
  • 2020-12-04 08:19

    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.

    0 讨论(0)
  • 2020-12-04 08:24

    It's very hard to collect "hard data" for this that's not misguiding.

    The biggest problem with doing a feature-to-feature comparison like you suggest is that the two languages encourage very different coding styles. Objective-C is a dynamic language with duck typing, where typical C++ usage is static. The same object-oriented architecture problem would likely have very different ideal solutions using C++ or Objective-C.

    My feeling (as I have programmed much in both languages, mostly on huge projects): To maximize Objective-C performance, it has to be written very close to C. Whereas with C++, it's possible to make much more use of the language without any performance penalty compared to C.

    Which one is better? I don't know. For pure performance, C++ will always have the edge. But the OOP style of Objective-C definitely has its merits. I definitely think it is easier to keep a sane architecture with it.

    0 讨论(0)
提交回复
热议问题