From: titmouse!bshirley (C. William Shirley) Newsgroups: comp.lang.objective-c,news.answers Subject: Objective-C Frequently Asked Questions Summary: Answers to Frequently Asked Questions asked about the Objective-C Keywords: FAQ objective-c programming Message-ID: <1993Mar20.015443.1203@gleap.jpunix.com> Date: Sat, 20 Mar 1993 01:54:43 GMT Sender: bshirley@gleap.jpunix.com Reply-To: BShirley@GLeap.jpunix.com Followup-To: comp.lang.objective-c Organization: The Republic of Texas Approved: news-answers-request@MIT.Edu Lines: 335 Archive-name: Objective-C/faq Last-modified: 1993/02/22 Version: 1.1 Answers to FREQUENTLY ASKED QUESTIONS concerning Objective-C Clarification: I have used the word `ObjC' for `Objective-C', the proper and official name for the language discussed within, throughout this file. Is is simply a time and space saver. Questions & Answers ~~~~~~~~~~~~~~~~~~~ Q1. What is Objective-C? A1. An object oriented (OO) computer language based on the C language and influenced by SmallTalk. It was designed by The Stepstone Corp. (and is a Trademark of Stepstone) and includes many of the OO things that make Smalltalk the "language to learn OOP with", and many of the great things about C that make it highly portable and very optimizable. It is NOT C++. Q2. Who makes an Objective-C compiler, what does it cost, how do I order? A2.1 The Stepstone Corporation (203) 426-1875 - (800) BUY-OBJEct voice / (203) 270-0106 fax 75 Glen Road Sandy Hook, CT 06482 compilers and runtime IBM RISC System/6000 w/ AIX Sun 3, 4, SPARCstations w/ SunOS HP9000/300,400,700,800 w/ HP-UX DEC Stations w/ ULTRIX Data General AViiON w/ DG/UX SCO UNIX SYS V PS/2 w/ AIX or OS/2 PC-AT w/ MS-DOS VAX w/ VMS MIPS NeXT Macs with MPW (Mac Programmers Workshop) class libraries available for a subset of the above A2.2 NeXT, Inc. Comes bundled with the extended OS release. (NeXTSTEP 3.0 - $295 on CD ROM) shipped Sept 92 (NeXTSTEP '486 - $995) intended Q4 92 A2.3 GNU Project Freely available GNU Experimental Tape GCC 2 (the GNU C/C++/ObjC Compiler with many new features - doesn't include runtime - yet) prep.ai.mit.edu (18.71.0.38) pub/gnu/gcc-2.0.tar.Z (See sites at end of file) Q3. Does GNU's gcc `do' Objective-C? A3. Didn't you read the above answer: It does as of release 2.0, but does not initially include the runtime system required to use ObjC. A runtime has been completed and donated to the project. It is currently (Sept 92) undergoing testing and some rewriting. Reports are: On the NeXT, which has a runtime system, programs compiled with gcc 2.0 (as available on the net) run when linked to NeXT's runtime library. A runtime has been completed and donated to the project. It is currently (Sept 92) undergoing testing and some rewriting. A group has formed to help develop a library of Objective-C classes to be distributed freely by the GNU project. Q4. What books concerning Objective-C are available? A4.1 Object Oriented Programming: An Evolutionary Approach Author: Brad J. Cox (, Andrew J. Novobilski second edition) Publisher: Addison-Wesley ISBN#: 0-201-10393-1 August, 1986 ISBN#: 0-201-54834-8 1991 two editions A4.2 Objective-C: Object Oriented Programming Techniques Authors: Lewis J. Pinson, Richard S. Wiener Publisher: Addison-Wesley, 1991 ISBN#: 0-201-50828-1 Abstract: Includes many examples, discusses both Stepstone's and NeXT's versions of Objective-C, and the (minor) differences between the two. A4.3 An Introduction to Object-Oriented Programming Author: Timothy Budd Publisher: Addison-Wesley ISBN#: 0-201-54709-0 Abstract: An intro to the topic of OOP, as well as a comparison of C++, Objective-C, Smalltalk, and Object Pascal A4.4 NeXTSTEP Programming Step 1: Object-oriented applications Authors: Simson L. Garfinkel, Michael K. Mahoney Publisher: Springer-Verlag, 1992 (800)SPR-INGE Abstract: It's updated to discuss NeXTSTEP 3.0 features (Project Builder, new development environment) but doesn't discuss 3DKit or DBKit A4.5 NeXTSTEP Programming Availability: RSN? Author: Alex Nghiem Publisher: Prentice-Hall Info: You can get the Table of Contents at sonata.cc.purdue.edu or cs.orst.edu via anonymous FTP Q5. What is the difference between Objective-C and C? A5. ObjC is a superset of the ANSI C standard. It is an object oriented language that has extensions similar to Smalltalk applied to C. It includes a few more key words and constructs. New Keywords: @interface @implementation @public @selector Constructs: [instance method: param]; <- sending a message to an instance Types: id - basically a generic pointer to an object [****************] Q6. What is the difference between Objective C and C++? A6. C++ has operator overloading, ObjC doesn't. Some consider this to be 'syntactic sugar', and it is, but it can be a quite handy bit of syntactic sugar. C++ has multiple inheritance, ObjC doesn't. There is much debate over the desirability and value of this. There are several ways to 'get around' this in ObjC. The run-time binding mechanism differ quite a bit in their functionality. (Details?? [***]) Q7. What is the difference between NeXT's, Stepstone's and GNU's versions of Objective C? A7. NeXT has defined and distributed its own class libraries, which are very integral to the NeXTstep environment. NeXT also extended Stepstones definition of the language to include new constructs, such as protocols, which are touted to deal with some aspects of multiple inheritance. NeXT's implementation does *not* support static binding, Stepstone's does, and GNU's (does?/doesn't?). Stepstone has a standard set of class libraries that work across all supported machines. GNU gcc (C/C++/ObjC) does not have a runtime system for resolving message passing, or include any classes. (yet) The Object (root) class of NeXT's and Stepstone's are slightly different; there are several Object methods and runtime C functions that are not part of Stepstone's. NeXT (and GNU?) supports Categories, Stepstone doesn't. NeXT has a native language debugger, Stepstone and GNU don't. NeXT (3.0) supports Protocols and forward declarations of classes, Stepstone (does/n't?), GNU (does/n't?). [****************] Q8. What are some of the common problems of the language and how can I work around them? (forward declarations of classes, class variables) A8.1 There is no innate multiple inheritance (of course some see this as a benefit). To get around it you can create a compound class ( a class with instance variables that are /id/s of other objects. They can specifically redirect messages to any combination of the objects they are compounded of. (It isn't *that* much of a hassle and you have direct control over the inheritance logistics) Protocols address this to some extent. [***] [** how does Delegation fit in here? **] A8.2 ObjC has no class variables. You can get around this by defining a static variable in the .m file, and defining access methods for it. This is actually a more desirable way of designing a class hierarchy, because it allows subclasses shouldn't access superclass storage (this would cause the subclass to break if the superclass was reimplemented), and allows the subclass to override the storage (if the classes access all their own variables via methods) A8.3 problem X [****************] Q9. What class libraries are available for Objective C? A9. See the related FAQ file - _Objective C - a matter of Class_ Q10. Are there any FTP sites with Objective C code? Where? A10. Yes. There are NeXT related sites at sonata.cc.purdue.edu cs.orst.edu And non-NeXT related sites at ? Q11. I'm an emacs junkie. Are there any .el files somewhere to support Objective-C? A11. Yes. Try sonata.cc.purdue.edu /pub/next/misc/objc.tar.Z Q12. So show me a program, a simple example. A12. See the companion file "A S[ia]mple Objective-C Program" or get all of the code from music.sie.arizona.edu:pub/ObjC/Sample.tar.Z Q13. What are Protocols? A13. Protocols are an addition to (currently only NeXT's 3.0+ version of) ObjC that allow you to organize related methods into groups that form high-level behaviors. This gives library builders a tool to identify sets of standard protocols, independent of the class hierarchy. Protocols provide language support for the reuse of design, whereas classes support the reuse of code. Well designed protocols can help users of an application framework when learning or designing new classes. Here is a simple protocol definition for archiving objects: @protocol Archiving - read:(NXTypedStream *)stream; - write:(NXTypedStream *)stream; @end Once defined, protocols can be referenced in a class interface as follows: // MyClass inherits from Object and // conforms to the Archiving protocol @interface MyClass : Object @end Unlike copying methods to/from other class interfaces, any incompatible change made to the protocol will immediately be recognized by the compiler (the next time the class is compiled). Protocols also provide better type checking without compromising the flexibility of untyped, dynamically bound objects. MyClass *obj1 = [MyClass new]; // legal, obj2 conforms to the Archiving protocol. id obj2 = obj1; // illegal, obj1 does not conform to the TargetAction // protocol. id obj3 = obj1; Terminology ~~~~~~~~~~~ C: A programming language. FTP: File Transfer Protocol. GNU: A project making freely available software. message: A "call" to an implementation of a method method: An implementation of an ObjC "function" factory method: A method which creates a new instance of a class class method: A method which acts on or with the whole of a class rather than an instance of a class. Often used interchangeably with _factory method_, but there is a subtle difference. instance method:A method witch acts on or with a specific instance of a class. OOP: Object Oriented Programming ObjC: An abbreviation of Objective-C Object: The base {class} of Objective-C. Objective-C: An Object Oriented programming language extended from the C language, and what this whole file is about. It is also a registered trademark of The Stepstone Corporation. --- All [**********] designate incompleteness of the FAQ. If you have any questions, corrections, comment, suggestions pass them along. I can be reached directly at or you can post to the news group (comp.lang.objective-c). Disclaimer: I am not related to any company or group mentioned above. This file was created to provide information to interested people, and not advertizing for anything listed above. gnu ftp site, prep.ai.mit.edu:pub/gnu/etc/DISTRIB (prep UK/Europe mirror) src.doc.ic.ac.uk (???) (prep Netherlands mirror) ftp.win.tue.nl (131.155.70.100) (prep UK mirror) src.doc.ic.ac.uk (146.169.3.7) (prep Japan mirror) utsun.s.u-tokyo.ac.jp (133.11.11.11) (Australian site) archie.au (IP number may change) My list of thanks has gotten a bit long, so instead of leaving anyone out, I'll just say thanks to all who have given feedback. This information is what YOU make it. --- -- Bill Shirley BShirley@GLeap.jpunix.com (home) Houston, Texas BShirley@Logic.WilTel.com (work) ``Your lunch, love it or heave it.'' (NXceptable)