Tell me more ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

There seems to be a lot of discussion of the various speed merits to C or C++ as compared to say Java or Python, but I rarely see Objective-C mentioned. Roughly where does it fall in terms of language performance?

share|improve this question
4  
1986 - Brad Cox and Tom Love create Objective-C, announcing "this language has all the memory safety of C combined with all the blazing speed of Smalltalk." Modern historians suspect the two were dyslexic. (source) – Mason Wheeler Mar 31 '12 at 5:08
2  
It falls into the range where performance doesn't matter much. It's the sole supported language for interfacing to Cocoa, so if you want to do that, nothing else works at all. For anything else, I'd consider it a terrible choice, regardless of performance. – Jerry Coffin Mar 31 '12 at 5:20
"performance" isn't a characteristic of a language, but of a language implementation and, more importantly, of the programs written in that language. You can write very fast programs in Objective-C, or you can write very slow ones. – Caleb Apr 1 '12 at 7:12

2 Answers

up vote 12 down vote accepted

Unlike C++, Objective-C is designed as a clean superset of C. The few Objective-C compiler I've used are better known as C compilers, but also handle Objective-C.

So, it's safe to assume that in the code generation level, C and Objective-C are equivalent.

The first difference appears in the OOP ABI, also called "late method binding". Just like in C++, Objective-C relies in compiler-generated function pointer tables that are traversed at runtime.

Unlike C++, however, the binding method is more 'dynamic', and promotes the use of the id superclass everywhere, making it slightly slower than C++ in theory. In practice, this difference is way below measurable.

Finally, the most important performance issue is the quality of the libraries used. Since Objective-C is only really popular in the Apple systems, it's reasonable to assume you're using it with Cocoa; which is a fine set of high-level libraries. In most cases, you can leave the heavy lifting to them, so your code either don't have to be so fast, or if you do heavy crunching, then it's likely to be a mostly-static code base, roughly similar to plain C.

TL;DR: it's right there with C and C++ languages where it matters most. If you're not getting good performance, check your algorithms; just as in any serious language.

share|improve this answer

Short answer: It's compiled into a similar format as C/C++/D. It doesn't use a virtual environment like Java/.Net. And it isn't interpreted like Python/Ruby/Lua. So it is on the faster end of the spectrum.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.