Solving one problem by creating a bigger problem


Often, people will not even realize that their solution to a problem merely replaces it with another problem. The quip attributed to Jamie Zawinski captures the sentiment:

Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.

For example, in response to "How do I write a batch file that..." some people will say, "First, install <perl|bash|monad|...>". This doesn't actually solve the problem; it merely replaces it with a different problem.

In particular, if the solution begins with "First, install..." you've pretty much lost out of the gate. Solving a five-minute problem by taking a half hour to download and install a program is a net loss. In a corporate environment, adding a program to a deployment is extraordinarily expensive. You have to work with your company's legal team to make sure the licensing terms for the new program are acceptable and do not create undue risk from a legal standpoint. What is your plan of action if the new program stops working, and your company starts losing tens of thousands of dollars a day? You have to do interoperability testing to make sure the new program doesn't conflict with the other programs in the deployment. (In the non-corporate case, you still run the risk that the new program will conflict with one of your existing programs.)

Second, many of these "solutions" require that you abandon your partial solution so far and rewrite it in the new model. If you've invested years in tweaking a batch file and you just need one more thing to get that new feature working, and somebody says, "Oh, what you need to do is throw away you batch file and start over in this new language," you're unlikely to take up that suggestion.

So be careful when you suggest a solution that has a high activation energy. Sure, something could be taken care of by a one-line perl script, but getting perl onto the machine is hardly a one-line endeavor.

