Microsoft's JavaScript focus is a winner

Never mind the complaints: JavaScript scripting is the best way forward for Microsoft Office and the Windows platform

Developers must be masochists. How else to explain all the negative reactions to Microsoft's newfound enthusiasm for HTML5 and JavaScript? First Microsoft said it would integrate the Web standards into the next version of Windows, now it says it will do the same with Office -- and in both cases, developers have done nothing but complain. Why?

Here's how it stands with Office right now: Users can script the Office components using Visual Basic for Applications (VBA), a proprietary Microsoft scripting language that's a subset of Visual Basic 6. VB6 itself was a lousy language with an ugly, cumbersome syntax; Microsoft ended all support for it in 2008, and I have yet to hear a single developer mourn its passing. Unfortunately, however, VBA lingers on.

[ Get software development news and insights from InfoWorld's Developer World newsletter. | And sharpen your Java skills with the JavaWorld Enterprise Java newsletter. ]

Let's not kid ourselves that VBA is "just a scripting language," either. Rightly or wrongly, entire business applications have been written as Excel macros, and maintaining those applications means maintaining competency in VBA.

Just don't expect a lot of company. At one time, Microsoft hoped VBA would become a lingua franca for Windows application scripting. To that end, it licensed the VBA runtime to third-party developers to include in their own applications. But Microsoft shuttered that program in 2007, meaning you won't find any new applications that support VBA today or in the future.

And that's not all. Office may be cross-platform, but Microsoft dropped support for VBA from Office 2008 for Mac. It's back in Office 2011, but macros still don't always port cleanly. Whether a given piece of VBA code will run largely depends on your OS platform and which version of Office you have installed.

Scripting for all seasons

The state of VBA today is a shambles, and the language clearly has no future. It's about time Microsoft offered us a credible alternative, even if it has to commit to supporting VBA for legacy code. So why not JavaScript? In fact, I can think of a bunch of reasons why it makes perfect sense:

  1. JavaScript has a huge installed base. It's practically as ubiquitous as Basic was in the 1980s. Children use it for school projects. Whatever you think of the language itself -- and I'm not a particular fan -- its limitations will hardly be major drawbacks when the goal is merely to script a word processor or a spreadsheet. It's certainly a better syntax than VBA. And given the vast amount of JavaScript code that has already been written and is readily available on the Web, solutions to common problems will be easy to find.
  2. Microsoft wouldn't be the first one to do it. Adobe has allowed users to script its professional graphics applications in JavaScript -- including Photoshop, Illustrator, and InDesign -- since the first version of Adobe Creative Suite a decade ago. If it works for Adobe's large, feature-rich applications, Microsoft should have no problem adapting it for Office.
  3. Maintaining a JavaScript runtime is cheap. Microsoft is already committed to developing a high-performance JavaScript execution engine for Internet Explorer. Repurposing the same code for Windows and application scripting means Microsoft won't have to commit additional resources to maintaining an orphaned language like VBA. In addition, with a shared JavaScript library, every layer of the Microsoft stack will gain the benefits of the latest JavaScript performance increases at the same time.
  4. JavaScript is portable. The Internet Explorer JavaScript engine only runs on Windows, but there are plenty of alternatives available on other platforms, such as the JavaScriptCore engine that ships as part of WebKit on Mac OS X. That makes it much more likely that application scripting on the Mac version of Office will maintain parity with the Windows version. As a side effect, it may also mean that alternative productivity suites, such as, may have an easier time reading Office document formats, macros and all. As of today, alternative suites offer only partial support for VBA macros.
  5. JavaScript runs on the Web. According to its job postings, among Microsoft's goals for Office 15 is to allow developers to "create rich applications that span clients and server" and integrate with Office 365, Microsoft's Web-based subscription productivity offering. If Office's standard scripting language is JavaScript, developers will be able to use the same language to automate the desktop Office apps and their Web-based counterparts. JavaScript is also a far better choice than VBA to allow developers to access Web services exposed by Office 365 for use in their documents.
  6. JavaScript runs on mobile devices. One of the big talking points of Office 2010 was that it offered "the best productivity experience across the PC, phone, and browser." That's been wishful thinking so far, but by orienting more Office functionality toward open Web standards, Microsoft has a shot at delivering a meaningful productivity experience on mobile devices for the first time.

Real scripting for Windows at last?

What I'd really like to see is for Microsoft to integrate Office's JavaScript scripting capabilities with the much-discussed JavaScript engine for Windows 8. Mac OS has long had AppleScript, which allows scripting across the Finder and multiple applications. AppleScript is an imperfect solution, but to do anything similar on Windows requires third-party automation tools. If Microsoft made JavaScript a foundational scripting language for the entire Windows platform, it would be a valuable tool for users and developers alike (and developers wouldn't have to feel guilty about forcing their customers to script their applications using a language as odious as VBA).

Can Microsoft hit all these marks? Can it really deliver a revolutionary JavaScript-based scripting solution that unifies the OS, desktop apps, the Web, and mobile, all in time for the next versions of Windows and Office? Let's face it: The answer is almost certainly not. But what Microsoft has announced sounds like a definite, clear start toward a better future.

The alternative is what Microsoft has now, which is VBA. So come on, those of you who are complaining -- you can't seriously prefer that?

This article, "Microsoft's JavaScript focus is a winner," originally appeared at Read more of Neil McAllister's Fatal Exception blog and follow the latest news in programming at For the latest business technology news, follow on Twitter.

Copyright © 2011 IDG Communications, Inc.

InfoWorld Technology of the Year Awards 2023. Now open for entries!