Differences between version 12 and revision by previous author of C++.
Other diffs: Previous Major Revision, Previous Revision, or view the Annotated Edit History
Newer page: | version 12 | Last edited on Tuesday, September 16, 2003 5:22:30 am | by AristotlePagaltzis | Revert |
Older page: | version 11 | Last edited on Saturday, September 13, 2003 12:48:47 pm | by GerwinVanDeSteeg | Revert |
@@ -1,26 +1,50 @@
-A ProgrammingLanguage.
+A ProgrammingLanguage developed by BjarneStroustrup as the successor to [C], keeping all of its power and flexibility, adding all new disadvantages
.
-Stroustrop decided that C was a neat idea, but needed more syntatic sugar. C++ has all the power and flexibility of C, with all new disadvantages.
+!!! Advantages
-Some of these disadvantages include:
-
* More type-safe meaning
the compiler picks up more errors.
-* Generic and type-safe
programming via templates
.
-* Object orientation
via 'virtual' functions and (multiple) inheritance.
-* The StandardTemplateLibrary, or
STL.
+* More typesafe so
the compiler picks up more errors.
+* Generic and typesafe
programming via [Template]s
.
+* [NameSpace]s help avoid symbol name collisions between independent pieces of code.
+* ObjectOrientedProgramming
via 'virtual' functions and (multiple) inheritance.
+* [
STL], the Standard Template Library
.
* iostreams as a replacement for printf(3).
-* The string class not being fully compatible with (char *), so they are useless for lots of io. eg istream::getline(char *, size_t) needs a character buffer, and can't take a string. same with read(char*, size_t) and get(char*, size_t); What is the point?!
-* Creating a string with numbers in it from variables is awful - it's easier to revert back to C: char buffer[[16]; snprintf(buffer,15,"output-%n.txt", counter); is more logical than strstream ss; ss << "output-" << counter << ".txt" ; string s; ss >> s;
-No, they're the new syntatic sugar. :) Some of them are very very nice.
+!!! Complaints
-The all new disadvantages include:
-* Your compiler will SegFault regularly instead of giving meaningful error reports when you stuff up a template definition
-* You still have to manage memeory, but now it's harder to figure out who's doing what since it's all hidden behind syntatic sugar
+!! String class
-(Stroustrop thought that
[Simula67 | http://www.cetus-links.org/oo_simula.html] was a neat idea,
but a garbage collector
was "too slow". So
he designed his own perfect object-oriented
language that didn't have one
. I'm not sure what
he was thinking
.) (The we
have to get him to hook us up
with his Supplier
, he
's obviously getting
the Good Stuff
)
+What's the point of a string class if it's not fully compatible __char *__ and is therefor useless for many IO operations? Eg you need a character buffer and can't pass a string object to
+
+* __istream::getline
(char *, size_t)__
+* __read(char*, size_t)__
+* __get(char*, size_t)__
+* ... the list goes on.
+
+!! Variable interpolation
+
+Interpolating variables into strings is absolutely hideous and easier done by reverting back to [C]. Compare:
+
+ // C way
+ char buffer[[16];
+ snprintf(buffer,15,"output-%n.txt", counter);
+
+ // vs
+
+ // C++
+ strstream ss;
+ string s;
+ ss << "output-" << counter << ".txt" ;
+ ss >> s;
+
+!! GarbageCollection (not)
+
+Since BjarneStroustrup liked
[Simula67 | http://www.cetus-links.org/oo_simula.html] but decided GarbageCollection
was "too slow",
he designed his own perfect ObjectOriented
language without it
. Quite a few people will readily assume
he must have been on crack
. Besides having to manage memory yourself, you now
have to cope
with new syntactic sugar that can conceal which part of your code is responsible for what bits on your heap. Great fun - really!
+
+!! [Template]s
+
+Your compiler will segfault regularly instead of producing error reports when you stuff up a [Template] definition. When it does produce an error report
, it looks like the (drastically snipped down) one below (in this case it
's from
the [STL]
).
-As an example of template-based (in this case the STL) error reports in C++:
/usr/include/stlport/stl/_hashtable.h: In method `size_t _STL::hashtable<_STL::pair<const CActionHandler::Keycode,void
__<snip>__
/usr/include/stlport/stl/_hashtable.c:347: instantiated from `_STL::hashtable<_STL::pair<const CActionHandler::Keycode,void
(CActionHandler::*)()>,CActionHandler::Keycode,_STL::hash<CActionHandler::Keycode>,_STL::_Select1st<_STL::pair<const
@@ -34,12 +58,8 @@
/usr/include/stlport/stl/_hash_map.h:188: instantiated from here
/usr/include/stlport/stl/_hashtable.h:557: no match for call to `(const _STL::hash<CActionHandler::Keycode>) (const
CActionHandler::Keycode &)'
-You will notice the above actually has quite a few lines removed for brevities sake.
-
-Perhaps
a good reason to stay away from C++ and program in [INTERCAL] or [PASL] (or
[Java]! - Jared)
.
-
-
Or to program
in something like [Ocaml | http://www.ocaml.org], which has parametized types, classes and modules, which cover
all the possible uses of C++ templates
in a saner manner, AFAICT
. --GlynWebster
+This is perhaps
a good reason to stay away from [
C++]
and program in [INTERCAL] or [PASL]. Or maybe
[Java]. Or in something like [Ocaml | http://www.ocaml.org], which has parametized types, classes,
and modules, covering most if not
all the possible uses of [
C++] [Template]s
in a saner manner.
-----
CategoryProgrammingLanguages