Two recent, seemingly unrelated, posts got me to thinking about an issue that's been bugging me. I wanted to reply to them, but since both of them (in my mind) are related, here's a new node.
tilly recently made a post about Microsoft being against Perl. He mentioned how the license for beta 2 of Microsoft's Mobile Internet Toolkit lists Perl as a 'verboten' tool for development if you use their toolkit. This is part of a multi-pronged attack by MS to ensure that those lured to the dark side stay there. Some of the prongs are:
In another post, deprecated wrote about de-inventing the wheel:
If you want to say:I hope your script DOES break,use CGI :standard; # instead of... use CGI qw{ :standard };
I agree with him because I feel that it's not good to use features in a way that's been deprecated, undocumented, or ambiguous (well, that's not quite he was saying, but pretty darned close). Now the obvious question is "how the heck are those two related?" The answer lies in point 3.a above: bad coding practices.
For example, in recent versions of IE, you can send a .gif image with a content type of 'text/html' and it will still render correctly. That's because IE will attempt to figure out the content-type and correct it if you have messed up. Now this seems like a nice thing to do. However, what happens is that many developers only test on IE and their Web pages break when displayed in other browsers.
Another, insidious example, is VBScript's date functions. VBScript uses the computer's locale settings to determine the date format that it should be expecting.¹ If it thinks that dates should be in a mm/dd/yyyy format, it will interpret 01/13/2001 as Jan 13, 2001. All well and good, right? Not quite. If you have 13/01/2001 for your date, it realizes that 13 is too large for the month and silently switches the month and day positions, resulting in the same date. Is this what you intended? Maybe, maybe not. It does mean that a program which appears to run correctly (but probably doesn't), cannot be easily ported to other languages since VBScript silently fudges things behind the scenes.
With IE attempting to determine content-type and VBScript attempting to figure out what you really meant with the date, we have MS products that are trying to infer meaning from data. This is a Bad Thing. Even AI systems can't infer meaning, they simulate the inference. When deprecated wrote that he wants use CGI :standard;, I understand where he's coming from. If this is documented and predictable, that's okay, but if it's not, then we shouldn't do that.
The way we instantiate objects is another example:
use Object; my $foo = new Object; # Bad my $bar = Object->new; # Good
In this example, the assignment to $foo is potentially bad. If you have a &new in your current namespace, you will be passing 'Object' to that function. Not good. This is one case where I disagree with Perl's DWIM attitude. We have the potential for subtle errors as a result. Of course, anyone who's tried to instantiate another object while in an object constructor named 'new' is likely aware of this.
From what I can see, Perl doesn't suffer from this too much, but MS products do. The downside of this is that developers who get used to MS's handholding are less likely to develop robust applications. When the software is second guessing the developer, the developer loses the fine-grained control that he or she will eventually need. In fact, I suspect that some of the sites out there that say 'IE Only' have that notice because of the enforced incompetence that can come from using MS tools.
Cheers,
Ovid
Update: For the curious, the way to deal with VBScript's date handling problems is to create dummy data sets and use them for the data source and then verify that the output is what it's supposed to be. Did the code catch all instances of reversed month and day that it should? Naturally, this should be done with any code, but is doubly-important with MS crud due to the behind-the-scenes data munging it does. I can't tell you the agony I've had to go through when VBScript has altered my data, despite there being no code that could create the alterations!
1. Of course, using your computer's locale settings means that the same program can produce different output on different machines depending upon locale. So much for portability.
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.
|
---|