Re: #define and (brackets)
- From: "Alan Carre" <alan@xxxxxxxxxxxxxxxxx>
- Date: Sat, 29 Nov 2008 19:36:23 +0700
"Igor Tandetnik" <itandetnik@xxxxxxxx> wrote in message
news:e61AHZZUJHA.4372@xxxxxxxxxxxxxxxxxxxxxxx
"Alan Carre" <alan@xxxxxxxxxxxxxxxxx> wrote in message
news:e$8mm$XUJHA.4168@xxxxxxxxxxxxxxxxxxxx
"Igor Tandetnik" <itandetnik@xxxxxxxx> wrote in message
news:OsZwtwXUJHA.4168@xxxxxxxxxxxxxxxxxxxxxxx
If I make a mistake, I want an error to
come out.
I'd love to live in such a world, too. Just to think, I'd never have to
touch a debugger again! Heck, if the compiler knows enough to tell me
whenever I make a mistake, why can't it just write the damn program for
me?
Then you'd find yourself happy on planet earth and in a real-life, highly
sophisticated software development environment.
You know I have a friend who works for a very respectable (and very
successful) investement firm [name omitted] writing software (in C++ using
VC2005) that, not surprisingly, computes the various dollar-values of
different forms of risk in real-time. This software is highly optimized, and
highly complex and also (obviously) needs to be *highly reliable* as the
firm's future depends *entirely* on that one crucial element (risk
analysis).
Well I can share with you something thing about working in "the real world";
a world where even the slightest errors have "real outcomes", such as the
total wreakage of the institution you're working for:
The average time between "RUNS" of their software is between 6 to 8 MONTHS.
That means that the only help you have in detecting bugs is, in fact, the
compiler. I mean, you can't just "run the program" and test that it works
because it requires the whole world's financial system essentially as a
command line parameter. And unfortunately you can't reliably simulate the
entire world. You may be thinking "use records from previous years etc..."
but no such detailed records, in fact, exist. What you might not realize is
that these ridiculously-complex systems work in time-frames of *pico
seconds*, not hours, not even as long seconds (a second would be essentially
infinite time in the banking world).
So how do they debug their code if they can't run it? You guessed it, the
COMPILER. The code is mostly written in "meta-code" style with built-in
"template-assertions" that alert the programmers to bugs without even having
to execute a single line of code. This is no fairy tale. When you hit
compile, if a varialble happens to have the wrong sign or type, or if a
branch condition happens to be incorrect, they get *compilation* errors.
They are forced to code this way because they are not afforded the luxury of
running and debugging the code "on a whim". That magical occasion (ie.
running/debugging "live code") only happens about twice a year.
So yes, wherever I can, I design my code such that when I make errors they
are automatically caught at compile time. If I think I might make a mistake
due to some implicit type conversion say, then I define that conversion as
"explicit". That's not magic, that's common sense. If I'm worried that I
might accidentally assign a B to an A (where such a conversion happens to be
legal) but I know that 99.9999% of the time that's a mistake, then I declare
A::operator= (const B&); and then deliberately *not implement it*. Then I
get a linker error when I make that mistake.
That's automatic bug detection at compile time. It's not magic. And the
compiler isn't doing it, I am: I'm FORCING the compiler to do it for me.
- Alan Carre
.
- Follow-Ups:
- Re: #define and (brackets)
- From: Tommy
- Re: #define and (brackets)
- References:
- #define and (brackets)
- From: Gerry Hickman
- Re: #define and (brackets)
- From: David Webber
- Re: #define and (brackets)
- From: Alan Carre
- Re: #define and (brackets)
- From: Igor Tandetnik
- Re: #define and (brackets)
- From: Alan Carre
- Re: #define and (brackets)
- From: Alan Carre
- Re: #define and (brackets)
- From: Igor Tandetnik
- Re: #define and (brackets)
- From: Alan Carre
- Re: #define and (brackets)
- From: Alexander Grigoriev
- Re: #define and (brackets)
- From: Alan Carre
- Re: #define and (brackets)
- From: Igor Tandetnik
- Re: #define and (brackets)
- From: Alan Carre
- Re: #define and (brackets)
- From: Igor Tandetnik
- #define and (brackets)
- Prev by Date: Re: IsDebuggerPresent() is true but OutputDebugString() produces no output
- Next by Date: Re: Who gets higher salary a Java Programmer or a C++ Programmer?
- Previous by thread: Re: #define and (brackets)
- Next by thread: Re: #define and (brackets)
- Index(es):
Relevant Pages
|
Loading