“The less code the programmer writes, the fewer bugs in your code” – said the adviser of the head of Apple Steve jobs at the January MacWorld Expo 1997. In the second half of the zero it became clear that this rule works not always… In 2006, Chris Lattner, one of the leaders and key developers of LLVM have thought of correcting deficiencies Objective-C. at First it was something of a hobby. Chris asked the participants several specialized “postal” forums with the question “What would you improve in Objective-C?”. Your humble servant has also contributed.
In that year, Chris became the head of one of the groups in the Department of development tools Apple.
The discussion, at times turning into a fierce counter-fighting continued after the release of Objective-C 2.0, but this excursion into the history of Objective-C interrupt. About this language, and about “Objective-C 3.0”, which is no “C” and called differently, talk in a separate series.
Will report only one little-known fact: it was not the first Objective-C 2.0 in history, in the early 90’s, when NeXT acquired the rights to the trademark and the language that experts are seriously engaged in the revision and improvement of the language. Replaced the “brake” runtime environment on your own (good), planted language in the GCC C (considered the best at the time).
For convenience, releases another innovation meant versions. Not only was 2.0 and even 2.1 – ended it’s not something in Objective-C, 4.1, 5.3. By 1993 or 1994, the rapid development of the language ceased, and he again became “just Objective-C”.
In 2006, it was announced Objective-C 2.0 third Millennium, in 2007, he replaced just Objective-C. iOS’s Future was written mostly in Objective-C 2.0.
In Objective-C 2.0, there was a lot of innovations, but one of them was both good and evil. The memory management system has remained the same as before – but now a decent part of the code tripped up the compiler…
This is a continuation of a series about WWDC 2011, previous parts here:
First part: WWDC 2011: Apple takes to the clouds…;
Second part: WWDC 2011: About the murder;
Third part: iCloud, on the other side of the screen.
Why Objective-C has no garbage collector?
This question occupied to many. To the great mobile revolution 2008 Objective-C was exotic for most of the programming population. Those who still had to meet him (briefly) hated him. The most hated feature of the language was the abundance of brackets. In two weeks you get used to them, it’s not a problem at all – but the hatred will not order.
Second in the scale of hatred was the memory management system. Strictly speaking, it was not part of the language – it was “sin” of object-oriented libraries, and had a lot of advantages, but its development stood a solid stone wall on the way to neophytes. “Why Objective-C has no built-in garbage collector?” they asked, for the thousandth time fighting with unruly and mysterious the retain/release/autorelease – “Because there are dozens of implementations with open source?”
Was. I’ve tried about five, and heard more about the same – to bring any of them to mind would be gone for two or three lives. To accustom himself constantly (in the background) feel the memory management system in the process of writing code was not easy, but much simpler. Driving skill in subcortical took six months.
The memory management system in Objective-C (forget about the library) was the best in the world. Not without flaws, but where they are not? Those were the days.
Because there was no sense of a memory management system and trained she professionals (and others it is better not to undertake the construction of the garbage collector in a strange and incomprehensible language), did not see the need. And the overcoming of the threshold of R/R/A even useful: those who could, increased self-esteem.
But this is my personal opinion.
Crime Objective-C 2.0
The superior Objective-C had a lot of new features, such as initialization of immutable collections literals.
It was another innovation, too, saving your fingers and print keys keyboard – properties. Properties, speaking in Russian. Omitting the details, the dynamic variables, working with whom was required to meticulously comply with the code of memory management to avoid leaks or abnormal termination of the program, now you can declare a property, putting in what way should be controlled by this variable occupies a piece of memory.
The default methods get the value of this variable and assigning a new one (which required the use of a memory management) generated a compiler, and never showed what’s inside.
To the delight neophytes, it worked!!! Any obstacles that must be overcome, was not… it would seem. In fact, the memory management system was the same, and syntactic sugar flew with her, sooner or later – but always. Nobody in his right mind and sober memory will not sit behind the wheel of a supersonic aircraft, relying on the autopilot and not being able to control the aircraft manually.
It was thousands of times worse than managing memory manually. Because the man was sure in a good mastery of the craft, bravely took on the real problem, and suddenly “boom” – totally incomprehensible, unexpected problems, out of the blue.
Without faith in his weapon is impossible to defeat. Forgive for banality.
Had to be tough educational program. How many neophytes (Yes, I avoid the word “newbie”) in the face with it, spit and walked away? In honest times are tough neophytes knew that before them was a dangerous enemy that must be fought, was alert and doing much less stupid.
They say that in primitive times in the wild forest grown man easily cope with numerous flocks of large canids. Modern man – alas.
The garbage collector
In the same year, in Obj-C there was also a garbage collector. Experimental, based on the best collector open source, modified by the Apple engineers and the author himself (not for free, of course) – I was not able to deal with him, in iOS it was not. For obvious reasons.
Then he was again modified, then another, and eventually occurred in 2011.
For some time after the “closing” of the garbage collector, he maintained – and in a year or two completely gone.
It did not happen.
That happened in 2011, read
To discuss the history of Apple you can in our Telegram chat.