Language Features for Management on Dr. Dobb's

Markus Koskimies markus at reaaliaika.net
Tue Jul 15 16:20:52 PDT 2008


On Tue, 15 Jul 2008 15:42:02 -0700, Walter Bright wrote:

> http://dobbscodetalk.com/index.php?option=com_myblog&show=Language-
Features-for-Management.html&Itemid=29

1) I agree, that programming languages are for programmers, not for 
management. That is the whole starting point! At my work, I use the 
languages, environments and coding standards the employer wants me to 
use; at freetime, I use Linux, Python, D and Java, in that order.

2) I disagree with the fundamental purpose of coding standard. Anyone 
being involved in a big project knows what they are for; they are not for 
being right or wrong, they are there just for psychological reasons.

The very definite basics of those psychological reasons are that 
currently humans make the code (whenever this changes, the rules change 
too). That sets up constrains, that you cannot solve at formal level. 
>From compiler point of view, things like (a) indentations, (b) comments 
and (c) variable namings are just totally irrelevant.

The main purpose of coding standards are that when you have 100 
programmers, all of them make similar code. What is the purpose of that? 
The main purpose is, that all the 100 programmers understand AS QUICKLY 
AS POSSIBLE the outcome of the other 99 programmers. There are of course 
other purposes of standards, e.g. you might have scripts that eat just a 
definite way of making things, and they normally hold "lessons-learned" -
knowledge of the smartest programmers in the company, but the main 
purpose is still, that when you look the (foreign) code of those 99 other 
programmers, it is immediately familiar to you and it is something that 
you might have also written.

To understand this issue, consider two infinite loops (written in D-like 
pseudolanguage):

1) First one:

	for(;;) { ... }

2) Second one;

	long f(int x) { return (x*2) -2 + math.pow(x, 2); }
	for(; ((uint)-2) > f((2*2 + 1, true)) { ... }

Which one is easier to follow? From compiler point of view, they make no 
difference. Compiler easily detects - or at least smart compiler does - 
that the second one is formally equivalent to infinite loop. But humans 
does not really work that way.

As said the purpose of the programming standards is not to be perfect, 
not to be complete or not to be even good. Their fundamental purpose is 
that when you have learned it, every piece of (very large) code look like 
you have written it by yourself. You understand quickly what the code is 
expected to do and - mor eimportantly - you quickly recognize "odd" 
structures that require more time to think about! I personally think that 
there it is wasted time for me to try to understand programs that are 
more complex (at source level) than they should be. That all just tells 
to me that the one who made the program is not professional, and that the 
problem he/she tried to solve was too complex to him/her.

When at freetime, I occasionally amuse myself by writing obfuscated 
codes; I try to make some things happening in that way that it is very 
hard to understand. That is only playing around; normally, I want to make 
code that I myself understand one month later. Normally, I include "usage
()" function to my codes. Normally, I use safe variants of function calls 
to make my own precious program to halt before it makes some stupid (or 
does not do anything what is far more frustrating when you have forgot 
how to use your own program!). Normally I put my coins to compiler to 
optimize away structures that makes the code easier to understand but 
which are not optimal for processors. Normally, I put my coins to 
algorithmic optimizations, not to try to optimize one loop; I have done 
that, being there, and found it not profitable - not for me, not for 
others.



More information about the Digitalmars-d mailing list