Data processing just got easier with Apps Script’s new V8 runtime
Google Developer Advocate
Try Google Workspace at No Cost
Get a business email, all the storage you need, video conferencing, and more.SIGN UP
What is Google Apps Script?
As a quick summary, for small to medium-sized team projects, Google offers a free scripting environment that connects Google and non-Google applications to automate calculations or workflows (by visiting script.new in a browser, or Tools > Script editor within a Google Sheet, Doc, Slide, Form, etc., or recording your steps as a macro). Each script (called an Apps Script) can run on a schedule, or be triggered by a user’s actions. These actions can include opening a sheet or interacting with custom UI components such as custom formulas, pop-ups, menu dropdowns, or even complex HTML-based interfaces with buttons and text inputs (web apps).
Type “script.new” in your browser to start a new Apps Script project.
Four improved use cases
In computer history, one can compare the revolutionary practicality of the industrial period’s assembly line with that of assembly language. The sequential list of instructions (for-loops, while-loops, if-statements), called imperative programming, served as a recipe-like format, but it doesn’t have room for abstracting code for humans (in other words, very literal instructions). It also can run into trouble when executing multiple instructions using the same memory; if there are “too many cooks in the kitchen,” unintended interpretations produce alternate outcomes (or side effects).
By leveraging modern JS, one can lean on functional programming, which bases its logic in evaluating statements as mathematical functions. This way, each function has its own purpose, which reduces hidden dependencies; allows parallelization without tasks “stepping on each other’s toes;” and locks memory to ensure there are no overwrites.
Modern JS’s explicit expressions reduce complexity, making it easier to write and maintain (read) scripts. Two of many favorites are:
Arrow functions: a function is passed as an argument to another function as data, in one line, using an arrow icon =>
Spread operator: inserts the values of an array using 3 dots
I recommend two great resources by Google Developer Experts (GDEs):
A summary of JS features with examples by Ben Collins.
A list of free JS learning sites by Amit Agarwal.
Data processing operations
Whether it’s physics simulations, invoice trends, ETL (extract, transform, load), or linear regression-based processes, using “map,” “filter,”, and “reduce”with arrow functions is powerful and clear. The runtime also provides a faster CPU computation for such mathematically intensive activities, and a better logs experience.
The best of JS features, combined with Apps Script
If you’re using scripts that employ the older runtime, review these incompatibility tips—unless you wish to opt out from migrating to the new version. It’s exciting to see what the community can build with the new capabilities modern JS unlocks, especially those who work with Google Sheets and data processing use cases.