Javascript: the new VBA

Somewhere at the end of the eighties, my dad started work at his [local university](http://www.rug.nl) where he became the [WordPerfect](http://en.wikipedia.org/wiki/WordPerfect) expert, which was the dominant word processor at the time. Beside acting as a helpdesk and laying out documents, he also spent a lot of time writing [WordPerfect macros](http://www.shkatz.com/macrotut/tofc.htm). WP's macro language allowed you to add functionality and automate common tasks. All was well, until Microsoft came along with Microsoft Office. It took Microsoft a long time to dominate the word processing market, but they managed to push WordPerfect practically out of the market with Word '97. My dad's university also switched to Word around that release. Word uses a dialect of BASIC for writing macros: [Visual Basic for Applications (VBA)](http://en.wikipedia.org/wiki/Visual_Basic_for_Applications). He still does the majority of his programming work in VBA. To give you a flavor: ~~~~~~~~~~~~~~~ Public Function BusinessDayPrior(dt As Date) As Date Select Case Weekday(dt, vbMonday) Case 1 BusinessDayPrior = dt - 3 Case 7 BusinessDayPrior = dt - 2 Case Else BusinessDayPrior = dt - 1 End Select End Function ~~~~~~~~~~~~~~~

It is likely that within 10 years practically all word processing will be done in some sort of web application. Albeit in Google Docs or something else, and with this platform shift will also come another shift in macro language. Although it may not be surprising, it looks like that macro language is going to be Javascript.

Google has started introducing [macro capabilities](http://www.google.com/google-d-s/scripts/articles.html) to its [Google Docs](http://docs.google.com) offerings, calling it [Google Apps Script](http://www.google.com/google-d-s/scripts/articles.html), but if you look closely you will see it's simply Javascript using a Google Docs API. The first application where Google Apps Script is introduced is in its spreadsheets, this is what it looks like: ~~~~~~~~~~~~~~~ function example() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; var myValue = Browser.inputBox("Enter a number"); sheet.getRange("A1").setValue("Number entered:"); var b1Range = sheet.getRange("B1"); b1Range.setValue(myValue); var valueToShow = b1Range.getValue() + 1; Browser.msgBox("Answer: " + valueToShow); } ~~~~~~~~~~~~~~~ Google's Apps Script -- I'm guessing they don't like to abbreviate it to GAS -- currently enables power users to define:

* Custom spreadsheet functions * Custom menus in the spreadsheet application * Send e-mails * Read and manipulate spreadheets * Communicate with web services

Google took another step to become a serious Microsoft Office competitor. And my expectation is that more web applications will allow users to build macros in this fashion soon.

Another programming domain conquered by Javascript.