Objective-C: Tha Apple Supported Programming Language
Creator: mage 19M

Objective-C: Tha Apple Supported Programming Language


If you are searching for an article for Objective-C or if you want to kick-start with Objective-C then you’re in the right place. This article has brief information on Objective-C in a simple language helps to acquire a better knowledge of a programming language.

Objective-C is the primary programming language use when writing software for OS X and iOS. It’s a superset of the C programming language and provides object-oriented capabilities and a dynamic runtime. Objective-C inherits the syntax, primitive types, and flow control statements of C and adds syntax for defining classes and methods. It also adds language-level support for object graph management and objects literals while providing dynamic typing and binding, deferring many responsibilities until runtime.

Objective-C is a general-purpose programming language that adds Smalltalk-style messaging to the C programming language. It was the main programming language supported by Apple for macOS, iOS, and their respective application programming interfaces (APIs), Cocoa and Cocoa Touch, until the introduction of Swift in 2014.


Brief History:-

Objective-C was created primarily by Brad Cox and Tom Love in the early 1980s at their company Productivity Products International.

Leading up to the creation of their company, both had been introduced to Smalltalk while at ITT Corporation’s Programming Technology Center in 1981. The earliest work on Objective-C traces back to around that time. Cox was intrigued by problems of true reusability in software design and programming. He realized that a language like Smalltalk would be invaluable in building development environments for system developers at ITT. However, he and Tom Love also recognized that backward compatibility with C was critically important in ITT’s telecom engineering milieu.

Cox began writing a pre-processor for C to add some of the abilities of Smalltalk. He soon had a working implementation of an object-oriented extension to the C language, which he called “OOPC” for Object-Oriented Pre-Compiler. Love was hired by Schlumberger Research in 1982 and had the opportunity to acquire the first commercial copy of Smalltalk-80, which further influenced the development of their brainchild. In order to demonstrate that real progress could be made, Cox showed that making interchangeable software components really needed only a few practical changes to existing tools. Specifically, they needed to support objects in a flexible manner, come supplied with a usable set of libraries, and allow for the code (and any resources needed by the code) to be bundled into one cross-platform format.


Features Of Objective-C:-

1. Classes are objects

Each class is an instance of a meta-class automatically created and managed by the run-time. We can define class methods, pass classes as arguments, put them in collections and so on. To create an object, we just send a message to the class we want to instantiate. No need to reinvent a “factory” system. No need for a specific constructor mechanism at the language level. This helps to keep the language simple and powerful.

2. Dynamic typing

As in Ruby, Python, Smalltalk, Groovy… Extremely useful because we don’t always know beforehand what our objects are going to be at run-time. Dynamic typing in Objective-C is simple to use. For example, this declares a variable that can hold a reference to an object.

3. Optional static typing

Still, Objective-C also has support for static typing. Best of both worlds. This declares a variable that can hold a reference to an object of the class.

4. Categories

Categories let us define new methods and add them to classes for which we don’t have the source code (such as the standard Cocoa classes provided by Apple). This makes it easy to extend classes without resorting to subclassing. Extremely useful to adapt existing classes to the requirements of frameworks we want to use or create.

5. Message sending

We interact with objects by sending them messages. Often, the receiver of a message will have a method that directly matches the message (i.e. that has the same name, or, in Objective-C terms, the same selector). In this case, the method will be invoked. But this is not the only possible outcome, as an object can choose to handle a message in other ways such as forwarding it to another object, broadcasting it to a number of objects, introspecting it and applying custom logic, etc.

6. Expressive message syntax

Message patterns in Objective-C are like natural language sentences with holes in them (prefixed with colons). When we write code that sends a message to an object, we fill the holes with actual values, creating a meaningful sentence. This way of denoting messages comes from Smalltalk and makes the code very expressive.

7. Introspection

Introspecting objects is easy. For example, we can ask an object for its class like this:

[myObject class]

Determine if an object has a method “foo”:-

[myObject respondsToSelector:@selector(foo)]

Ask an object for the signature of its method “foo”:-

[myObject methodSignatureForSelector:@selector(foo)]

Ask a class whether it is a subclass of another class:-

[class1 isSubclassOfClass:class2]

8. Dynamic run-time

Objective-C has a dynamic run-time. It allows crafting messages at run-time, dynamically creating classes, dynamically adding methods to existing classes, changing method implementations.

9. Automatic garbage collection

The automatic garbage collector runs in its own thread, concurrently with the application code. It uses a generational model to improve its efficiency by targeting priority memory zones that are more likely to be garbage. It works for objects and also for raw C memory blocks allocated with the NSAllocateCollactable() and similar functions. malloc() works, as usual, providing control over memory not managed by the collector.

The garbage collector is an opt-in service, you can choose to not make use of it in your application and instead rely on a reference counting system. This system includes a rather ingenious delayed-release mechanism that goes a long way to reduce the burden of manual reference counting.

10. C inside

Objective-C is primarily an object-oriented extension to the C language and constitutes a superset of C. This means that the raw power of C is available and that C libraries can be accessed directly (as you know, there is quite a number of them available out there). Besides, this creates a symbiotic relationship between the language and the operating system, as Mac OS X, which is a UNIX system, is primarily written in C and, for the upper-level parts, in Objective-C.

11. C++ fluent

Not only is Objective-C a superset of C but it can also understand and call C++ code. Used in this configuration, the language is named Objective-C++ and allows mixing Objective-C and C++ code in the same code statements. It also allows directly using C++ libraries.

12. Simplicity

Objective-C’s Smalltalk-inspired object system is leaning toward simplicity. Many features that tend to render languages complex (templates, overloading, multiple inheritances, etc.) are simply absent from Objective-C, which offer simpler programming models taking advantage of its dynamic nature.

13. Access to Apple technologies

Each new version of Mac OS X, and now, of the iPhone OS, is full of interesting new technologies which are directly available from Objective-C to play with. This contributes significantly to make Objective-C fun to use.


Applications:-

Anything you can reasonably think of. It’s a fine language, very productive, and backed (on Mac OS and iOS) by some absolutely amazing frameworks that do everything from implementing a simple array or string to presenting an entirely scalable, interactive, annotatable world map down to street level. Some of the common applications developed in Objective-C are:-

Mac OS applications
iOS applications
GUI apps for Apple platforms
GUI apps on GNUStep
Create bridges between C/C++/Objective-C and Swift
Mac OS and iOS related APIs
Kavish Mathur

Software engineer

4 年

FUTURE TECHNLOGY IN 2020 - FIFTH GENERATION https://dwarpalsikar.blogspot.com/2020/06/5g-technlogy-in-2020.html

回复

要查看或添加评论,请登录

Sunil Sharma的更多文章

社区洞察

其他会员也浏览了