In 1999, Mac OS X did not. Unforeseen circumstances intervened, in addition, had to rewrite the graphics engine, and in industry have laughed at Apple to take on its shoulders so many impossible tasks at once.
Started contingency innocently enough, with a discussion of application interaction for Carbon apps to Cocoa. In fact, this interaction was not that impossible. No mystical barrier between Objective-C and C, which in those days wrote some authors, has never been.
Objective-C worked fine even with C++. More precisely, C++ worked version of Objective-C++, details below.
Barriers no, but the abstraction of each of the parts of the system were very different: the transmission of information from one part to another (a situation where in one part there is a library needed by the programmer who works in the other case ordinary and everyday) I had to spend too many time on translation, and even learning “inostrannogo” language.
A clever programmer put in such conditions not for the first time, I would especially frequent and murky cases of communication, and would write their own library for their simplification and harmonization. Imagine: instead of increasing the value of operating system, unique software products, hundreds of programmers will either have to “translate” data in motion, or to write your own library for this…
I decided to write such a library yourself, in advance. Called its Core Foundation. If you have dealt with programming for Macs and/or iOS, you’ve heard of it, and some of its derivatives (Core Graphics, for example). And, at some point, she has healed his own life, and grew into much more than a thin boundary layer of objects and code…
This is the fifth part of a series about the transformation of Apple in the NeXT Apple. Previous parts:
- NeXT Apple.
- Apple chooses the path.
- The Carboniferous period (Carboniferous) in the history of Apple.
- Honeymoon carbonation
Given: there are two parts of the same operating system, each of them is, or will be, libraries interesting to the opposite side of the system. Each piece organizes and presents information on your. One of them does it just for her, but also in many different ways, in different languages (mostly C++ and C, but not only).
Technical requirements for binding both parts of the libraries were determined easily.
As the language of implementation binding of libraries was chosen, which is understandable without translation on both sides of the border. If you correctly take into account features of the implementation in C C++ and Apple illiterate engineers if work is not engineers (managers?), everything will work fine.
On the other hand, for highly object-oriented part of the operating system, it would be logical to share with the opposite side of “objects”. C is not considered an object-oriented language, but…
But really, all that is needed to implement it object-oriented behavior, it is. Just any normal person, to solve an applied problem, do not come to mind to spend a lot of time on such a non-trivial exercise.
I sometimes (when I lived in pure C) I really wanted to uchudit something… But alas.
Apple has designed a pseudo-object-oriented system in which the objects performed a structure with hidden contents, with each of which was linked to its own set of functions and procedures. If you do not understand about what speech, do not worry.
I’ll try not to get into all the mechanics too deeply. Sorry, colleagues – if any of you happen to wander in this text.
To reduce the number of uncertainties, recruitment and the principles of data structures in Core Foundation copied (pretty close to the text) to Cocoa. Added to your library what Cocoa has never been (CFTree, for example).
Thing was very convenient. From a variety of raw data, with some effort (but within limits), programmer at Carbon now can collect data in any of structures (for example, is an array, elements of which can be either strings, or other arrays of strings), and issue it in response to a request from the or even from this side.
On the other side, in Cocoa, brother-programmer will convert this generic object into an object of some class… Boom sick again. From Cocoa, the strength of which is high speed programming, the work with such objects is too time-consuming…
And then some lunatic came up with “to put” Cocoa on the border layer, and make the most used objects Core Foundation to develop, at the behest of the programmer, object in Cocoa Core Foundation object and back…
And some other lunatic decided that this is exactly what we need – and that is not a pity to spend a lot of time to waste… This someone’s name was Evie. Jobs who all have stuck your nose in thought over this offer for a few days (draft, yet almost illegal) was already in operation, under the cover of Evie and… agreed.
He was not a techie, but a flair for the elegant solution he had.
Objective-C++ is a hybrid language that was designed (by accident) on NeXT Software, shortly before the absorption of her Apple (or Vice versa).
Objective-C++ wasn’t specifically designed. For purposes of the forgotten already, one of the engineers NeXT needed a compiler compilers (such as yacc or bison).
But for the tasks within these simple and reliable “KK” something was missing, or he was tormented by curiosity, instead he decided to use a compiler of compilers “on steroids” (I can’t remember what it was called – but I have a couple of months of his torment, out of curiosity, 20 years ago).
And, as an exercise, he wrote a language compiler that combines C++ and Objective-C. And C.
The compiler was incredibly slow, but gets the job done well, and it was included in the developer tools NeXT, which moved into the Project Builder Mac OS X.
It turned out the language, is indispensable for the import to Cocoa code written in C++.
To be continued