Objective C vs. C++

keith gorlen keith at cecil.UUCP
Thu Dec 12 03:46:57 AEST 1985


I have looked into both Objective C and C++ extensively.  I have not
actually programmed in Objective C, but I attended one of their seminars
(which I would recommend) and have studied the Objective C reference
manual (dated April, 1985).

Both Objective C and C++ are C preprocessors that add object-oriented
programming features (e.g. encapsulation and inheritance) on top of C.
C++ does a prettier job of this, and also adds features such as improved
type checking, operator and function overloading, free store management,
and inline functions.

A major difference between the two is in the implementation of dynamic
typing.  Objective C uses the Smalltalk terminology of "sending a
message" to a "method", C++ refers to this as "calling a virtual member
function".  Both mechanisms permit the binding between a function call
and the implementation of a function to be determined by the type of an
object at run time.  Objective C implements this binding by searching
tables, caching the search results to improve efficiency.  C++ builds
complete virtual function tables at compile time and just does an
indirect subroutine call, but the tables are comparatively large.  Thus,
C++ trades off space for speed, and also looses a few other capabilities
of minor importance (in my opinion).

This difference, together with inline functions, means that C++ should
be significantly more efficient than Objective C, but I know of no
actual comparison that has been done.

Objective C also comes with a SmallTalk-80 -like class library that
includes collection classes such as Set, Bag, Dictionary,
OrderedCollection, etc. and a filer that can store/read data structures
comprised of objects of these or any user-defined class to/from disk.
C++ does not come with such a class library, but I am implementing one
which I hope to place in the public domain if/when the documentation
gets written.

As of last Summer, Objective C was priced at $5K for binary (cheaper
versions are (will be?) available for the Mac and PC) and I believe
there is also a version for VAX/VMS.  C++ is priced at $2K for a source
license, and runs on a variety of UNIX systems.
-- 
---
	Keith Gorlen
	Computer Systems Laboratory
	Division of Computer Research and Technology
	National Institutes of Health
	Bethesda, MD 20892
	phone:	(301) 496-5363
	uucp:	{decvax!}seismo!elsie!cecil!keith



More information about the Comp.lang.c mailing list