Monday, January 28, 2008

Use JScript over VBScript

When trying to complete a Windows-based script for any type of system administration - at work, volunteering at my church & school, or otherwise - I've always been a bit intrigued at why anyone would choose VBScript over JScript.

While some of Microsoft's own examples are written in both VBScript and JScript, many are written exclusively in VBScript. I've not found any documentation that shows that VBScript is supported any better by - or has better support for - the Windows Script Host than JScript.

I finally happened to run across a great article that summarizes why JScript should be preferred, and lists many of the same reasons why I always convert any WSH scripts I'm involved in to JScript. The article is Eight Reasons Windows Administrators Should Learn JScript Instead of VBScript by Bill Stewart, on O'Reilly WindowsDevCenter.com.

Stewart's key points, followed by some of my highlights:

  1. JScript Is More Widely Used
    • JScript is really the same as JavaScript 1.5, while VBScript is proprietary to Microsoft.
  2. JScript Is Alive and Well
  3. JScript Is Easy to Learn
  4. JScript Is Object-Oriented
    • JScript shares many of JavaScript's powerful advantages and syntax. For example, many of the tips in my previous post on JavaScript Closures apply equally to JScript, but are impossible to match in VBScript.
  5. JScript's Regular Expression Handling Is Better
  6. JScript Arrays Are Much More Powerful
  7. JScript Date Handling Avoids Local Time Problems
  8. JScript Has Better Exception Handling
    • By comparison, exception handling is practically non-existent in VBScript.

In my opinion, many of these same points should also lead anyone to choose C# over Visual Basic .NET (VB.NET) when working with the Microsoft .NET framework.

No comments: