Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!unmvax!pprg.unm.edu!hc!lll-winken!uunet!mcvax!kth!sunic!dkuug!iesd!fischer From: fischer@iesd.dk (Lars P. Fischer) Newsgroups: comp.sys.mac.programmer Subject: Re: LSC++? Message-ID: <1701@iesd.dk> Date: 11 Apr 89 01:52:49 GMT References: <11822@ut-emx.UUCP> <9707@claris.com> Sender: fischer@iesd.dk Organization: Dept. of Computer Science, University of Aalborg Lines: 45 In-reply-to: hearn@claris.com's message of 10 Apr 89 01:24:02 GMT From article <11822@ut-emx.UUCP>, by padraig@ut-emx.UUCP (Padraig Houlahan): > My initial impressions after playing around with C++ is that apart from > a few extra features, there is very little to be gained in using it > instead of C. By this I mean a good top down structure (to me at least) > would appear to have 90% of the benefits that an object oriented approach > claims. > > Am I missing something obvious? One of the benefits of OO is the ease of adding functionality to a program step by step. Additions are much easier to add once you have the basic class hierarchy in place. Also, OO makes it *much* easier to re-use code, and to provide good libraries. Take a look a GNU libG++. It has a String type that handles memory allocation, index checking, regex's, etc, etc. Building this with ordinary C would be *possible*, but it would be difficult, and it would be difficult to use. With C++ I don't have to worry about using a String in a wrong way. I can't. GNU libG++ also has container classes, etc, etc. Note that, when you use hash tables from the standard Unix library, there is no type checking, and worse, there is no way to have more than one hash table in a program. With GNU libG++ I can have any number of hash tables, with full typecheking. Again, this might be *possible* to do in C, but, for all these years, no one have done it. C++ is all new, and it's been done already. This *could* be a hint.... With OO, it is easy to provide different implementations of something, based on different data structure, but with the same interface. Example: I just made an experiment with an application I'm writing. It uses hash tables, but I wanted to know if AVL trees would be faster. To test that, I had to change *one single declaration* and to generate a new class using a standard utility (one command). That's all. Do that in C! Don't get me wrong. I was a C hacker, and have written a good deal of C code. C is not bad. Still, I would hate to go back. /Lars -- Copyright 1989 Lars Fischer; you can redistribute only if your recipients can. Lars Fischer, fischer@iesd.dk, {...}!mcvax!iesd!fischer Any sufficiently advanced technology is indistinguishable from magic. -- Arthur C. Clarke