E
E
eliah_lakhin2011-07-02 18:12:36
Objective-C
eliah_lakhin, 2011-07-02 18:12:36

Features and benefits of using Objective-C?

Dear friends,
I am practically not familiar with the Objective-C programming language, and I would like to hear your opinion about its capabilities in comparison with other languages ​​that are popular today.
To be more specific, I'm interested in the following points:

  1. Why did Apple choose this particular language as the main one for its platform?
  2. What language design elements reflect the design of the Cocoa platform itself?
  3. What design elements of Objective-C do you personally like, find very useful/indispensable in your work, and that are missing in any other languages ​​that you also work with?

I draw your attention to the fact that I would like to hear the answer in terms of the strengths of Objectove-C. I understand that the language, like any other software system, certainly has its advantages and disadvantages, but I would like to hear about the advantages first of all.
Thanks in advance for your replies.

Answer the question

In order to leave comments, you need to log in

5 answer(s)
V
vlm, 2011-07-06
@vlm

> 1. Why did Apple choose this particular language as the main one for its platform?
Because Jobs came to Apple for the second time from Next, in which the language was the basis of the platform. And there he was the basis of the platform due to the fact that he was better than the rest (in the mid-late eighties). Jobs, who came to Apple, found an unreal mess in the operating system (Mac OS 8, 9), which lagged behind its competitors for years (Windows, Linux), did not have normal multitasking, etc. Therefore, he dragged in half of the software component of the Next company in order to start writing the operating system not from scratch. By the time Jobs came to Apple in 1997, C++ wasn't much better than Objective C (ABI issues, metaprogramming issues, etc.), so even then there was no point in changing things up.
> 2. What language design elements reflect the design of the Cocoa platform itself?
Simplicity (single-inheritance) and documentation.
> 3. What design elements of Objective-C do you personally like, are very useful / indispensable in your work, and which are missing in any other languages ​​​​that you also work with?
Objective C is the best C language for team work. Explicit argument names increase the readability of the code and reduce the urgency and/or freshness of the documentation. Single inheritance, no operator overloading, lack of metaprogramming eliminates the difference in styles between team members (when one does not understand the other). Simplified code review.

T
tonsky, 2011-07-02
@tonsky

About item 1 - as far as I understand, when they chose, there was nothing more sensible - there was no OOP in C and there were problems with modularity, in C ++ at that time a non-standardized hell was still going on, the rest worked much more slowly on hardware at that time time. Objective C was cutting edge back in the day.

A
Ariel Feinerman, 2011-07-02
@arielf

2
Cocoa is an Objective-C framework that uses all the features of the language.
3
dynamic typing, blocks, categories, introspection and the ability to programmatically change objects and their methods at runtime, etc.

W
Weageoo, 2011-07-03
@Weageoo

In terms of capabilities, it is practically not inferior to C #, but the syntax can cause rejection at first.
1. Speed ​​(no intermediate code) - so they have the best graphics. tonsky is also probably right
2 and 3 - answered arielf , I agree with him.

O
OCTAGRAM, 2017-06-09
@OCTAGRAM

