Carmack about static analysis

Derek ddparnell at bigpond.com
Sat Dec 24 07:11:59 PST 2011


On Sat, 24 Dec 2011 23:42:41 +1100, bearophile <bearophileHUGS at lycos.com>  
wrote:

> A new blog post by the very good John Carmack, I like how well readable  
> this post is:
> http://altdevblogaday.com/2011/12/24/static-code-analysis/
>
> ... human minds and the logic of lint programs are two cognitive (or  
> pre-cognitive) systems that work in very different ways. Often what's  
> obvious and easy for a mammalian brain can't be seen by a lint tool and  
> what a lint tool finds easy to spot is hard to find for a human brain.  
> So they are both needed. The difference in the way computers and people  
> "think" is one of reasons of the usefulness of computers for our society.


But isn't lint written by humans? I'm pretty certain 'lint' is not a  
cognitive entity, but just a program written by people, who as we all  
agree, can and do make mistakes. I'm under the impression that a //lint//  
program is an attempt to emulate a very pedantic (if not anal-retentive)  
person who in real life would have no real friends, due to their  
obsessive–compulsive habit for extreme nit-picking.

So in saying that, I would have to side with John Carmack in so far as  
thinking that if a near-perfect lint program cannot understand some source  
code, then a regular coder would also have difficulty in groking it.

In short, it does no harm to make one's code as readable (such that your  
intention is exceedingly obvious) as possible.

> Here there are some bad examples about /Analyze:
> http://randomascii.wordpress.com/2011/09/13/analyze-for-visual-studio-the-ugly-part-5/
> In the same blog you see many other similar cases.


The article you reference is primarily saying that this specific lint-like  
functionality contains bugs. It is not an argument to convince us to  
abandon lint functionality.


> In theory functional-style is a good to shrink the code, but in D  
> functional-style code is a jungle of (({}){()}) so it's hard to write  
> and hard to read.

I once, long ago, suggested to Walter/Andrei that D is approaching the  
ASCII equivalent of APL. The actual text of D source code can be a  
hindrance to reading the code, let alone understanding what has been  
written. I know it is hyperbole, but some D source modules are close to  
write-only code, meaning that it takes specialist/expert D knowledge to  
understand some source code. I'm not so certain that this is a desirable  
feature of any programming language.

-- 
Derek Parnell
Melbourne, Australia


More information about the Digitalmars-d mailing list