Free Newsletters
Technology & Business Daily

InfoWorld
Log-in | Register

  Friday, March 05, 2004 

Why no 'use strict' in Python?

Yesterday I had the opportunity to speak with Anders Hejlsberg, father of both Turbo Pascal and C#. Of course I had to scratch my dynamic language itch, so we talked some about that. The upshot is that Anders believes compile-time type checking is valuable, but also thinks we can (and probably should) use type inferencing to make static type checking feel more dynamic.

During our conversation, he reminded me of an issue that I've been meaning to ask the Python folks to comment on. To illustrate it, consider exhibits A, B, and C.

Exhibit A. This Python program produces no compile-time error when the misspelled variable aNyme is referenced. It produces an error at runtime.

$ cat loose.py
aName = 'abc';
print '[' + aNyme + ']';
$
$ python -c "compile(open('loose.py').read(),'loose.py','exec')"
$
$ python loose.py
Traceback (most recent call last):
  File "loose.py", line 2, in ?
    print '[' + aNyme + ']';
NameError: name 'aNyme' is not defined

Exhibit B. This Perl program produces no compile-time or run-time error.

$ cat loose.pl
my $aName = 'abc';
print "[" . $aNyme . "]\n";
$
$ perl -c loose.pl
loose.pl syntax OK
$
$ perl loose.pl
$ []

Exhibit C. This Perl program produces a compile-time error.

$ cat strict.pl
use strict;
my $aName = 'abc';
print "[" . $aNyme . "]\n";
$
$ perl -c strict.pl
Global symbol "$aNyme" requires explicit package name at strict.pl line 3.
strict.pl had compilation errors.
$
$ perl strict.pl
Global symbol "$aNyme" requires explicit package name at strict.pl line 3.
Execution of strict.pl aborted due to compilation errors.

A few others out there have made this observation, for example:

I find python confusing on the other hand. e.g. sysmsg = sysmsg.replace('&', ' ')
what if you wrote "sysmgs = sysmsg.replace('&',' ')"
there is a small typo! In perl "use strict;" would find that for you, but python has no equivalent yet. [anonymous comment at LinuxJournal.com]
In my use of Perl, I've sometimes had to relax the constraints imposed by "use strict" -- for example, with "no strict vars" when I'm dynamically conjuring variable names. But on the whole, I never felt (though I'm sure some do) that "use strict" seriously compromised Perl's essential dynamism.

Are there reasons why Python can't, or shouldn't, support something like "use strict"?

 

No-Touch Deployment vs ClickOnce

Mark Levison, one of the developers I interviewed for the .NET story, thinks that Microsoft has undersold the benefits of No-Touch Deployment (NTD), the current solution for running rich .NET clients from the Web. Having done the gruntwork required to understand and use NTD, Mark's not so sure that developers ought to write off this technology and wait for Whidbey's ClickOnce.

I think David [Treadwell] misses much of the point. The caching features of No-Touch Deployment (NTD) work well enough. Click Once will be useful, but there are many other issues dealing with NTD apps. My impression is that MS didn't dog-food enough NTD. I think there are a few key areas that need work. [Mark Levison]

Mostly, Mark's asking for documentation and tutorials that will enable other developers to use NTD effectively, and spare them much of the painful R&D he had to go through. In his posting, he ticks off a very specific and well thought-out list of suggested items to cover in tutorials.

 


Recent Entries


















































Sponsored Technology Links

 
 
 HOME  NEWS  BLOGS  PODCASTS  VIDEOS  TECHNOLOGIES  TEST CENTER  EVENTS  CAREERS   About | Advertise | Awards | RSS | Contact Us 

Copyright © 2008, Reprints, Permissions, Licensing, IDG Network, Privacy Policy, Terms of Service.
All Rights reserved. InfoWorld is a leading publisher of technology information and product reviews on topics including viruses,
phishing, worms, firewalls, security, servers, storage, networking, wireless, databases, and web services.

CIO :: ComputerWorld :: CSO :: Demo :: GamePro :: Games.net :: IDG Connect :: IDG World Expo
Industry Standard :: IT World :: JavaWorld :: LinuxWorld :: MacUser :: Macworld :: Network World :: PC World :: Playlist