Home > Articles > Operating Systems, Server

  • Print
  • + Share This


GNUstep is not written in C. The language used is Objective-C, which, unlike C++, is a pure superset of C. This means that any valid C program is also a valid Objective-C program. In addition to its C inheritance, Objective-C adds Smalltalk-like object-oriented syntax and semantics. The additions made to the C language are very small; a C programmer familiar with the concepts of object orientation can learn Objective-C in about an hour.

The core of the Objective-C additions is the message-passing syntax. Message passing is how objects communicate, and is analogous to method invocation in a language like C++. This syntax is sometimes considered confusing. Every parameter in an Objective-C message is named, so the method call will be followed by a list of name:value pairs. This approach makes the code very readable, since you never forget the order of the parameters, and each is explained. But developers with no Smalltalk experience are likely to find it unfamiliar.

Objective-C has a few features not found in more common languages. One of the most useful is categories. An Objective-C category is a set of methods that are added to an object at runtime. These methods are then available to any instance of the object.

Unlike C++, Objective-C is a late-bound, dynamic language. Methods are looked up at runtime. If a method isn’t found, a default method is called. This setup can be overridden to provide support for delegates, for example. It’s also possible to query objects to see whether they support a particular method. This strategy is used by GNUstep and Cocoa for things like key-value coding (KVC), which allows instance variables to be set directly or via get/set methods (if they’re implemented), through a well-defined mechanism.

  • + Share This
  • 🔖 Save To Your Account

Related Resources

There are currently no related titles. Please check back later.