Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

ziggy (25)

ziggy
  (email not shown publicly)
AOL IM: ziggyatpanix (Add Buddy, Send Message)

Journal of ziggy (25)

Friday May 16, 2003
12:39 PM

Language Design: Once and Only Once?

[ #12253 ]
Python's irreverent motto, "There's Only One Way To Do It" is simply a jab at TMTOWTDI. In reality, Guido admits that in some cases, TMTOWTDI works -- especially at the lower layers of a language. A better statement of the Python philosophy is that higher level constructs benefit from using the one, simple, obvious way to do it.

Pragmatic Programming and The Practice of Programming both promote the principle of "once and only once" (OOO), or "don't repeat yourself" (DRY). This is a great piece of advice when writing programs, but doesn't really apply when designing a language. Larry has proven this time and time again with Perl, yet people still like to misapply the OOO principle to the domain of language design.

Here's a case in point, courtesy of David Megginson via the xml-dev list:

> W3C has violated a first-order principle of language design; that
> there should only be one way of doing something, such that everyone
> ought to devise the 'same' program to solve the 'same' problem.

int x = 0;
while (x < 10) {
   printf("hello\n");
   x++;
}

int x;
x = 0;
do {
   printf("hello\n");
} while (x++ < 10);

int x;
for (x = 0; x < 10; x++)
   printf("hello\n");

/* etc. */

It's clearly a principle rarely put into practice (I won't even start on the Common LISP looping constructions).

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • People seem to think that, for example, one looping construct should suffice for all needs. They don't realize that you want different constructs for different needs.

    Different looping constructs may be used to acheive the same end, yet their means may differ; there are often memory, performance, or maintainability (ie readability/debugability/ease of alteration, etc) tradeoffs involved.

    Even though TIMTOWTDI may seem profligate, in reality there are often subtleties at play that are not manifest in the

    • People seem to think that, for example, one looping construct should suffice for all needs. They don't realize that you want different constructs for different needs.

      Yep. Someone said later in that thread that OOO is fundementally wrong at the language design level, using Scheme as an example. Specifically, the idea that you do not need iteration whatsoever, since all iteration can be expressed in terms of recursive functions.

      Don't even get me started on the fallacy that the only data structure yo