Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!pasteur!ames!lll-winken!uunet!mcvax!unido!laura!exunido!bause From: bause@exunido.uucp (Falko Bause) Newsgroups: comp.lang.c++ Subject: C++ - ADVANTAGES/DISADVANTAGES, FIELDS OF APPLICATION (Summary) Message-ID: <1216@laura.UUCP> Date: 21 Mar 89 08:15:24 GMT Sender: root@laura.UUCP Reply-To: bause@exunido.UUCP (Falko Bause) Organization: University of Dortmund, W-Germany Lines: 169 Here is the summary of advantages/disadvantages and main fields of application of the C++-language. Because there were only a few responses, i list excerpts of the original answers. If you have questions please contact the given address. - Falko - From Doug Schmidt : ========================================================================== 1. Main DISadvantages: a. NO STANDARD REFERENCE MANUAL!!!!!! b. No support for exception handling, parameterized types or tasking (this is a result from the AT&T's attempt to stay close to the C and UNIX heritage). c. Language cannot be described by an LALR(1) grammar (makes it more difficult to write a correct compiler). d. Certain recent features of the language are rather difficult to understand, i.e. pointers to function members, multiple inheritance, etc. 2. Main Advantages a. Combines the flexibility of assemble language with the power and abstraction of higher level languages. b. Easy to learn if you know C. c. Very nice support for abstract data types (IMHO better than Ada and Modula 2. d. Supports inheritance and object oriented features not found in most other procedural languages. e. Reasonably good compiler available for free (GNU g++). f. Language is growing and evolving, so that missing features today may be found in future releases. g. Much better type checking than C. From Michael Tiemann : ============================================================= Disadvantages: No concept of modules. For truly large programs, it is impossible for one programmer to hide his private names (such as class names) from another programmer. This causes name conflicts, which the compiler may or may not detect until a system is installed. Ambiguous syntax. The grammar of C++ is inherently ambiguous. As a result, parsing C++ is essentially impossible, though one can write parsers which closely approximate what Bjarne had in mind when he created the language. For example, the following C declaration: TYPE (*EXPR)(); could be interpreted as either, declaring EXPR to be a pointer to function returning type TYPE, or it could be to take EXPR, dereference it (or apply operator *), cast the resulting expression to type TYPE, then use the result as a function to call (or to apply operator ()()). As you can see, there are two perfectly valid interpretations of the same syntactic form. The reason for declaring variables in programming languages was to avoid the problems that could crop up in languages like fortran: C initialize i ii = 0 C use i f (i) as you can see, there is a typo (ii instead of i), but since ii is implicitly declared, no error message is generated. How can a C++ compiler know whether it should be declaring a new variable, or using an old one in the case above? C++ uses a references, which are not very complicated to understand, but they are not taught in standard programming courses. As a result, as you can see, there is a typo (ii instead of i), but since ii is implicitly declared, no error message is generated. How can a C++ compiler know whether it should be declaring a new variable, or using an old one in the case above? C++ uses a references, which are not very complicated to understand, but they are not taught in standard programming courses. As a result, it usually takes the average programmer about 6 months to figure out on their own when and how to use references. C++ provides a rich variety of features, but syntactic limitations keep these features from being usable in a lot of contexts. As a result, C++ features are more ad hoc than orthogonal. For example, it is possible to have an object, and object which needs a constructor (for initialization), and an object which needs a constructor which takes arguments. It is also possible to declare an array of objects, an array of objects which take constructors, but not an array of objects which need constructors that take arguments. The method for initializing static class members, and the whole issue of initialization of file-level objects exposes just how weak the unix compilation environment (using ld) actually is. This is not a fault of C++ per se, but C++ really stretches its environment at its weakest points. Objects are not objects. This means that the language offers no special support to those who wish to write their own object oriented environments. See Keith Gorlen's OOPS package to see how complex such a task is without any help from the language. Stroustrup added features to C++ to make it possible to write code without using as many macros. However, some of these features (such as the notion of a class) came without additional support (like the way to get a class's name as a string), so more uses of macros were needed. Again, Gorlen's OOPS package makes extensive use of macros. The best example of this is that C++ does not provide a `super' method (which would return a classes base type), so the very declarations of classes in OOPS must be done with macros. From Ben Verwer : ========================================= For one person, a few thousand lines of code, C++ has as advantages: it is easier to read, better to comprehend, though you in the beginning quite often overlook a remark in Stroustrup's book. It's main disadvantage is that it is much slower, since you know more than the compiler. E.g. each object is referenced by a pointer. For small objects, used in small loops, it is a few factors slower to reference the objects' data via the pointer, rather than putting the data in a register. E.g. list_iterators, queues. Once my code works, I often translate my C++-code piecewise back to regular C. It makes the difference between a smashing performance or one during which you start to think about the coming coffee-break. (I am working on a thesis on robot path finding). From Dr. James Coggins : ========================================================= Application: research in computer vision/computer graphics Advantages: I work with a large library of procedures. C++ provides structure to the name space of those procedures, making management and use of the library easier. C++ helps to isolate architecture from implementation - a desirable differentiation. Disadvantages: There is a cost in the complexity of the preparations required to make a C++ library operate properly. C++ appears much more complex if you do not fully adopt O-O design. if you do, many of the features fall into place and make sense. From Rob French : ================================================================================= I've been using C++ for some time now. My primary applications have used the InterViews toolkit as a very easy to use alternative to the X toolkit. I'm in the process of doing my bachelor's thesis on heuristic optimization techniques for silicon compilers. I'm using C++ to write my compiler since it can easily handle dynamic objects, and my project is more orientation toward an object-oriented programming approach.