ANSWERS: 1
  • Objective-C is a very pragmatic language. Objective-C implementations use a thin runtime written in C that adds little to the size of the application. In contrast, most OO systems at the time that it was created used large VM runtimes that took over the entire system. Programs written in Objective-C tend to be not much larger than the size of their code and that of the libraries (which generally don't need to be included in the software distribution), in contrast to Smalltalk systems where a large amount of memory was used just to open a window. Likewise, the language can be implemented on top of existing C compilers (in GCC, first as a preprocessor, then as a module) rather than as a new compiler. This allows Objective-C to leverage the huge existing collection of C code, libraries, tools, and mindshare. Existing C libraries — even in object code libraries — can be wrapped in Objective-C wrappers to provide an OO-style interface. All of these practical changes lowered the barrier to entry, likely the biggest problem for the widespread acceptance of Smalltalk in the 1980s. Objective-C can thus be described as offering much of the flexibility of the later Smalltalk systems in a language that is deployed as easily as C. The first versions of Objective-C did not support garbage collection. At the time this decision was a matter of some debate, and many people considered long "dead times" (when Smalltalk did collection) to render the entire system unusable. Although some 3rd party implementations have added this feature (most notably GNUstep), Apple has not implemented it as of Mac OS X v10.4, but has confirmed that it will be included in Mac OS X v10.5. Another common criticism is that Objective-C does not have language support for namespaces. Instead programmers are forced to add prefixes to their class names, which can cause collisions. As of 2007, all Mac OS X classes and functions in the Cocoa programming environment are prefixed with "NS" (as in NSObject or NSButton) to clearly identify them as belonging to the Mac OS X core; the "NS" derives from the names of the classes as defined during the development of NeXTSTEP. Since Objective-C is a strict superset of C, it does not treat C primitive types as first-class objects either. Unlike C++, Objective-C does not support operator overloading. Also unlike C++, Objective-C allows an object only to directly inherit from one class (forbidding multiple inheritance). As Java was influenced by the design of Objective-C, the decision to use single inheritance was carried into Java. Categories and protocols may be used as alternative functionality to multiple inheritance; Java however lacks categories. The design and implementation of C++ and Objective-C represent different approaches to extending C. In addition to C's style of procedural programming, C++ directly supports object-oriented programming, generic programming, and metaprogramming. C++ also comes with a large standard library which includes several container classes. Objective-C, on the other hand, adds only object-oriented features to C. Objective-C in its purest fashion does not contain the same number of standard library features, but in most places where Objective-C is used, it is used with an OpenStep-like library such as OPENSTEP, Cocoa, or GNUstep which provide similar functionality to some of C++'s standard library. One notable difference is that Objective-C provides runtime support for some reflective features, whereas C++ adds only a small amount of runtime support to C. In Objective-C, an object can be queried about its own properties, for example whether it will respond to a certain message. In C++ this is not possible without the use of external libraries; however, it is possible to query whether two objects are of the same type (including built-in types) and whether an object is an instance of a given class (or superclass). The use of reflection is part of the wider distinction between dynamic (run-time) features versus static (compile-time) features of a language. Although Objective-C and C++ each employ a mix of both features, Objective-C is decidedly geared toward run-time decisions while C++ is geared toward compile-time decisions. The tension between dynamic and static programming involves many of the classic tradeoffs in computer science. Edit: Objective-C++ is a front-end to the GNU Compiler Collection that can compile source files that use a combination of C++ and Objective-C syntax. Objective-C++ adds to C++ the extensions Objective-C adds to C. As nothing is done to unify the semantics behind the various language features, certain restrictions apply: * A C++ class cannot derive from an Objective-C class and vice versa. * C++ namespaces cannot be declared inside an Objective-C declaration. * Objective-C classes cannot have instance variables of C++ classes that do not have a default constructor, or that have one or more virtual methods, but pointers to C++ objects can be used as instance variables without restriction (allocate them with new in the -init method). * C++ "by value" semantics cannot be applied to Objective-C objects, which are only accessible through pointers. * An Objective-C declaration cannot be within a C++ template declaration and vice versa. Objective-C types, (e.g., Classname *) can be used as C++ template parameters, however. * Objective-C and C++ exception handling is distinct; the handlers of each cannot handle exceptions of the other type. * Care must be taken since the destructor calling conventions of Objective-C and C++'s exception run-time models do not match (i.e., a C++ destructor will not be called when an Objective-C exception exits the C++ object's scope). Source: http://en.wikipedia.org/wiki/Objective_c

Copyright 2023, Wired Ivy, LLC

Answerbag | Terms of Service | Privacy Policy