This post originated from an RSS feed registered with Ruby Buzz
by Jeremy Voorhis.
Original Post: Is Your Code Acceptable?
Feed Title: JVoorhis
Feed URL: http://feeds.feedburner.com/jvoorhis
Feed Description: JVoorhis is a Rubyist in northeast Ohio. He rambles about Ruby on Rails, development practices, other frameworks such as Django, and on other days he is just full of snark.
In his book, Aspects of the Theory of Syntax, Noam Chomsky insists that we make a distinction between language competence and performance. Competence refers to one’s knowledge of a language, while performance refers to one’s ability to practice that language. When discussing language performance, Chomsky introduces the term acceptability. In Chomsky’s words, utterances are acceptable when they are “perfectly natural and immediately comprehensible without paper-and-pencil analysis, and in no way bizarre or outlandish.” Chomsky goes on to describe some structural heuristics for acceptability of the written word. Some things that contribute to the decay of acceptability are repeated nesting of an element, self-embedding of an element and nesting of a long and complex element.
He goes on to suggest that these patterns limit acceptability because they work against the finiteness and decay of human memory. He may not have had programming languages in mind while he wrote this passage, but the same limitations when communicating in English stand when communicating in Ruby or some other programming language.
Simply put, if you are writing software “for a human first and a computer second1”, keep your statements concise and refrain from gratuitous nesting and run-on statements when possible. The interpreter may find your code very acceptable, but you also have a human audience which includes yourself. Look back on some code you have written two weeks ago and ask yourself – is it acceptable?