Comments (84)
  1. Maurits says:

    … ah, if only "find" supported regular expressions …

  2. Another example of "when the only tool you have is a hammer…".  My favorite are the deep SQL people – any problem can be solved with SQL.  I once needed a little desktop alarm clock/reminder.  A SQL person suggested building it around some feature of SQL Server.  (I need a wristwatch – I get Big Ben.)

  3. Chris says:

    The source of the JWZ quote is the Unix Hater’s Handbook, and it’s actually a reference to "sed", the standard Unix stream editor:

    <blockquote>

    Some people, when confronted with a problem, think "I know, I’ll use sed." Now they have two problems.

    </blockquote>

  4. Adam says:

    How about, some people, when confronted with a problem, think "I know, I’ll use a batch file." Now they have two problems.

    Seriously.

  5. Centaur says:

    If only batch language was sufficient for any nontrivial tasks.

    Here is a perl script I consider handy.

    ($pattern, $replace, $options) = @ARGV;

    foreach (glob(‘*’))

    {

     if (m/$pattern/i)

     {

       $oldname = $_;

       eval("s/$pattern/$replace/i$options");

       print qq(ren "$oldname" "$_"n);

     }

    }

    Invoked normally, it will show which file names match the given pattern, and what the given replacement will do to them. When the result is satisfactory, pipe the output to cmd.

    Now, how do I do that with batch language and findstr…

  6. James Risto says:

    Thanks for FINDSTR … I use it a whole lot, and avoids me saying "maybe I will install GREP" and then have a new problem.

  7. Marco M says:

    The analysis it’s incomplete however. It should also take into consideration future problems, based on the analysis of past ones.

    Even if perl is absurdly overkill right now, it might be the right choice anyway if it will help the 99% of future problems. On the contrary if it will surely be useless in every future project, avoiding it might be the right choice even if it’s not overkill right now.

  8. Nektar says:

    The real question is why hasn’t Microsoft provided by default with Windows Perl or Unix utils or even Monad with Vista. No it will not even be included in Vista and such is the state of affairs for 20 years.

  9. oldnewthing says:

    Nektar: cscript.exe has been around for a long time. Write your command scripts in JScript or VB.

  10. DavidE says:

    Windows scripting host is OK, but it has some very significant shortcomings, particularly in the way it handles redirection. Things that you can do easily in Perl or bash are very annoying in WSH. Being able to pipe things to a loop is indispensable. At the very least, someone in MS who handles scripting should really study the Unix utils and see what’s missing that could be added to make WSH more useful.

    Also, for little things, it would really be helpful if there was a suffix that Windows would recognize as "run this with cscript" or "run this with wscript". I know I can hack it for my system, but I want it to work without hacking every system.

  11. Coderjoe says:

    So you’re suggesting I need to learn another new langauge to perform some task, which I could do quickly using some other tool or langauge I already know, but isn’t installed by default?

  12. AC says:

    "At the very least, someone in MS who handles scripting should really study the Unix utils and see what’s missing that could be added to make WSH more useful."

    They did. See Monad development

  13. I finally tried out Regular Expressions in just one such moment of "I hear these help.", followed by a couple of days of "What?"  and "Help?" and "Thank goodness for internet tutorials!".

    I now find them invaluable, and they’ve saved me a load of time.  But they certainly delayed the first project I used them in…

  14. BryanK says:

    If you’ve invested years in tweaking a batch

    > file and you just need one more thing to get

    > that new feature working, and somebody says,

    > "Oh, what you need to do is throw away you

    > batch file and start over in this new

    > language," you’re unlikely to take up that

    > suggestion.

    Unlikely, perhaps, but it still might be the Right Thing to do.

    Case in point: we have a program we use internally to print barcode labels for the boxes we ship out the door.  It was originally written in VB4, and had had several band-aids applied over the years, to the point where it was getting really quite crufty.  It had also been upgraded to VB5, then VB6, so it had some old vestiges of VB4 in it along with the new VB5 and VB6 stuff.  The backend database was created in Access 95 (or 2.0, not exactly sure which), and had been upgraded through 97 to XP, so it also had some ancient cruft in it.

    Now, yes, we could have just kept adding band-aids to the system, and kept it hobbling along forever, and yes, there was a large investment in rewriting it in .net and SQL, but IMO it paid off very well.  We removed a bunch of the concepts of the old version ("batch" mode being separate from "on-demand" mode, for instance; now there’s just a button to print a group of labels, which is disabled for certain parts), and made the entire system much simpler.

    My point is that while there’s an obvious cost involved in all rewrites, there’s often a more "hidden" cost when you just try to patch up your old batch file, and this hidden cost is often larger over time.  Patching involves small incremental costs forever; rewriting involves one large cost, then a comparatively longer time of no cost.  (And then another time of lower costs, because when the invariable changes in requirements do come, it’s often easier to make the changes in the code after a rewrite cleans out the old junk that doesn’t need to be there anymore.)

  15. It’s helpful that MS has maintained the batch language

    for those of us still running QDOS scripts we wrote

    in 1980.  However MS has had almost 25 years to ship

    a new batch language that, say, is based on

    Unix’s sh, (which was written when — in 1972?)

    but smart enough to recognize when it’s about to

    process a batch file and handle that transparently.

    I’ll leave compatibility details as an exercise

    for the reader.  But whatever happened to the ‘switch’

    command that shipped with DOS 3.x?

  16. O says:

    Microsoft should just ship perl with their system like every other operating system vendor does, but as usual they are too arrogant and suffer from Not Invented Here syndrome.

  17. Alun Jones says:

    For Centaur:

    @echo off

    setlocal enabledelayedexpansion

    for %%a in (*) do (

     set aaa=%%a

     set bbb=!aaa:%1=%2!

     if not !aaa!==!bbb! echo ren !aaa! !bbb!

    )

    Sure, it doesn’t use regular expressions for the patterns to match, but … it’s a batch file, it works, and it’s not exactly hard to follow… uh… if you know batch files, that is.

    Here’s an example of a run:

    C:>renit vbs foo

    ren listusers.vbs listusers.foo

    ren listusers.vbs;0 listusers.foo;0

    ren searchpad.vbs searchpad.foo

    ren searchxt.vbs searchxt.foo

    ren datediff.vbs datediff.foo

  18. Dave says:

    Then again, do you really want Windows Update to start hosting a CPAN mirror?

  19. Gene says:

    Unix Hater’s Handbook

    FYI, there’s a PDF of that on the net, and it’s even approved by the authors.

    > Microsoft should just ship perl with their system

    Please god, don’t propagate that atrocity any further. I prefer my languages designed, instead of dealing with what Larry Wall regurgitated from a bunch of UNIX man-pages. APL and perl are write-only languages.

  20. Pops says:

    Counterpoint:

    Yesterday I needed to process a couple hundred files, finding and extracting a value from each and changing two values in each. So I downloaded and installed Perl, refreshed my memory with a couple of tutorials, and was done within about an hour. And now I have a program that will repeat the process in a couple of seconds when I need it again.

  21. oldnewthing says:

    Pops: Awesome. What did your legal department have to say about that?

  22. Alun Jones says:

    Define:engineer

    Someone who will spend thirteen hours building a tool that will allow a twelve hour task to be done in one hour… and will then forget to do the task.

  23. waleri says:

    > Unix Hater’s Handbook

    >FYI, there’s a PDF of that on the

    net, and it’s even approved by the authors.

    And distributed by Microsoft

    Ref: http://research.microsoft.com/~daniel/unix-haters.html

  24. waleri says:

    Sorry, "distributed" was supposed to be in quotes in the above post

  25. Grant says:

    Actually, Microsoft used to ship Perl on the resource kit cd; they just didn’t install it by default.

  26. J. Peterson says:

    With Mac OS X, I get python perl, applescript, and various shells right in the box.  No installation necessary.  With Windows, I get..uh…"batch files".  Disk space is no longer an issue.

  27. Isaac Lin says:

    Not sure it is appropriate to hit Microsoft for NIH syndrome with respect to Perl, given that they provided substantial funding, as I understand it, for the oneperl effort that converged the Win32 Perl fork with the main Perl sources. I believe this was in response to customer demands that Perl be better supported on Windows. Microsoft itself has provided tools in the past that were implemented in Perl.

    As for bundling Perl, at least historically I guess anti-trust issues made it a bit tricky to do so.

  28. Cooney says:

    Centaur:

    > Here is a perl script I consider handy.

    That’s odd. I just type ‘echo <pattern>’

    Gene:

    > Please god, don’t propagate that atrocity any further.

    Yeah, it’s Evil, but it’s a useful sort of evil. Way less nasty than batch files.

  29. Marco M says:

    >> Pops: Awesome. What did your legal department have to say about that?

    What are exactly the issues in using perl ?

    This comment smells FUD. Be explicit or don’t say anything at all. Also, I might add, there is more legal danger in using MS technologies (I’m just thinking of the browser activex license) than open ones..

  30. Marco M says:

    Just wanting to add..

    many companies have the policy of letting free install of well known open source software (perl, apache, vnc, vlc, firefox, putty, cygwin etc etc etc) at least on developers machines.

  31. TrueRegExpHater says:

    I hate RegExp. It’s both infinite complex while useless. It cannot handle the simplest task like searching every rows including one word and not including another.

  32. oldnewthing says:

    I don’t know what the issues are with using perl. That’s why you have to ask the lawyers. Some IT departments also don’t like it when people run unauthorized software on their work computers.

    Some packages may contain restrictions such as "The terms of this license apply to anything produced with the aid of this packages," or "For non-commercial use only." And if you redistribute the packages with your own product, then things get really interesting. (Who is liable if a security hole or patent infringement is found in that package?)

  33. John Liu says:

    I think at the end of the day, people just need to evaluate more whether "solution A" is better than "solution B".  Rather than sticking with the "I have a hammer and everything looks like a nail" mentality.

    In one project I wanted to replace the manual build process with NAnt, but was shot down by the management because they wanted to ‘evaluate various build programs and choose one for the entire product line’.  I ended up just sticking with batch files for that one project.  I was upset at the time, but now looking back, it was probably the right thing to wait.  The entire product line is using MSBuild now, does the job that NAnt would have done, but was a lot easier to preach to the non-techie management than this FOSS NAnt.

    2c

  34. Daev says:

    Ah yes, the useless become-like-me-first answer.  These responses always remind me of:

    "I’m having trouble finding a seat at the synagogue during Yom Kippur.  What can I do?"

    "Why don’t you try converting to Christianity, you heathen."

  35. Rich says:

    If batch scripting, cscript, etc. were easier to use (and, possibly, cross platform) you’d probably see better usage of them.  I know you weren’t trying to toe the MS line here–you’ve got some good arguments–but it sure looks like shilling to those unfamiliar with you.

    "I don’t know what the issues are with using perl. That’s why you have to ask the lawyers. "

    "Some packages may contain restrictions such as  ‘The terms of this license apply to anything produced’…"

    MS software contains restrictions, too.  The lack of having to track down license restrictions is not an advantage MS tools typically have.  Not to mention the fact that it is pretty rare to have an open-source scripting language have restrictions on script products.  Certainly the popular ones do not have such restrictions (gee, wonder why?).  Not to mention, I can find the restrictions on the root level of the distribution in a clearly labeled LICENSE file that is pretty readable, at least in the beginning.  Where’s my MS EULA and distribution rules for cscript scripts?  Heck if I know, and it’d be unreadable if I did find it.

    "Some IT departments also don’t like it when people run unauthorized software on their work computers. "

    True.  Can’t argue with you there.  The same goes for "high activation energy"  I do think IT sometimes gets carried away with preventing rather than enabling.

    You forget, though, all these newfangled programs and incredibly fast broadbrand combine to let people get up and running in minutes, not "half an hour".

  36. Nawak says:

    @Raymond:

    > Some packages may contain restrictions such as

    >"The terms of this license apply to anything

    >produced with the aid of this packages," or "For

    >non-commercial use only."

    A bit offtopic but I think that this kind of license is non-binding. And I remember that a court in Germany ruled in that way some time ago (granted, I live in France , not Germany…). The point is: these licenses are not contracts since I didn’t sign them (if they think I did, I want to see my signature somewhere) and therefore not enforceable. Don’t blindly trust what I say, IANAL!

    Oh but believe me, I know that my company (and I) could certainly get in a lot of trouble given a sufficiently talented (lawyered?) opponent!

    Anyway, sometimes I put away theoretical illegality (still within morality) and choose to focus on the actual job being done. Life is nicer that way. Maybe you can’t afford that Raymond, you are certainly more watched than I do…

    >And if you redistribute the packages with your

    >own product, then things get really

    >interesting. (Who is liable if a security hole

    >or patent infringement is found in that

    >package?)

    That is a point I addressed. Of course anything that ships shall be cleared by the legal department. I don’t think anybody would find clever to ship alien code within your company’s product without notifying anyone!

    At least I hope so!

  37. David Candy says:

    Remember there are more languages than batch in Windows. VBS can do RegExp. Also there is no point converting – those Christians just worship Jews. Who has spotted the error in the comment box section.

    On Error Resume Next

    Set ShellApp = CreateObject("Shell.Application")

    ReportErrors "Creating Shell.App"

    set WshShell = WScript.CreateObject("WScript.Shell")

    ReportErrors "Creating Wscript.Shell"

    Set objArgs = WScript.Arguments

    ReportErrors "Creating Wscript.Arg"

    Set regEx = New RegExp

    ReportErrors "Creating RegEx"

    Set fso = CreateObject("Scripting.FileSystemObject")

    ReportErrors "Creating FSO"

    WshShell.RegWrite "HKLMSoftwareMicrosoftWindowsCurrentVersionApp Paths" & Wscript.ScriptName & "", Chr(34) & Wscript.ScriptFullName & Chr(34)

    WshShell.RegWrite "HKLMSoftwareMicrosoftWindowsCurrentVersionApp Paths" & Left(Wscript.ScriptName, Len(Wscript.ScriptName)-3) & "exe" & "", Chr(34) & Wscript.ScriptFullName & Chr(34)

    ReportErrors "Updating App Paths"

    If objArgs.Count = 0 then

    MsgBox "No parameters", 16, "Serenity’s ReplaceRegExp"

    ReportErrors "Help"

    ElseIf objArgs.Count = 1 then

    MsgBox "Only one parameter", 16, "Serenity’s ReplaceRegExp"

    ReportErrors "Help"

    ElseIf objArgs.Count = 2 then

    Set srcfile = fso.GetFile(objArgs(0))

    ReportErrors "srcFile"

    If err.number = 0 then Set TS = srcFile.OpenAsTextStream(1, 0)

    If err.number <> 0 then

    Msgbox err.description & " " & srcFile.path, 48, "Serenity’s Search"

    err.clear

    else

    ReportErrors "TS" & "     " & srcFile.path

    Src=ts.readall

    If err.number = 62 then

    err.clear

    else

    ReportErrors "ReadTS" & "     " & srcFile.path

    regEx.Pattern = objArgs(1)

    regEx.IgnoreCase = True

    regEx.Global = True

    If regEx.Test(Src) = True then

    Msgbox "Found in " & srcfile.path, 64, "Serenity’s Search"

    End If

    End If

    End If

    ReportErrors "Check OK" & "     " & srcFile.path

    Elseif objArgs.count = 3 then

    Set srcfile = fso.GetFile(objArgs(0))

    ReportErrors "srcFile"

    If err.number = 0 then Set TS = srcFile.OpenAsTextStream(1, 0)

    If err.number <> 0 then

    Msgbox err.description & " " & srcFile.path, 48, "Serenity’s Search"

    err.clear

    else

    ReportErrors "TS" & "     " & srcFile.path

    Src=ts.readall

    If err.number = 62 then

    err.clear

    else

    ReportErrors "ReadTS" & "     " & srcFile.path

    regEx.Pattern = objArgs(1)

    regEx.IgnoreCase = True

    regEx.Global = True

    NewSrc= regEx.Replace(Src, objArgs(2))

    If NewSrc<>Src then

    Msgbox "Replacement made in " & srcfile.path, 64, "Serenity’s Search"

    TS.close

    Set TS = srcFile.OpenAsTextStream(2, 0)

    ts.write newsrc

    ReportErrors "Writing file"

    End If

    End If

    End If

    ReportErrors "Check OK" & "     " & srcFile.path

    Else

    MsgBox "Too many parameters", 16, "Serenity’s ReplaceRegExp"

    ReportErrors "Help"

    ReportErrors "All Others"

    End If

    Sub ReportErrors(strModuleName)

    If err.number<>0 then Msgbox "An unexpected error occurred. This dialog provides details on the error." & vbCRLF & vbCRLF & "Error Details " & vbCRLF & vbCRLF & "Script Name" & vbTab & Wscript.ScriptFullName & vbCRLF & "Module" & vbtab & vbTab & strModuleName & vbCRLF & "Error Number" & vbTab & err.number & vbCRLF & "Description" & vbTab & err.description, vbCritical + vbOKOnly, "Something unexpected"

    Err.clear

    End Sub

  38. Cooney says:

    Daev:

    > "Why don’t you try converting to Christianity, you heathen."

    For some reason, I read that with a Jewish accent and it was hilarious.

  39. Baz says:

    TrueRegExpHater:

    "I hate RegExp. It’s both infinite complex while useless. It cannot handle the simplest task like searching every rows including one word and not including another."

    True if pattern FOO does not match, but pattern BAR does:

    /(?=^(?:(?!FOO).)*$)BAR/s

    So, you were saying?

  40. Dave says:

    "Solving a five-minute problem by taking a half hour to download and install a program is a net loss."

    This is exactly my objection to the bloated .NET framework. Why add dozens of megabytes of Someone Else’s Code to the mix? It looks like Vista will ship with basically no CLR-based apps, even though its developers are guaranteed they have the .NET framework. I am following their lead.

  41. Chee Wee says:

    Sounds like you’re talking about VB and VB.NET. ;o)

  42. Nawak says:

    Raymond:

    I work for a large company and I am often installing tools without asking for permission (all the more if it would be to the legal department).

    Why? Because I need to get work done. You can say everything you want about the fact that in theory the EULA may be against corporate policy or maybe it will conflict with some other software etc, but if it is a ‘satellite’ tool I know and know it will help me, then it gets installed.

    I consider the EULA irrelevant, I will bear responsibility for any damage the program does (what could it do?) and consider not binding any "you must give us your first born baby"-clause in the EULA.

    Note that I am talking about satellite tools, ie tools that helps getting the job done but are not necessary to doing it and, of course, will not be shipped with the product.

    Note *also* that I am only talking about public domain/freeware/shareware tools, not pirated copies! (In that case, there is of course a legal question in the matter!)

    Otherwise, for source code or tools that we want to include inside or alongside our product, we of course ask the legal department, but that is because they are responsible for what ships, so it’s perfectly logical.

    The perennity of the solution is an interesting point and we consider it for other tools, but as I said, I am only talking about satellite tools, not production shell scripts etc.

    If my "personally-installed" SmartFTP refuses to run tomorrow, I don’t care, there are other FTP clients available.

    Same for PuTTY, cygwin, perl, LinCVS, WinHex, VLC, Firefox, Thunderbird and many many others!

    BUT my work would really be slower without them!

  43. Marco M says:

    > "The terms of this license apply to anything produced with the aid of this packages," or "For non-commercial use only." And if you redistribute the packages with your own product, then things get really interesting.

    It’s really funny because the only one time when we had serious problems was with the internet explorer activex (shdocvw) which is already included in the OS, but using it in your application is not so easily permitted it seems. Finding some license is very hard, and also it seems you must have an IEAK license which is customly made by MS potentially different for each customer.. that means MS might refuse you a license or even revoke it. There is not even documentation around (or it’s hard to find) to check if the .NET framework 2.0 browser control (which is just a wrapper) has the same licensing burden or not.

    On teh contrary there is not much to check on an unaltered GPL2, LGPL2, MIT or BSD license.

    >> (Who is liable if a security hole or patent infringement is found in that package?)

    The security hole is a non-issue. Unless you suddenly became liable for security holes in Windows… as always the author takes no responsibility etc etc etc. This is for all software around open or not. For the patent ones I wonder what happens for MS software. Apart from forcing a patch download (already happened) which removes the issues.. the patch download could be done by open source developers too. Or I can remove the offending code myself in an extreme. And in the meanwhile I’ll support antipatents politicians.

  44. TrueRegExpHater says:

    Baz, that isn’t a valid regexp syntax according to findstr and VS.

    Anyway, if it had worked, don’t you think the syntax is overcomplicated for such a simple and common task?

    So, you were saying?

  45. Dave Harris says:

    The point is: these licenses are not

    > contracts since I didn’t sign them (if

    > they think I did, I want to see my

    > signature somewhere) and therefore

    > not enforceable.

    That doesn’t quite make sense. A licence gives you permission to do something; as such it doesn’t need to be enforced. The restrictions amount to situations that the licence does not cover, where the default copyright law applies. They don’t need your signature to be enforceable.

    For example, the GPL gives you permission to distribute source, and permission to distribute source+object code. If you distribute object alone, then you are doing something the licence hasn’t given you permission for, so you are in breach of copyright and can be sued for it. (However, the remedies will be the same for any other breach of copyright – eg they can’t compel you to distribute your source code.)

    (I am not a lawyer either.)

  46. Ben Bryant says:

    "I now find [regular expressions] invaluable" you missed the point. Yes they can be great, but this is about whether the reg exp facility is available to your program — if it involves an install or could potentially trip over differences in reg exp implementations installed by or borrowed from other components, then it is more of a problem than a solution.

  47. oldnewthing says:

    AC: I don’t see how perl solves the problem – it looks like it has the same problem as your custom program.

    "Copying PERL.EXE to C:WINDOWS was one easy step, but the dissadvantage is that it’s not the user’s dir (he will certainly forget to copy the PERL.EXE from C:WINDOWS when he changes machine). Alternative would be to make some new dir in user’s folders, add it to the path bla bla bla. When he changes to the new machine he would have to add the path himself."

  48. e.thermal says:

    Pops; The same thing could be done in vbscript in about 30 minutes without installing anything on the machine and can be fully tested with a proper debugger.

  49. 8 says:

    "getting perl onto the machine is hardly a one-line endeavor"

    apt-get install perl-base

    (but in practice that would tell you it’s already the latest version)

    "MS software contains restrictions, too."

    Yes, the FrontPage 2002 EULA forbid users to write pages that are against Microsoft, MSN, MSNBC etc. Not only is that (imnsho) short-sighted, but unconstitutional.

    "If you distribute object alone, then you are doing something the licence hasn’t given you permission for, so you are in breach of copyright"

    yes, but you can "Accompany it with a written offer, valid for atleast three years for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code…" http://www.gnu.org/licenses/gpl.html

    AC, use echo or type to write a VBScript to a file and execute it with cscript. Dirty trick, but should work.

  50. What people ask for and what they want are not always the same thing.

  51. oldnewthing says:

    8: There’s probably a "su root" in there somewhere too. And then you have to deploy it to all the systems on your network and add it to the hard drive image that you use on all the machines you acquire.

    And the bit about quoting the license agreement only supports my point: You have to read the license agreement and determine whether you (and your company) are okay with its terms. Typically this involves a lawyer.

  52. keithmo says:

    AC:

    set today=%DATE%

    set filename=%today:~10,4%-%today:~4,2%-%today:~7,2%

    Caveat: I have no idea if this works in non-US locales.

  53. I hate to say this, but this is like saying that one musnt give preference to .Net because of the RTM download and installation issues. Not that I disagree with the previous statement, but the difference between .Net 1.1 and 2.0 is so huge that I must think twice before starting off on a .Net 2.0 based project.

    Oh, I dont have a choice either.

    So the problem is that of writing a framework/API that comes bundled with the OS and doesnt require  a lot of support and maintenance behind it. What’s more important is  failsafe silent installation.

  54. oldnewthing says:

    Indeed, installing .NET to print the date is overkill. You have to balance the benefit against the activation energy. My point is that many people ignore cost of the the activation energy.

  55. Alun Jones says:

    You really have to love an argument about the legalities of software licencing that includes commentary such as describing a software licence as being "unconstitutional".

    The Constitution (at least, in the USA, which I think is where the author "8" was referring to) restricts what the government can do.  Microsoft, not (yet?) being the government is not bound by the Constitution.

    Clearly, I’m not a lawyer either, so I think that neatly draws us back to Raymond’s original point – that you should get approval from your company’s legal department before you go approving software for use.

  56. Baz says:

    TrueRegExpHater:

    "Baz, that isn’t a valid regexp syntax according to findstr and VS."

    That regexp works perfectly fine here in Perl :) What? findstr/VS/whatever-M$-regexp-engine-you-are-using doesn’t support negative lookahead assertions? Now there’s a surprise.

    "Anyway, if it had worked, don’t you think the syntax is overcomplicated for such a simple and common task?"

    I would suggest that the syntax is only overly complicated if you don’t understand it.

    So, you were saying?

  57. Codejoe says:

    Raymond, I think you went overboard with the reply to AC’s perl vs custom simple programs and cmd example. There is no manually copying PERL.EXE into C:WINDOWS or such. The perl install program takes care of adding the perl binary directory to your path.

  58. Coderjoe says:

    Nawak:

    I believe that currently, law works on the fact that you have to make a copy in order to run any software. When you install it, you make a copy to your hard drive. When you run it, you make a copy into ram, etc. In order to have the legal ground to make these copies, you need to have a license that grants you the rights. Remember that the default copyright license is "All Rights Reserved," which means that the copyright holder has to explicitly grant you rights, and any rights not explicitly granted are not allowed.

    IANAL, but I have done a fair amount of reading.

  59. oldnewthing says:

    Codejoe: So that doesn’t solve the other problems of how to get perl installed when you move machines. That’s even more work than copying a single EXE.

  60. AC says:

    I have a beautiful example — my coleague wanted to perform some kind of daily routine using .cmd files. So he needed to name the resulting files in the form YYYY-MM-DD-something.

    Such a simple task is a major pain to make in .cmd. Especially since you can’t guess the format of the output of DATE /T.

    He didn’t want solution which included the step of installing Perl.

    So I wrote the small C program which just printed predictable date, used that output in cmd and that

    was acceptable for him. The only detail — the cmd was supposed to work in different dirs (wherever he copies it) so the EXE had to be in the PATH.

    Anyway… Copying EXE to C:WINDOWS was one easy step, but the dissadvantage is that it’s not the user’s dir (he will certainly forget to copy the EXE from C:WINDOWS when he changes machine). Alternative would be to make some new dir in user’s folders, add it to the path bla bla bla. When he changes to the new machine he would have to add the path himself. Now imagine that he has a few more demands — more new EXE files.

    Now compare this with: "here’s dostuff.pl and you just have to install Perl (click click and that’s all). When you change computer, just copy your dostuff.pl and install Perl again (click click and that’s all).

    Installing Perl sounds *simpler* to me.

    Btw, how can you produce YYYY-MM-DD in cmd without the external EXE?

  61. Anon says:

    Alun said: The US Constitution restricts what the government can do. Microsoft is not bound by the Constitution.

    Umm, no.

    The Constitution allows what the government can do, rather than the other way around.

    The Constitution, being the supreme law of the country, binds every company operating in the US, including MSFT.

  62. Maurits says:

    findstr /R

    Sweet! I learned something new today.

  63. pat flaherty says:

    Do a full perl installation for a user to run his/her perl script on the machine of their choice (the one where you just installed perl)?

    People here were arguing about that the other day.  In regards to a perl script that I’d written.

    And then I remembered something.  Oh!  There are all kinds of tools that will take a perl script and turn it into a standalone EXE.  No perl installation.  No PATH either.

    Admittedly, neither of the options that came with perl worked (perlcc and pp).

    But this did:

    http://www.indigostar.com/perl2exe.htm

    And it was done in a trice.  We can move the result (EXE) anywhere we want with impunity.

    There are others – I plan to check this out as well:

    http://www.activestate.com/Products/Perl_Dev_Kit/?tn=1

    pat

  64. patrick flaherty says:

    I might add that we’re not a software firm and that all our software is for internal consumption.

    I seem to remember reading that tech-industry IT jobs represented something less than 10% of the IT labor market.

    Meaning, it would appear, that most software is not written to be sold.

    pat

  65. Nawak says:

    @Dave Harris:

    I think you’re right about the licenses: without them, the rule is the law. What I was saying when I wrote "these are not contracts" was that since the law doesn’t forbid me to use a program somebody voluntarily gave me (via their web server) and since the license/EULA is not a contract, I am not ‘forced’ to do what it tells me. "Not for commercial use"? Well at run-time I think it is too late! I did not infringe any copyright since *they* distributed the program, and no law forbids me to run what I want on my computer (or my company’s).

    SNAL (Still Not A Lawyer)

  66. Norman Diamond says:

    And the bit about quoting the license

    > agreement only supports my point: You have

    > to read the license agreement and determine

    > whether you (and your company) are okay with

    > its terms. Typically this involves a lawyer.

    Well then:  Nearly everyone who buys a computer has to involve a lawyer.  There are rare exceptions where Windows licence agreements aren’t asserted in conjunction with new computers, but typically it applies to nearly everyone.

    Why haven’t computer sales plummeted?  There are huge numbers of illegal acts?  Or just dangerous acts?

    Thursday, March 23, 2006 11:29 AM by Alun Jones

    > The Constitution (at least, in the USA,

    > which I think is where the author "8" was

    > referring to) restricts what the government

    > can do.

    It does even less than that.  Court rulings have said that the US constitution doesn’t restrict what the US government can do depending on which part of the US the victim was born in, or their race, or being born outside of the US and not being US citizens, etc.  Aside from court rulings, it is common practice in most countries that constitutions only exist for show not for obedience.

    Thursday, March 23, 2006 1:31 PM by Coderjoe

    Nawak:

    > IANAL, but I have done a fair amount of

    > reading.

    And while reading, you made illegal temporary copies of copyright material on your retinas.

  67. Nawak says:

    @Coderjoe:

    Well, doesn’t loading an exe into RAM fall under fair-use or is fair-use already dead, as Lawrence Lessig warned it would happen?

    (Lessig’s main point was that now, and it will get even more true in the future, *everything* is a copy. Computer pass their time copying things (from a website to your disk, from your disk to your ram etc.) and that protecting fair-use for these copies was therefore *essential*)

  68. Brian Reiter says:

    Actually, Microsoft does ship ksh, tcsh, perl, grep, sed, awk, gcc etc…

    It’s all a part of the "new" POSIX subsystem called Interix aka The Subsystem for Unix-based Applications nee Windows Services for UNIX. Interix is a derivative of OpenBSD and System V and was acquired from Softway Systems to replace the useless POSIX.1 implementation that originally shipped in Windows NT but was removed as of Windows XP. I think the only point of the original psxss was was to meet DoD procurement guidelines.

    Since it’s a Microsoft product and Microsoft is already an approved vendor, the legal department should lay off.

    SFU 3.5 here:

    http://www.microsoft.com/technet/interopmigration/unix/sfu/default.mspx

    Subsystem for Unix-based Applications (SUA/Interix 5.2) http://www.microsoft.com/windowsserver2003/r2/unixinterop/default.mspx

    Vista will have it, too.

    So now you can install SFU/SUA/Interix an have a whale of a problem. (But actually it’s a fantastic product.)

  69. Maurits says:

    Baz and TrueRegExpHater…

    Baz, you fell into TrueRegExpHater’s trap.  The problem with regexs is that they are more powerful than they are legible.  The way to avoid the problem is to use them with care.

    TrueRegExpHater, don’t be silly.  This is perfectly possible to do simply in regular expressions.  Suppose you’re looking for lines that contain at least one lowercase letter, but no numbers:

    Perl: perl -ne "print if /[a-z]/ and not /[0-9]/" < data.txt

    Findstr: findstr "[a-z]" data.txt | findstr /V "[0-9]"

    The trick is not to spend time developing a combination hammer/screwdriver, but just use a hammer and a screwdriver.

  70. Cooney says:

    Coderjoe:

    > I believe that currently, law works on the fact that you have to make a copy in order to run any software. When you install it, you make a copy to your hard drive.

    Nope, it’s been determined that copying incidental to the normal usage of the software is allowed. Regardless, if you bought it shrinkwrap, you own it, so Copyright doesn’t really restrict what you do with it so lons as you don’t distribute it.

  71. Jeffrey Snover says:

    This is a fun discussion.

    I largely agree with the original point.  

    One of the things that I’ve always disliked about the toolkit approach (despite its undeniable achitectual power) was that each tool was optimized for a narrow band of problems and my problems always seemed to span or shift these bands.  So I’d start writing a script in CSH (OK – you can start throwing rocks now :-) and then end up needing to do a bunch of stuff in awk and sed and then often just throwing it all away and doing it from scratch in TCL or C.  Ditto with CMD.exe, VBSCRIPT and C++.  

    The other problem was that each of these tools required their own learning curve.

    As a team, we all had similar experiences and resolved to address this issue as we designed Monad.  We knew that when we shipped, no one would know what Monad was and that it would require every single person to invest their time to learn our tool and get it installed on all their machines.  

    We took that "ask" very seriously and dedicated ourselves to making that investment a worthwhile one.  

    For one, we adopted a (sometimes manical) focus on consistency.  I was inspired by my VMS experience which I hated for the first 20 minutes until I relaxed, learned the model (regular syntax, very strong naming guidelines, very consistent semantics), and was then delighted to realize that I could make a prediction about what to do and that that predication was almost always correct. (The joke used to be that someone could attach a fishfinder to the VAX and you’d know how to manage it).  

    The other thing we did was to give the language/environment an incredibly wide dynamic range so that it didn’t fail you when you needed it, forcing you to switch tools.  That has 2 dimensions:

    1) Experience level.  We aim to have a good experience for

    COMMAND-LINE OPERATORS,  

    SIMPLE SCRIPTERS BASH-style scripting – unnamed, untyped parameters, etc )

    SOPHISTICATED SCRIPTERS (think Perl,Ruby,Python towards C#,VB.NET – named, typed variables, lambdas, access to any .NET object, etc)

    2) Type of data/instrumentation.  MONAD supports text/string processing, OLE automation/COM, WMI, ADSI, XML, ADO, as well as any .NET object.

    So yes, Monad asks you to make an investement of  your time to learn it and get it installed (it will be installed by default in a future OS release).  We appreciate the magnitude of that request and have worked feverishly to ensure that it will be an investment you’ll never regret.

    Now all that said, Monad a V1 technology and "the proof of a pudding is in the eating" so only you folks can tell whether we’ve achieved this or not but at least you know what we were trying to accomplish.  Actually, now that you know what we are trying to accomplish, I’d really appreciate any rocks you’d like to throw at us pointing out where we have not as well as we could have.  I’ll try to get them addressed for V2.

    Cheers!

    Jeffrey Snover

    Monad Architect

  72. 8 says:

    8: There’s probably a "su root" in there somewhere too. And then you have to

    >deploy it to all the systems on your network and add it to the hard drive

    >image that you use on all the machines you acquire.

    I’m sorry, but for someone listed in /usr/src/linux/CREDITS you disappoint me. If you don’t use sudo, then enter the command "su" and it’ll ask for the root password (I thought you’d know this). With sudo, just use sudo apt-get install xyz, and enter your own password if asked.

    Deploying it can be done in a variety of ways. One trick for instance is to have a company specific apt repository in /etc/apt/sources.list, and have a package installed on all machines by default, like ‘company-standard’. Then simply add a dependency to that package and increment the version, and the package gets installed with the next dist-upgrade. But there are probably better ways as well.

    Dpkg accepts a –get-selections and –set-selections argument that lets you copy the list of packages across machines, so new machines shouldn’t pose a problem when the list is on a central server.

    >And the bit about quoting the license agreement only supports my point: You

    >have to read the license agreement and determine whether you (and your

    >company) are okay with its terms. Typically this involves a lawyer.

    I’m sure this happens in bigger company’s, I didn’t mean to prove you wrong.

    >The Constitution (at least, in the USA, which I think is where the author

    >"8" was referring to) restricts what the government can do.  Microsoft, not

    >(yet?) being the government is not bound by the Constitution.

    That would severely suck if it were true. (Fortunately) I don’t live in the USA anyway, so I wasn’t referring to that law specifically. But the problem is that it’s (although IANAL) against freedom of speech (which should be in your constitution too IIRC) and anti-precensorship legislation, but since this is a software EULA, it does fall into somewhat gray area I guess. And you don’t have to agree.

  73. Norman Diamond says:

    Saturday, March 25, 2006 8:24 AM by Jeffrey Snover

    > (The joke used to be that someone could

    > attach a fishfinder to the VAX and you’d

    > know how to manage it).

    My fishfinder disagrees.  She said to remind you that managing cats is like herding senior programmers.

    Ummmmmm, some of my VAX experience disagrees too, because some of my VAX experience had Unix running on them.  Of course many accurate Unix manual pages exist just like many accurate MSDN pages exist, but the existence of manual pages doesn’t mean you’ll be able to predict what to do without finding which pages to read.

  74. Neil says:

    Interix is nice, but it doesn’t like being run as a scheduled task.

  75. JMM says:

    Sigh.  So many threads.

    Constitution: The constitution is the surpreme law of the land, and is binding in whatever it says.  (In theory.  The surpreme court says otherwise sometimes.  I’d tend to say the surpreme court is wrong in those cases, but it’s probably better all in all if we abide by their decisions anyway.)  However, the constitution doesn’t try to bind what private individuals say in contracts much.  In purticular, the first amendment says "congress shall make no law…", which doesn’t keep contracts from regulating speech.  Otherwise, everyone could freely ignore NDAs.

    Software licenses: As far as I know, this is untested in court.  If I’m wrong, please give me references, I’d love to read them.  The GPL (which is one of the two licenses available for perl, on a your-choice basis) is a nice example of a license that is hard to find anything wrong with, since it makes no restrictions whatsoever on normal use, since it doesn’t try to exploit technicalities to do things a license can’t do.  Perl modules, of course, are free to have any license they want, but most are under the same terms as perl itself.  A quick read of the documentation that comes with the module will tell you what the license is, and 99% of the time, it’s totally straightforward.  Liability for bugs is a complete red-herring, as everybody will disclaim to the same amount if they have half a brain — the maximum amount allowed by law.  If you don’t like that, I’m sure you can buy insurance.

    Original post: The first problem with your argument is that if you keep looking at only this problem, installing and learning a real language like perl might not be worth it.  You can work around the evil of batch files, or change the file associations to make using js or vbs usable, and deal with those languages.  But next week you’re going to have this issue again.  You can pick up a copy of activestate perl fairly quickly on a reasonable connection, and keep hitting next, and perl is quite a good language, for a reasonable programmer.  If you disagree, there are any number of other languages which also have "just hit next" installers for win32.

  76. You need to interoperate with batch files

  77. Your IT department is in charge.

  78. REblog says:

    I’m reviewing the source code for a rather large project this week and I wanted to update my Facebook…

Comments are closed.