Carmack about static analysis

bearophile bearophileHUGS at lycos.com
Sat Dec 24 15:51:57 PST 2011


Adam D. Ruppe:

> It's the same fallacy. I can't read Carmack's mind, but
> I'm sure he's talking about shortening code the same way
> I would mean it if I said it - simpler concepts, fewer cases,
> less repetition.

In a medium sized program there are many different ways to reduce redundancy and repetition, at various levels. Example: modules found online are a good way to avoid writing some chunks of your program yourself. Using certain abstractions sometimes helps to write one idea only once in a program. Etc.

Another significant way to remove repetition at a very different level is to use micro-patterns like higher order functions, like map and filter, and other std.algorithm functions like canFind, count, etc, plus iterators like zip, etc. If you use them you are often able to reduce the code _significantly_ and make it more explicit (because if you use std.algorithm.count the person that reads the code knows you are counting).

But a problem is that such D code is full of braces and parentheses that make such code hard to read and write (I agree with Andrei that D is not very designed for such kind of code, but the fact doesn't change).

Bye,
bearophile


More information about the Digitalmars-d mailing list