Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective-C's dynamic advantages in Cocoa development?

So from my understanding (one of) the biggest allures of Obj-C is the dynamic, message-passing runtime.

How's this and other features overall beneficial to Cocoa development? Why was Obj-C used for Cocoa dev and not C++/C?

Basically I'm trying to understand how such language features are actually beneficial in terms of when actually solving a particular problem in terms of OSX or iOS application.

like image 694
James Avatar asked Oct 14 '22 22:10

James


1 Answers

Major pieces of the Cocoa frameworks are difficult (not impossible, of course) in less dynamic languages. Key-value coding (which makes use of dynamic dispatch and runtime class and hierarchy modification) are very hard to do in compile-time bound (method-calling) languages. Core Data's synthesis of attribute getters/setters is a similar example of Objective-C's dynamic messaging (and dynamic runtime) making things much easier.

Objective-C's dynamic messaging was designed specifically to solve the dependency problem in large projects. Whereas a compile-time bound language like C++ requires that dependent modules be recompiled together, Objective-C's runtime-bound messaging means that you don't always have to re-compile everything. At the time of NeXT's decision to use Objective-C over (the, at the time, immature C++), that was a major factor in developer sanity. It still makes large systems easier to manage (though, again, it's certainly not impossible in C++ or Java or ..., just much harder).

like image 130
Barry Wark Avatar answered Oct 18 '22 00:10

Barry Wark