On Friday, 10 August 2012 at 08:38:18 UTC, Walter Bright wrote:
Take a look at bearophile's list of Ada features advertised as making Ada code less buggy. Then look at, for example, dmd's bugzilla list.

How many of those bugs would have been prevented by Ada's features?

I'd say about 0.

It's a good point.

I'd say it's about the same in my line of work (making games with C++).

Here's what I perceive to be the most common causes of bugs in things I write:

1. Unconsidered use cases.
- e.g. User did X, but I had forgot to consider X when writing the code, or X was considered by poorly tested.

2. Poor knowledge of a system.
- e.g. Wrote the code expecting it to do something, but it didn't do all the things I expected, or my code had unintended side-affects in another part of the system.

3. Uninitialised variables.
- These are relatively rare, but consume a lot of time as they can be hard to reproduce and only appear in release builds.

4. NaN's.
- Quite common in any sort of physical simulation code, and difficult to track down.

5. Threading issues
- Quite rare, but difficult to track down.


I'd say #1 is by far the most common cause of bugs in any project (certainly DMD), and #2 gets more and more common as the number of developers on a project increases (as well as the number of lines of code). DMD is quite small, and you (who has full knowledge of DMD) checks every change list, so #2 is quite rare in DMD.

#3 is solved by D, and #5 as well.

#4 is hard to solve, especially when SIMD comes into the picture (as it often does in that sort of code).

#2 is interesting because you could arguably say that it is partially solved by things like functional programming, which makes some kinds of code simpler, meaning people are less likely to misunderstand how your system works. I have no doubt that it's true, but it's hard to argue that objectively. I don't believe there is any silver bullet for simple code.

Reply via email to