1. Generally speaking, this was a tragedy for Apple. I disagree with other commentators about the fact that there was nothing to choose from. It was, and not just was, but Apple sat tightly on SOM technology, which was cooler than Objective-C . So, the non-fragile ABI appeared in Objective-C 15 years later than it was in SOM, and still, in some respects, Objective-C is inferior in fragility. The Apple SOM was an improved fork of the IBM SOM and, for example, introduced a reference count for all objects, which was not the case with the IBM SOM. At the same time, it was not a programming language that was closed in itself, but a model that was potentially accessible from any programming language, and I counted 11 programming languages ​​that were supported in one way or another in SOM. Flagship, it must be understood, was consideredDirectToSOM C++ dialect, which implemented the Metrowerks CodeWarrior translator in MacOS. It's a C++ hybrid, on par with C++/CLI, Objective-C++, and C++/CX, where two hierarchies are rammed into one language. Apple itself was the main engine of OpenDoc, a cross-platform analog of ActiveX, where SOM is used instead of COM. Apple had a CyberDog browser that supported OpenDoc in a similar way to Internet Explorer's ActiveX support. In addition to OpenDoc, Apple also made the Compound Document Framework, which in the future was supposed to be ported to other platforms supported by SOM. That is, SOM in the Apple ecosystem before Jobs occupied not the last place, and many developments were tied to it, and some of them even outstripped IBM, which was responsible for the SOM port for other platforms (Windows, OS / 2, AIX). In addition, Apple has invested in the Dylan programming language, a schema dialect that compiles to machine code, and having a Pascal-like syntax instead of bracket c-expressions (but c-expressions are also allowed). In general, Apple did not suffer from a lack of options. Decisive, in my opinion, was the failure of Mac OS 8 (Copland) and the betrayal of IBM. If SOM was such an important part of the classic Mac OS, then it should have moved to Copland, and indeed, on the images that I was able to find, there is evidence thatSOM migrated there too. If Copland took off, Apple would have a modern OS, 32-bit, preemptive multitasking, and a proven object model. Why Copland did not take off is a separate issue. According to rumors, the authorities broke firewood, the project was redone too often, and when it was necessary to release the next version of the operating system, it was too raw (and Mac OS 8.5 had to be released, continuing the classic line). The second reason is the betrayal of IBM. In 1996-1997, many people were blown away by Java, and so was IBM. They put all the chips in Java, and left SOM with a closed code, and so that the smart people from open source did not rock the boat, as in GNUStep, they crushed SOM's coffin with patents that ended only in the mid-2000s. In such conditions, Jobs comes to Apple and brings Objective-C and OPENSTEP OS in his convoy. There was some sort of widget library, 32-bit kernel with preemptive multitasking. AppleScript and Carbon were dragged from the classic Mac OS, but SOM remained in history.
2. Low level compatibility, especially after the non-fragile ABI Objective-C 2.0, but at the same time translation to machine codes. Thanks to this, applications can simultaneously enjoy the benefits of OOP, and not constantly drag megabytes of libraries, and classes can be extended without breaking compatibility with applications. COM, not supporting inheritance, could not take the same place as Objective-C and SOM. They tried most of all in Mozilla, they also have XPCOM in all fields, but even they got out “non-frozen interfaces” that break compatibility. Because of this, if you install, for example, iTunes and iCloud on Windows, they share libraries, just like on Mac OS X, and Thunderbird and FireFox (as well as XULRunner-based applications) each carry their own megabytes of libraries. This property applies not only to Cocoa, but also to third-party libraries.What Java is praised for here is available in a language that is compiled into machine codes. According to my practice of long number libraries for I2P, machine codes sometimes drive a lot.
3. In addition to 2, I personally like that Apple said "No" to traceable garbage collection and "Yes" to automatic reference counting. Against the backdrop of a crowd of crazy people who strive to ruin everything that their dirty hands can only reach with a tracer garbage collector, and hopelessly ruin new undertakings from the very beginning, Apple, being a corporation, suddenly behaved exceptionally adequately. Say “No!” to traceable garbage collection, and from such a high level! Isn't that a miracle? At the same time, this possibility is most adequately built into the language. ARC was in Delphi through COM interfaces ten years ago, Delphi turned out to be the most convenient language for COM, but this possibility, somehow it happened, remained relegated to the background. In the Ada language, smart pointers could be made, and they did, but this feature never became built into the language, so that directly on access it was possible to hang a pragma or an aspect without wrapping in Controlled. Objective-C became the first, and ARC from it went to Delphi, however, it still cannot reach Delphi for Windows and Mac OS Ten. It can’t, and that’s it, well, what are you going to do. It's so hard to think aboutif you think about it, it's so hard to implement, well, so hard. This is by the way why Apple's ARC was like a bolt from the blue. What the hell, they have brains, and they know how to use them, and they also have hands, and they grow from the right place. While others were paving the road to hell or snapping their beaks, these ones took it upon themselves to do it right.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question