A monster called Mac OS X

Aug

19

2018

In 1999, Mac OS X did not come out. The unforeseen circumstances intervened, in addition, we had to rewrite the graphics engine, and in the industry they were already chuckling at Apple , who took on so many impossible tasks on their shoulders at once.

The unforeseen circumstance began quite innocently, with the discussion of the interaction of applications for Carbon with applications for Cocoa. Actually, this interaction was not that impossible. There were no mysterious barriers between Objective-C and C, which some authors wrote about in those days, never was.

Objective-C worked perfectly even with C ++. More precisely, with C ++ worked its version of Objective-C ++, the details are below.

Barriers were not, but the abstractions of each part of the system were very different: when transferring information from one part to another (and the situation when in one of the parts there is a library that is necessary for the programmer who works in another – the case of ordinary and ordinary) had to spend it is inadmissible for a lot of time to translate, and even to study a “foreign” language.

A clever programmer, put in such conditions not for the first time, would single out especially frequent and cloudy cases of communication, and would write his own library for their simplification and unification. Imagine: instead of increasing the value of the operating system with unique software products, hundreds of programmers will have to either “translate” the transmitted data, or write their own libraries for this …

We decided to write such a library ourselves, in advance. Called her Core Foundation. If you were dealing with programming for Macs and / or iOS, you’ve heard about it, and some of its derivatives (Core Graphics, for example). And, from a certain moment, she began to live her own life, and grew into something much more than a thin boundary layer of objects and code …

This is the fifth part of the series about turning Apple into NeXT Apple. Previous parts:

NeXT Apple .
Apple chooses the path .
Carboniferous period (Carbon) in the history of Apple .
Honeymoon carbonization
Core Foundation
It is given: there are two parts of the same operating system, each of them has, or will eventually, libraries interesting for the opposite part of the system. Each of their parts organizes and presents data according to their own. One of them does this not just in its own way, but also in a multitude of different ways, in different languages ​​(mostly C ++ and C, but not only).

The technical requirements for binder both parts of the libraries were easy to determine.

The language of the implementation of the link libraries was C, which is understandable without translation on both sides of the border. If you correctly consider the features of the implementation of C in C ++, and Apple illiterate engineers if they work, then not engineers (managers?), Everything will work fine.

On the other hand, for a strongly object-oriented part of the operating system, it would be logical to exchange “objects” with the opposite side. C is not considered an object-oriented language, but …

But in fact, all that is necessary to implement object-oriented behavior on it, there is. It’s just that no normal person who decides an applied task will ever think of spending a lot of time on such non-trivial exercises.

Sometimes (when I lived in a clean C) I really wanted to find something … But alas.

On Apple, a pseudo-object-oriented system was designed in which structures with hidden content performed objects, each with its own set of functions and procedures. If you do not understand what you are talking about, do not worry.

I’ll try not to get too deep into this mechanics. Sorry, colleagues – if one of you accidentally wander into this text.

To reduce the number of uncertainties, the set and principles of data structures in Core Foundation have been copied (pretty close to the text) in Cocoa. Added to their libraries something that Cocoa never had (CFTree, for example).

Stuck was very comfortable. From a variety of uncombeded data, with some effort (but within the bounds of the acceptable), the programmer in Carbon could now collect the data in one of the structures (for example, an array whose elements can be either strings or other arrays of strings) it in response to a request from that, or even from this, side.

On the other side, in Cocoa, the brother-programmer converts this universal object into an object of some class … Boom – again it’s not good. From the side of Cocoa, whose strength is the high speed of programming, working with such objects is too time-consuming …

And then some crazy person came up with the idea of ​​”planting” Cocoa on this very boundary layer, and getting the most used Core Foundation objects to turn from the Cocoa object to the Core Foundation object and back, according to the programmer’s will …

And some other madman decided that this is exactly what is needed – and that it’s not a pity to spend a lot of extra time … This someone was called Evi. Jobs, who all poked his nose, thought about this proposal for several days (the project, which is still almost illegal) was already at work, under the cover of Evi, and … agreed.

He was not a technician, but he had a flair for the beautiful decisions he had.

Objective-C ++

Objective-C ++ is a hybrid language developed (accidentally) by NeXT Software, shortly before Apple’s takeover (or vice versa).

Objective-C ++ no one specifically designed. For forgotten purposes, one of the NeXT engineers required a compiler compiler (such as yacc or bison).

But either for his task in these simple and reliable “kk” something was missing, or he was tormented by curiosity, instead of them he decided to use the compiler compiler “on steroids” (I can not remember what it was called – and I a couple of months tormented him, out of curiosity, about 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 it did its job well, and it was included in the developer toolkit NeXT, which moved to Project Builder Mac OS X.

The result is a language that is indispensable when importing code written in C ++ into Cocoa.

Viewing:-66

In: A Technology & Gadgets Asked By: [20988 Red Star Level]

Answer this Question

You must be Logged In to post an Answer.

Not a member yet? Sign Up Now »