We're All Going to Become Programmers: Choose Your Weapon!

I know—you're expecting me to write about the Microsoft judgement. But first, I have nothing to say that someone hasn't already said, and second, my opinion makes everyone mad. On the one hand, I agree that Microsoft violated the antitrust laws, and—like 'em or not—they are the law. But on the other hand, the forced-breakup-as-penalty seems a bit extreme, as if I'd been arrested for stealing a book from a bookstore, convicted, and then sentenced to the electric chair. But that's not what I want to talk about this month. Instead, I think I have a more important topic. These are important times for us administrator types. In addition to our other duties, we're getting a new one: programming.

But wait, wait, don't go—it's good news, trust me. One flaw of Windows NT 3.1, 3.5, 3.51, and (until recently) 4.0 has been lack of programmability. Many administrator tasks are both multistep and repetitive: create the user, don't forget to create the home directory, customize the logon batch script . . . But the automating tool has been administrator carbon units rather than programming-language-driven silicon units. Sure, we always had some ability to automate—the old limited DOS-derived batch language (the "son-of-a-batch" programming language, you might call it) and some very nice (and expensive) third-party tools. For most of us, however, automating regular tasks has been out of reach.

Nowadays, Microsoft OSs include a wealth of both scripting languages and scripting tools. The foundation is Windows Script Host (WSH), which lets you use either VBScript or JavaScript (with other options available if you look further) to write scripts that have the programming power of "big-name" programming languages. But all the programming power in the world is useless if you don't have anything to manipulate—that is, if you have to be a C-language whiz to actually get to the OS's dials and levers. We're well-served there also with a host of easy-to-use technologies such as Windows Management Instrumentation (WMI), Active Directory Scripting Interface (ADSI), and a wealth of ActiveX controls.

But before you embark on your new programming career, get ready for your first decision—VBScript or JavaScript? Your answer, as it turns out, will depend on what you're familiar with now and what you use your scripting language for. But you'll need to know one of the scripting languages. BASIC, which is at the root of VBScript, has been a Microsoft favorite for decades; I remember using the built-in Microsoft BASIC in my Ohio Scientific Challenger 1P and the TRS80 Model I to write games that helped me work my way through graduate school in the late 70s. BASIC has grown into the most all-encompassing scripting and macro language in the Microsoft world because it's built into Microsoft Office, IIS (in the form of Active Server Pages—ASP), and even Internet Explorer (IE).

People don't realize that in addition to its main function as a Web browser, IE is a VBScript programming environment in its own right, completely free of charge. For example, I recently had to compute the length of each day in the year. (Contrary to popular belief, days are not 24 hours long but can vary about 30 seconds either way each day.) I implemented an HTML file with embedded VBScript to demonstrate the kinds of things that VBScript in IE can do. Point your browser to see the script—but be sure to use IE: Netscapers can't run VBScript! That brings me to perhaps the strongest reason not to choose VBScript as your scripting language: browser compatibility. JavaScript, your other choice, can basically do everything that VBScript can—and both IE and Netscape support it.

But browser compatibility may not matter if your goal is to write administrative scripts. If you learn how VBScript handles such items as Outlook Calendar objects in a browser, you're 99 percent of the way to writing Outlook Macros in Visual Basic for Applications (VBA), or standalone Visual Basic (VB) applications, or server-side ASP applications in—you guessed it—VBScript.

But JavaScript is no slouch at multiple uses either. I'm told that you can build ASP programs with JScript (Microsoft's flavor of JavaScript). In addition, IE uses JScript, and WSH supports it right out of the box. But to my knowledge, Office does not support a "JavaScript for Applications," so there's the rub: Use JScript rather than VBScript for client-side Web compatibility, but VBScript rather than JScript for controlling Word, Outlook, and other Office components. Either can do ASP, IE scripting, and WSH.

Are there significant programming pros or cons to either language? Not so far as I can see. However, let me underscore that 99 percent of my ASP, IE scripting, and WSH work has been in VBScript, so I might not see a major flaw of VBScript that JavaScript lacks. Part of your decision should be based on your current comfort level; if you like C and C-like programs, you'll probably find JavaScript easier to learn. On the other hand, if you already use one of the VB variants, VBScript will be easy to learn (although the way VBScript handles a few basic things such as reading and writing files will give you pause).

JavaScript beats VBScript in handling cookies, which is really relevant only to browser scripting—but a significant point in that area. JavaScript's built-in functions make many programming projects easier because JavaScript includes bit operation functions and a built-in sort function, both of which VBScript lacks. On the other hand, VBScript makes date arithmetic and many kinds of string manipulation far easier and is a trifle easier to integrate with COM objects and ActiveX.

None of the reasons I've covered is sufficient to eliminate either language from the running. In the end, it boils down to personal taste—which is why you'll find some pretty heated religious wars about the choices! Some great online tutorials for VBScript and JavaScript are free on the Web, so check those out before charting your course. Find a simple but nontrivial task and script it in both languages, then decide. But no matter which scripting language you pick, start learning one today.

After all, you don't want to be the last administrator around still doing things by hand, do you?

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.