I’ve read that, the objective-c programs need objective-c runtime to run.
AFAIK, both C/C++ programs don’t require any runtime environments to run. as the generated binary code is being executed directly by the underlying OS.
So this means that Objective-c programs require a redundant layer to run, correct? and If so, is this layer seems like Java VM and .net runtime or seems like Qt runtime (in flavor of some additional libraries)?
EDIT:
After some read, I found that, the objc compiler generates some more information in the generated compiled code that is responsible of many things such as method passing (objc_sendMsg(), introspection and others)
Thanks.
The compiled code is native but you need an additional library (the runtime) which does all the object and message handling (lookup, invocation etc.). There is no virtual machine involved. So it is more like QT than Java runtime.
[Update]
Since the C++ message binding behaviour is not obvious to programmers of more dynamic OO languages (e.g.: Objective-C or Smalltalk) – like me – I wrote a small C++ test app which demonstrates the effect of the
virtualkeyword on the choice of the method to call.An Objective-C programmer would expect a output of
since
t12is actually aTest2which was casted toTest1.The actual output is
because C++ (by default, i.e. without
virtual) statically binds the call totest1based on the type it knows at compile time which isTest1(due to the cast).