🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #5130

Re: Re: Language tools for good code

#5130
From: Vance Morrison
Date: Mon, 08 Feb 1988 14:45
112 lines
5905 bytes

Hello Brad  (et al),

	I am sure that I did not make myself clear when I described
my concept of modularity.  C, Modula-2, Ada, provide some tools that
provide modularity, and as you suggested, it is the programmer, not
the language itself that makes code modular. (a REAL PROGRAMMER can
write fortran in any language (:-). 

	But I as a programmer, can only make my code modular to the
extent that the language lets me.  Try to right a modular program in
old versions of BASIC and you will see what I mean.  Since BASIC does
not have the concept of a procedure with parameter passing and local
variables, its is quite painful to try to write modular programs in
that language.

	In the same way, I want to write code that is much more modular
than common procedural languages (C, ada etc) allow me to do.  I feel
frustrated  and believe that their must be a better way, the language 
just won't let me do it.  That is why I am trying to design this 
next generation language.  

	I believe an example is in order, because I am sure that most
of you are thinking that the present tools are sufficient, if only they
are used properly.   Suppose I wanted to make a general purpose matrix
multiplication routine.  My input is a two matrices and the routine
will return the matrix product.  The only thing my routine needs to
know about the matrices is that how to find their dimensions, how to
index them, and how to add and multiply the individual elements.
I want this routine to work on ANY data structure that has these 
operations defined.  I DON'T want to assume that the matrices are arrays
(for sparse or symmetric matrices it may make more sense to store it
in other ways).   This is impossible in most present languages. 
(although ada can do this with generic packages, but with ada you
run into problems with the strong typing).

	Now some may say that this is a non-problem, that since no-one
would ever need a module that generic, who needs a language that allows
you to make such a module.  I would respond that I have talked to a 
few BASIC programmers who have know conception of how useful a procedure
is.

My concept of modularity boils down to this two simple rules

1) A module should contain in its interface definition ALL the 
   information it needs.  All assumptions about the data a module
   operates on should be stated in the interface definition.  
   This rule makes the module independent of any other module, and
   allow the programmer to treat the module as a 'black box' where
   only the interface definition is visible.

2) A module should ONLY make those assumptions that it needs to do
   its jobs.  In the above example restricting the matrices to have
   only integer elements is a needless assumption, since the operation
   of matrix multiplication can operate on ANY data type that has
   a multiplication and addition operation defined.  (The matrix elements
   could be polynomials, and the SAME code could be used to multiply
   the matrices.

There are other 'nice' features that my language should have.  For
instance, the interfaces should be designed to be easily modifiable,
and flexible, so that the human effort needed to design and hook 
modules together is minimized, but these are 'extra' features.

Present languages allow us to meet the first criterion IF THE PROGRAMMER
DESIGNS HIS CODE WELL.  The second requirement is where present languages
are found lacking.  I believe ANY 'flat typing' (that a typing that 
cannot be hierarchically ordered) like ada, is not flexible enough.
Object oriented languages do better, but become a problem when the
hierarchy of the types need to be changed.  

	My goal is to design a language that meets the above two goals
(as well as several others).  I hope to get some of you also thinking
about these problems and to bounce my ideas off you.  

-----------------------------------------------------------------------

	This passage is unrelated to the above.  

	You mentioned some possibilities for trying to encourage 
programmers to design good code.  I would like to put in my 2 cents
worth.  I believe that the LANGUAGE should not FORCE any code design
practices on the programmer (it may encourage them).  That is the
job of the programming environment and ONLY at a humans request.

	For instance, you could implement an editor a a compiler
switch that warns or even prohibits code that does not meet certain
quality standards.  But the decision to use that feature should be
in the hands of the programmer (or program team leader etc).

	The reason, is that for most rules you propose, there is 
often some time that it is sensible to violate it.  For instance,
when I write small, one shot programs, I do not comment them and
I would become quite mad at any editor/compiler that forced me
to do it.  

	My philosophy is that computers should help people, not
restrict them.  I remember all the time I wasted trying to get
around certain typing restrictions in PASCAL.  (I had a legal reason,
I was interfacing with VMS system services)  I found it quite 
ironic that I was spending a lot of time getting around restrictions
that the compiler programmers spent a lot of time putting in place.

	We have enough trouble overcoming TRUE restrictions, lets
not create any more of our own making.


					Vance Morrison
					morrison@accuvax.nwu.edu
					morrison@nuacc.bitnet
					morrison@northwestern.arpa
Technical Details
Message-ID: <4000010@nucsrl.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!rutgers!mit-eddie!bloom-beacon!gatech!hao!oddjob!nucsrl!morrison
References: <7166@ncoast.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!rutgers!mit-eddie!bloom-beacon!gatech!hao!oddjob!nucsrl!morrison
From: morrison@nucsrl.UUCP (Vance Morrison)
Newsgroups: comp.lang.misc
Subject: Re: Re: Language tools for good code
Message-ID: <4000010@nucsrl.UUCP>
Date: 8 Feb 88 14:45:40 GMT
References: <7166@ncoast.UUCP>
Organization: Northwestern U, Evanston IL, USA
Lines: 112