Code is Composition


The Purpose of Language

Computers can't yet understand English.  It has largely to do with the utility that spoken language offers to humans.  It's partially a vehicle for communication.  It's partially a medium of expression.  In everyday conversation it's used to share ideas, to inspire, to evoke emotion, to send hidden messages, to obscure facts, to test, or even to actively deceive.  As the saying goes, "Speech was given to man to conceal his thoughts."

Code clears out much of the ambiguity from human speech.  First, it isolates intent.  Computers don't have the need for emotional expression, influence, or deception.  Our interactions are purely factual and cooperative.  Trust can be assumed.  This greatly simplifies the exercise of extracting meaning from or embedding meaning into language.

Declarative programming languages tell the computer what to do.  Even more precisely, imperative code tells the computer how to do it.  Humans and computers are different, but by narrowing the focus of our communications, code allows us to understand each other.

Code also allows humans to communicate with each other.  It's a somewhat unique medium in that it simultaneously conveys the same information to two alien audiences, each via their own distinctive means of interpretation.


 

The Rosetta stone - issuing the same decree in three languages served as a "key to deciphering the Egyptian scripts"

Interpretation

There's an implicit trade off between these means of interpretation.  While a computer has no preference per se, the more verbose the code, the less space-efficient it is.  A group of compressed machine instructions may be near space optimal but will simultaneously render the document beyond cryptic for a human audience.

Moreover, such an efficiently codified message would largely lose the ability to embed semantics.  By virtue of its information entropy, language allows multiple levels of meaning to be contained in the same message.  It's via this mechanism that much of the human to human meaning is embedded in code.  We call it style.

Well styled code should be grammatical.  It should be concise.  It should avoid too much repetition.  If this sounds familiar, it should.  In fact, there's a well know set of rules that provide guidance as to how to produce a high quality, human readable document.

Elements of Style is an ageless classic of English Composition but lends itself surprisingly well to Software, particularly the chapter, "Elementary Principles of Composition."

  • Avoid ambiguity
  • Phrase booleans as positive
  • Be concise and complete
  • Be consistent
  • Group related concepts
  • Etc 

One may even be able to map the tenants of Clean Code with those of Elements of Style.  After all, computers don't care about clean code or style.  Like in any written document, its purpose is to help humans understand each other.

 Links:

 

 

 

Comments

Popular posts from this blog

Engineering Truisms

The Telescoping Constructor (Anti-Pattern)

A Strategic Approach to Precision Process Automation