C++ traps that D2 doesn't avoid yet?

Janderson ask at me.com
Sun Nov 9 00:33:26 PST 2008


ore-sama wrote:
 > bearophile Wrote:
 >
 >> But what I've just said can't help you see why it's so important for 
the compiler to help avoid as many bugs as possible. I can't explain 
such essential concept in few lines here, so I suggest you to keep 
programming and reading, eventually you will probably get it.
 >>
 > it's clearly understandable that we don't need bugs. My point is to 
not let compiler prevent programmer from writing expressive code. If you 
force programmer to write a lot of text to make compiler happy, this in 
turn can cause bugs.

Writing extra code to tell the compiler what you really mean is not 
necessarily a bad thing.  Think about where you actually spend most of 
your time.  If you are working on a small project, maybe you spend more 
of your time typing out the code.  I think this is why scripting 
languages are loved for getting some done fast but grow unwieldy as the 
program gets larger.

For me I can code something up pretty fast once I know what I want.  How 
it interacts with the rest of the system is the difficult part. 
Particularly as a game programmer (I imagine its the same for other 
factions).  I spend most of my time debugging and integrating with other 
peoples code.  It's more difficult to spot a bug that someone else wrote.

Lets take game AI for instance.  The team can do their best to plan out 
a good AI for a character however when you hit the run button the AI 
appears to take on a life of its own.  Why does the character decide to 
pick this target over this other target?  Why does the character go left 
instead of right in this particular situation?  Why does it only happen 
in release?  I don't want spend hours tracking down the issue only to 
find its (for example)
  - an un-initialized variable or
  - a change introduced by Joe which changed how a particular class was 
designed to work. Note: unit tests are great here to enforce things 
continue to work the same way.

Just a general question to everyone.  Do you sometimes take conscious
notes of what you spend your time doing?  Then try to figure out ways to 
improve on it?

I have found that there's things I didn't expect that I was spending 
time on.

Even simple things like:
  - adding commonly used code fragments to visuals assists intellisense
  - using programs like distCC or incredibuild if your build is slow
  - not reinventing the wheel
  - Cheats and macros to improve debugging time.
  - Always fixing a bug and making sure it can't be repeated without at 
least a highly visible warning.
  - Making classes invariant so they can't be used in a wrong way
...
go a long way to improving productivity.

-Joel



More information about the Digitalmars-d mailing list