home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!stanford.edu!leland.Stanford.EDU!leland.Stanford.EDU!kocks
- From: kocks@leland.Stanford.EDU (Peter Kocks)
- Subject: Re: Need help implementic data structures of generic objects
- Message-ID: <1992Dec14.212143.15591@leland.Stanford.EDU>
- Sender: news@leland.Stanford.EDU (Mr News)
- Organization: DSG, Stanford University, CA 94305, USA
- References: <1992Dec8.165230.2587@ucc.su.OZ.AU> <42186@sdcc12.ucsd.edu> <1992Dec11.233253.27540@informix.com> <1992Dec13.141400.5307@mole-end.matawan.nj.us>
- Date: Mon, 14 Dec 92 21:21:43 GMT
- Lines: 57
-
- In article <1992Dec13.141400.5307@mole-end.matawan.nj.us>, mat@mole-end.matawan.nj.us writes:
- |> In article <1992Dec11.233253.27540@informix.com>, cshaver@informix.com (Craig Shaver) writes:
- |>
- |> > YES! Do that elegant Smalltalk thing. Do not listen to C++ hacks and
- |> > bigots. Put a little thought into it and do something (re)useful.
- |>
- |> If you are programming in Smalltalk then by all means use the same
- |> language construct for inheritance as for genericity. But if you
- |> are programming in C++, use the right tool: a template.
- |>
- |>
- |> When in Smalltalk, Talk Small. When in C++, think clearly and write
- |> clearly. True elegance means using a thing well as designed.
- |>
-
- My $0.02. Use Obj-C. I have just spent a fair amount of time comparing strong
- vs weak type casting systems (sometimes called static vs. dynamic binding) and
- have reached the following conclusions. C++ is the optimum strong casting
- language, Smalltalk is the most popular weak casting system. The ADVANTAGE
- of C++ is that it is strong casting (which makes the prevention of bugs
- considerably easier). The ADVANTAGE of Smalltalk is that it is weak casting.
- The disadvantage of C++ is that when you want to do the more complex OOP
- techniques, they often make the most sense in a weak casting language. C++ lets
- you get around the need for weak casting by giving you such things as
- templates. Its not exactly the same, but it should enable you to implement
- your design. It also means that C++ gets much more complex as you increase the
- complexity of your OOP design. The disadvantage of Smalltalk is that it can
- be slow. Weak casting systems require somekind of run-time system and hence
- smalltalk can be slow. There are, however, several Smalltalk implementations
- which allow a lot of the code to be compiled and it really isn't THAT slow.
- The other disadvantage is that smalltalk is not C. So, all those neat
- C tricks you learned are useless.
-
- Weak casting is a nice feature allowing you to send messages to objects without
- knowing how (or if) the message can be implemented by the object. It really
- is great, but it makes for run-time errors which are bad (BUT not THAT bad).
- The solution, if you want a weakcasting system and you don't want to give
- up C, is clearly Obj-C. Obj-C is essentially a mix of smalltalk and C. It
- gives you the advantages of weak casting and C code. While it is not as
- fast as C++, the difference is relatively minimal and it is certainly faster
- than implementing your own weak casting system in C++. Of course, no one
- except NeXT really uses Obj-C and this is the biggest problem -- too bad.
- Obj-C is avaialable on most platforms. Obj-C is not as straight forward
- to learn as C++ (for people who already known C). C++ is much closer
- to C than Smalltalk. Obj-C is much closer to Smalltalk. I think the reason
- C++ became so popular is that it is relatively easy to learn OOP from
- a C background using C++. Unfortunately, we are stuck with C++ so the
- ultimate answer I believe is to forget about doing any kind of weak casting
- design. To do it in C++ is inviting disaster. Smalltalk is not fast
- enough (well maybe it is) and it does not give you C code possiblities. Obj-C
- is the clear answer, but you'll be all alone.
-
- I'm stuck with the same problem and I've decided to curse C++ and just
- get on with using templates etc...
-
- --Peter Kocks
- kocks@cardinal.stanford.edu
-