Source: Apps Script V8 Runtime Explained For Non-Professional Developers
Apps Script doesn’t have a module loader system. If you’re used to developing in NodeJs, you’ll also be familiar with importing and exporting to include required modules in your project. With Apps Script, you have no control over the order in which multiple script files are executed. In Legacy Apps Script, there seemed to be some kind of workaround going on so that global statements were executed in a sensible order (I don’t know the details), but in V8 this is not the case. …
My golden rules are
- Nothing executable should be in global space
- Don’t rely on the order that things are processed
- Minimize the number of executable functions (1 is good)
- Always assume your code will be reused somewhere else.
Source: Apps Script V8: Multiple script files and namespaces – Desktop liberation
Source: Apps Script V8: spreading and destructuring – Desktop liberation
More tips and guidance from Bruce Mcpherson for developers migrating code to the Apps Script V8 runtime.
Sets and Maps can often be a cleaner way of storing data than using Objects or Arrays, even though at first glance they may seem a little redundant. Unlike an array, they are aware of what else is in the map or set (so you can avoid duplicates), and unlike an object, you can use anything as the key – including the item value itself
Given many Apps Script projects focus on manipulating data Bruce Mcpherson provides a useful introduction to Maps and Sets.
Source: Apps Script V8: Maps and Sets – Desktop liberation
It’s a shorthand way of using a template into which variables are subsituted in a string. This allows for better reuse of string structures, and a few other goodies besides (like all V8 additions, it’s more than just a syntactical spruce up)
Bruce Mcpherson has a very useful post highlighting the benefits of using the new V8 runtime when working with string output
Source: Apps Script V8: Template literals – Desktop liberation
This post from Alexandrina Garcia-Verdin, better known in the community as AGV, highlights some of the benefits of the new Google Apps Script V8 runtime including succinct syntax and data processing operations:
Image source: Google
Source: Apps Script’s new V8 runtime | Google Cloud Blog
The article is an overview of the workflow covered in the author’s presentation along with install instructions for trying it out in your G Suite domain.
Source: G Suite Solutions — Apps Script Powered Workflow Automation
A bit of a monologue about various syntax changes and adjustments in learning and using the tool.
Source: Things one can get used to for the V8 Google Apps Scripts engine
One of the key things that V8 has sorted out is the scope of variables. Using var to declare variables meant that anything declared within the scope of a function could easily be accidentally overwritten, causing hard to track down errors. ES6 (since it’s commonly known as V8 in Apps Script – I’ll be referring to it as V8 from now on), has added const and let to the variable declaration vocabulary to help prevent these kind of problems.
Why not make it a proper library? Because to make it a drop-in replacement, needs to have access to global scope, which a library doesn’t.
The V8 runtime changes how the
Logger class works, which has shown much slower load times for simple Logging statements. This snippet writes all
Logger.log calls to a spreadsheet when invoked, greatly speeding up development time.
I’m a public school teacher writing Apps Script projects to manage documentation and to make life easier in general. You can read more on my blog, blog.ohheybrian.com or follow me on Twitter, @bennettscience.
Benchmark: Loop for Array Processing using Google Apps Script with V8 – submit.md
Kanshi Tanaike has published some useful benchmarks looking at the process time for various loop methods comparing the old Google Apps Script runtime with V8. Something to keep in mind that while there are performance improvements there is a cost as calls to G Suite services:
Source: Benchmark: Loop for Array Processing using Google Apps Script with V8
This page describes the new features enabled by V8 and how you can enable V8 for use in your scripts. Migrating scripts to V8 describes steps for migrating existing scripts to use the V8 runtime.
Source: V8 Runtime Overview | Apps Script | Google Developers