10/29 C++ is so freaking BROKEN. Augh!
\_ Just use C.
\_ Would if I could.
\_ No, you are. C++ works just fine, and far better than C for many
purposes.
\_ C vs. C++. FIGHT!!!
\_ True, it's better than C for many purposes, but at the very
least it has some serious lexing/syntax issues.
\_ Most of the warts stem from backwards compatibility with C
(primarily integer promotion, operator precendence, etc.).
\_ Bull... Shit... Things which are broken in C++:
Confusing Scoping Operators
Confusing auto creation vs. explicit instantiation of objects.
Confusing auto creation vs. explicit instantiation of
objects.
Ability to overload things like new.
Ability to do crappy stuff like delete this.
Multiple Inheritance
Friends (god, wtf was Bjarne thinking?)
Sticking classes in .h files.
Templates (good idea, but crap implementation).
STL was too damn late in coming so nobody uses it.
Language is too frickin' big.
We should've adopted Objective C over C++. C++ is just
a dog of a language. Just take a look at MFC and its mess.
\_ cs61b got you down? I've actually seen alot of the
stuff on your list used in VERY effective ways. Most of
your complaints sound like the things newbies whine
about. Train harder, grasshopper.
\_ A lot of the things you list are not broken. Just
because something is confusing to _you_ does not make
it 'broken.' Just because something is an advanced
feature for which you see no use (overloading new) does
not make it broken. However, I will agree that C++ is
combining too many worlds in a poor and inelegant way.
Still, I have to respect it in that you CAN get work
done in it. -- ilyas
done in it. We would not have been better off with
ObjC over C++, though ObjC is certainly a much
smaller language. One reason is, ObjC uses essentially
the smalltalk object system, which is not suitable for
many systemy kinds of programming. -- ilyas
P.S. My favorite MFC moment is seeing stuff like:
template <class T> class Foo : public T { ... }
\_ This is typically called a shim class. And?
\_ There is no and. I just find the idiom amusing.
\_ You learned Java before C++ right? It's hard to move to
a real language after playing with toys for a while.
I've used all the above features well, and use STL
heavily. (You didn't even mention streams. Amateur.)
\_ Actually, I was thinking more of obvious stuff like
the << and >> template problems, and the fact that
:: is both the namespace separator and the name for
the "global namespace." (Which becomes a problem
when the C++ lexer throws away whitespace...) -op
\_ How is :: the "name" for the global namespace?
If it were, then you'd access globals by ::::foo,
yes? Isn't the "name" for the global namespace
epsilon (nothing)? :: is always a namespace
separator.
\_ Sorry I didn't state it in explicit theory
terms, but it amounts to the same thing. If
you want to specify the global namespace, you
begin the identifier name with ::. ie
::foo:bar. I was just using the same
\_ A single colon is not a namespace
separator. Did you mean ::foo::bar? Are
you sure you're programming in C++?
terminology used in a C++ book I read a
while ago. It maybe have been Bjarne, but I
can't remember exactly.
\_ Errr, read the post above you again. pp is
exactly right. -- ilyas
\_ Errr.. read my post again, I agreed
with him.
\_ Right. This works just like Unix pathnames --
foo/bar is a relative path, and /foo/bar is an
absolute path. What problems does it create?
Yes, >> in templates is stupid.
\_ I just had this experiance, if you have
2 identifiers in a row, ie "id1 id2",
and you try to force the global id2,
C++ throws out the white space, so
instead of having two identifiers, you
get 1 big identifier "id1::id2", which,
of course, it can't find.
\_ That doesn't even make sense. White
space separates tokens. I don't think
you know what you're talking about.
\_ Maybe it's only true in gcc 3.4,
go ahead and try it.
\_ I don't have access to gcc 3.4 (nor
do I want it). That sounds like a
bug in a compiler, not a language
flaw.
\_ It doesn't make sense, and you
haven't provided enough instruction
about how to reproduce it. What
do you mean "have two identifiers"
in a row? When would that be legal
at all? In what context? How
about some real code?
\_ If you like:
#include <iostream>
class B { };
class A {
public:
B foo();
};
B ::A::foo() {
std::cout << "Hello" << std::endl;
return B();
}
int main() {
A a;
a.foo();
return 0;
}
fails with this error:
test.cc:11: error: `class B::A' has not been declared
test.cc:11: error: ISO C++ forbids declaration of `foo' with no type
\_ But you shouldn't need to have (or be expected to
have) the global namespace qualifier in A::foo's
definition anyway. How about an example where it's
actually a problem? The scoping operator (::) does
need to discount whitespace, because otherwise you
wouldn't be able to break apart really::really::
long::lines.
\_ The case where I ran into this as a "real
problem" spanned multiple files and
thousands of lines of code. So I contrived
an example. I'm pretty sure that's a normal
thing to do.
\_ Explain how. C++ doesn't allow nested
functions, so you either define functions
in global scope or within a namespace.
If you're already in global scope, you
don't need the leading ::. If you're not
in global scope, why are you defining a
function in one namespace from within another?
\_ And inablilty to explicitly declare a
function in global scope doesn't
strike you as a little wierd? Even if
it is usually unnecessary? I never
said I couldn't do something else. I
did something else and it worked, that
doesn't mean this isn't bad design.
\_ And it doesn't strike you as weird that
you want to do something like:
class A {
void f();
};
namespace foo {
void ::A::f() { }
}
? I mean, really. Even if you could
do it, you're just making your own
code more unmaintainable by defining
functions where they don't belong.
\_ I think you must be using non-C++
concepts and trying to for them into
C++. By the same token, you can't take
English idioms and translate them word-
for-word into Spanish.
\_ Most of my work is research
outside the concepts of any
language. SO yeah.
\_ No, it doesn't seem weird. Most
lexically-scoped languages allow things
to be declared only in the current
scope.
\_ Maybe so, but in C++ you have to
define methods explicity in a
namespace, but you can't
expicitly declare the namespace.
Perhaps you could argue that
it's just an unfortuate mix of
C++ features, but that's bad
design isn't it?
\_ What do you mean? You don't
have to define methods explicitly
in a namespace (you put them
within a "namespace ns { ... }"
block). And how is that not
explicitly declaring the namespace
itself? And no, it's not a bad
design. Have you not noticed that
you alone seem to be the only
person who has any issues with
this? Sane programs written
properly won't have these issues.
\_ Let's all switch to http://digitalmars.com/d
\_ BCPL is the STANDARD! |