Re: The D Programming Language
David Abrahams wrote:
"Andrei Alexandrescu (See Website For Email)"
<SeeWebsiteForEmail@erdani.org> writes:
There might be a terminology confusion here, which I'd like to clear
from the beginning:
1. A program "has undefined behavior" = effectively anything could
happen as the result of executing that program. The metaphor with the
demons flying out of one's nose comes to mind. Anything.
2. A program "produces an undefined value" = the program could produce
an unexpected value, while all other values, and that program's
integrity, are not violated.
The two are fundamentally different because in the second case you can
still count on objects being objects etc.; the memory safety of the
program has not been violated. Therefore the program is much easier to
debug.
Seriously?
IME you're at least likely to crash noisily close to the undefined
behavior. If you make everything defined the program necessarily
soldiers on until one of your own internal checks is able to notice
that something went wrong. Or am I missing something?
I think it's one thing to have a wrong numeric value and one very
different thing to have a program in which all hell breaks looks due to
random overwriting of memory.
I don't have any real experience with Java, but Python generally
exhibits Java-like behavior, and I don't find it easier to debug than
C++.
Well the only thing I can add is that in my limited experience,
debugging Java programs is much easier because there's never the case
that a dangling pointer misteriously overwrites some object it wasn't
supposed to. I remember __to this day__ a night in 1998 when a colleague
and myself spent one night figuring out a completely weird exception
being thrown (in a C++ program) under very complex circumstances - just
because of a misfit memcpy() in a completely different and unrelated
part of the program. Now that I think of that, I remember a few others.
Probably I'd remember even more under hypnosis :o). To tell the truth, I
also remember of a JVM bug causing me a few gray hairs... :o)
Andrei
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]