Re: #define and (brackets)



"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


.



Relevant Pages

  • Re: How printf() works???????
    ... Getting something totally backwards is,of course, a mistake. ... is no evil intent in my correction. ... What he said to you about your compiler is beside the point and did not ... Therefore Robbie Hatley took your statement as correcting a ...
    (comp.lang.c)
  • Re: How printf() works???????
    ... Getting something totally backwards is,of course, a mistake. ... is no evil intent in my correction. ... What he said to you about your compiler is beside the point and did ... "Hey Robbie, you are an idiot to have said that my compiler is not good ...
    (comp.lang.c)
  • Re: How printf() works???????
    ... Getting something totally backwards is,of course, a mistake. ... What he said to you about your compiler is beside the point ... RHs whole reply was based on explaining the OPs code. ... fuss over *my* reply instead of answering directly to Robbie Hatley, ...
    (comp.lang.c)
  • Re: Two Click disassembly/reassembly
    ... bigger mistake if I deliberately implied such a thing. ... computer, invented a language, and wrote a compiler. ... Some portions used pre-existing tools. ... write the tool and port the code, than it would take me to port the code ...
    (alt.lang.asm)
  • Re: Teaching new tricks to an old dog (C++ -->Ada)
    ... attributes helps both the writer and the compiler. ... > catch at compile time any out of boundaries access. ... C++ array like types don't have these properties. ... Maybe, if one gets used to template programming, the basis of the ...
    (comp.lang.ada)

Loading