Date: 19 Mar 1999 12:24:45 -0500 From: mjd@op.net (Mark-Jason Dominus) Subject: Re: perl and y2k (was Re: The millennium cometh -- eventually) Message-Id: <7cu18t$53q$1@monet.op.net> In article <19990315.123459.1O1.rnr.w164w_-_@locutus.ofB.ORG>, Russell Schulz wrote: >if memory serves, it was MJD who pointed out the basic things you would >do with a year, and to handle them correctly was at least as long (and >in at least one case longer) than to handle them incorrectly, given the >problematic representation (year-1900). Yes. My point is that the interface to `localtime' is very badly desgined. It offers a convenience feature that is *only* convenient if you are *trying* to commit a Y2K error. A long time ago there was a unix filesystem utility that would print a prompt something like this: About to erase filesystem; hit ctrl-C within 10 sec to abort This was, ridiculed, quite rightly, as a monstrously bad user interface, and has since been replaced. If someone using this program accidentally loses their filesystem, whose fault is it? Is the the fault of the operator, who didn't carefully read the manual or follow the printed directions? Perhaps, but I think the program and its author have to shoulder some of the blame. The `localtime' interface is similar. Its most convenient, carefully engineered default case is to do the wrong thing. To do the right thing, you have to make a special effort to defeat the built-in behavior. And the built-in behavior is so egregiously stupid and worthless that it takes you by surprise. Note for people not familiar with `localtime': `localtime' returns the current time as represented by a list of values including seconds, minutes, hours, and so on. The `year' member of this list is not the current year, or even the last two digits of the current year, but rather _the current year minus 1900_, so that it looks like the last two digits of the year, and invites you to use it that way, even though such use will fail next year when the `year' value will be `100'. If a gun fires backwards by default, and people are injured, that is partly the gun manufacturer's fault, no matter how carefully the flaw is documented. The gun has a problem of killing the users accidentally; it is a problem in the gun. It is not right to put all the blame on the person who pulled the trigger. There is a reasonable, normal way for guns to work, and this gun does not work that way. There is a reasonable, normal way for time functions to work, and localtime does not work that way. When it injures the user, you cannot put all the blame on the user; the poor design is also to blame. Software designers are not any more exempt from responsibility for bad engineering than are the designers of any other artifacts. Saying `Perl does not have a Y2K problem' is naive. `localtime', and by extension Perl, has an egregiously bad design that encourages Y2K errors as the most normal and common form of operation. This is, in fact, a problem with localtime, and not with the programmers who use it or with anyone else.