By Douglas Crockford's Department of Style | Article Rating: |
|
December 12, 2008 06:15 PM EST | Reads: |
748 |
Certain elements in the Java and JavaScript communities have been buzzing about Tennent's Correspondence Principle. I have heard it described as the ability to replace an expression with a function, so that
expression
means the same thing as
(function () { return
expression; })()
There are some things that can't be enclosed that way, such as return
statements and break
statements, which the advocates of Tennent's Correspondence Principle (or TCP) claim is a symptom of a bad smell. Yow! Language design is already difficult enough without having to cope with olfactory hallucinations. So to better understand the problem, I bought a copy of Tennent's 1981 book, Principles of Programming Languages.
It turns out that the Correspondence Principle is descriptive, not prescriptive. He uses it to analyze the (by now forgotten) Pascal programming language, showing a correspondence between variable definitions and procedure parameters. Tennent does not identify the lack of correspondence of return
statements as a problem.
He does seem to have some specific notions of good programming language design, however. For example,
Many existing languages only managed to combine countless "features" into a jumble that is neither easy to implement nor a pleasure to use.
It is amazing how little has changed since 1981. He also has warnings about side effecting features such as getters and setters:
Side effects are often confusing to program readers because they are unexpected: the familiar expressions of conventional arithmetic and algebra do not have side effects.
Read the original blog entry...
Published December 12, 2008 Reads 748
Copyright © 2008 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
Feb. 17, 2019 02:00 AM EST |
By Elizabeth White ![]() Feb. 16, 2019 04:45 PM EST Reads: 14,062 |
By Zakia Bouachraoui Feb. 16, 2019 04:00 PM EST |
By Zakia Bouachraoui ![]() Feb. 16, 2019 03:30 PM EST |
By Yeshim Deniz ![]() Feb. 16, 2019 05:45 AM EST |
By Yeshim Deniz Feb. 16, 2019 03:15 AM EST |
By Pat Romanski Feb. 16, 2019 12:15 AM EST |
By Roger Strukhoff Feb. 14, 2019 05:00 PM EST |
By Elizabeth White Feb. 13, 2019 08:15 PM EST |
By Liz McMillan Feb. 13, 2019 06:45 PM EST |