Objective-C

general-purpose, high-level, object-oriented programming language

Objective-C is an object-oriented programming language used to make computer programs for macOS and iOS devices.[3][4][5]

Objective-C
FamilyC
Designed byTom Love and Brad Cox
First appeared1984; 40 years ago (1984)
Stable release2.0[1]
Typing disciplinestatic, dynamic, weak
OSCross-platform
Filename extensions.h, .m, .mm, .M
Websitedeveloper.apple.com
Major implementations
Clang, GCC
Influenced by
C, Smalltalk
Influenced
Groovy, Java, Nu, Objective-J, TOM, Swift[2]

History change

Objective-C was created in the early 1980s by two programmers named Brad Cox and Tom Love. However, it didn't become popular until it was bought by NeXT in 1988 for their NeXTSTEP operating system. After NeXT was bought by Apple in 1996, it became the main programming language for Mac OS X and later the iPhone, iPod Touch and iPad. In recent years, Swift has been more popular than Objective-C.

Basics change

Objective-C is a strict superset of C, meaning that any code that can be written in C can be used in Objective-C programs without changing it. However, it adds some features of its own that can't be used in a traditional C program.

Messages change

In Objective-C, functions are called using messages, a feature inspired by the SmallTalk programming language. Messages look like "blocks" of code similar to the one shown below:

[object messageToObject];

These blocks can be nested inside of each other as well, for example:

[[object messageToSendToObject] messageToSendToResultOfInnerMessage];

Interfaces and Implementations change

Unlike other programming languages such as C and Java, Objective-C classes are divided into two separate parts:

  • Interface, which contains the initial declarations of variables and functions.
  • Implementation, which contains the actual code for functions.

Usually, these are put in two different files, with the interface using the ".h" extension and the implementation using the ".m" extension.

Variations change

Objective-C has variants that add features to the original Objective C programming language.

Objective-C++ change

Objective-C++ allows for C++ code to be used in Objective-C applications.[6]

Objective-C 2.0 change

Objective-C 2.0 is an improved version of Objective-C.[7] It adds many features, such as garbage collection (automatic memory management), fast enumeration and properties (the automatic generation of variable methods).

References change

  1. "Runtime Versions and Platforms". Developer.apple.com. Archived from the original on July 20, 2016. Retrieved December 24, 2017.
  2. Lattner, Chris (June 3, 2014). "Chris Lattner's Homepage". Chris Lattner. Archived from the original on June 4, 2014. Retrieved June 3, 2014. The Swift language is the product of tireless effort from a team of language experts, documentation gurus, compiler optimization ninjas, and an incredibly important internal dogfooding group who provided feedback to help refine and battle-test ideas. Of course, it also greatly benefited from the experiences hard-won by many other languages in the field, drawing ideas from Objective-C, Rust, Haskell, Ruby, Python, C#, CLU, and far too many others to list.
  3. Kochan, S. G. (2013). Programming in objective-C. Pearson Education India.
  4. Bennett, G., Fisher, M., & Lees, B. (2012). Objective-C for Absolute Beginners: iPhone, iPad and Mac Programming Made Easy. Apress.
  5. Zdziarski, J. (2008). iPhone Open Application Development: Write Native Objective-C Applications for the iPhone. " O'Reilly Media, Inc.".
  6. Archived documentation of Objective-C++, by Apple.
  7. Clair, R. (2012). Learning Objective-C 2.0: a hands-on guide to Objective-C for Mac and iOS developers. Addison-Wesley.