From LQWiki
Jump to: navigation, search

Objective-C (sometimes written Obj-C) is a superset of C that has additions to the language to support object-oriented programming. It's fairly simple to learn for those who already know C (and not nearly as complex as C++). Objective-C modeled on Smalltalk and strikes a good contrast with normal C: you will never confuse normal C with Objective-C parts. Unlike C++, Objective-C is single inheritance, and by default late-binding.

Objective-C is tied very closely to the base class that all objects must eventually inherit from. This base class implements all of the languages real features, and is not something anyone can implement easily. The best known (or, arguably, only) Objective-C API is called OpenSTep, based on the NEXTSTEP API (used by NeXT, which was bought by Apple), and used in Mac OSX. This API implements a base object, various helper objects, a GUI system, and pretty much a complete OS API. The features found in the OpenSTep API include: memory management (by use of reference counting), dynamic binding, object posing (to replace a run-time object with your own custom subclass), and lots of objects one would expect in a standard library API. Also, a base class exists that proxies all requests to it, meaning any object that inherits from it will be network transparent without doing much else.

The language features themselves are:

  • Single inheritance
  • Late binding
  • Static binding (via a form a cacheting)
  • Protocols (defining a object API thats then implemented by various objects themselves)
  • Categories (extending a already existing object)

You save your Obj-C source code files with the .m filename extension (header files still use the regular .h), and compile them using the gcc command.

GNUstep is GNU's effort a implementing the OpenStep API on GNU/Linux systems, and common development tools. Its also the only Objective-C framework for non-OSX systems, besides the minimal library that ships with gcc.

External links