v8 is uncovering some of my dirtiest coding

46 views
Skip to first unread message

Bruce Mcpherson

unread,
Mar 27, 2020, 12:46:10 PM3/27/20
to Google Apps Script Community
Don't know about anybody else, but I'm finding that v8 is uncovering all my past coding sins - especially since I have a lot of libraries out there. 

If something becomes an error under v8 even in a piece of code that isnt executed, then the library will become unusable. 

Chief culprit for me is something like this, where I've forgotten to declare a private variables. All this is moot now, because this isn't how you do it nowadays, but some of our code is pretty old.

function someClass () {
 
var self = this;
 
/// forgot to declare private variable -- option_  !!
 
/// var option_;
 
self.setOption (value) {
   
// this is wrong
    option_
= value
 
}

}

Of course, pre-v8 the option_ value would have become (wrongly) part of the global space, and we would have been none the wiser as the editor ignored 'use strict' anyway. (see https://ramblings.mcpher.com/apps-script/apps-script-v8/javascript-v8-variable-scopes/ for discussion on this topic)

If you are using any of my libraries and they are failing when you switch to v8 - see if theres'app a new version. If still a problem, let me know so I can start to track them down. 


CBM Services

unread,
Mar 27, 2020, 1:23:30 PM3/27/20
to google-apps-sc...@googlegroups.com
This is what scares me moving to V8. Google indicated they will be putting in place migration tools to help.

Do we know when those are coming?

From: Bruce Mcpherson
Sent: ‎2020-‎03-‎27 9:46 AM
To: Google Apps Script Community
Subject: [Apps-Script] v8 is uncovering some of my dirtiest coding

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/dfac8dbb-be3b-47e0-8934-347f827c94fd%40googlegroups.com.

Bruce Mcpherson

unread,
Mar 27, 2020, 1:37:35 PM3/27/20
to google-apps-sc...@googlegroups.com
No, but you can do some pre- work by linting your code 

if you are not using clasp, there are a few online ones around


CBMServices Web

unread,
Mar 27, 2020, 1:43:42 PM3/27/20
to google-apps-sc...@googlegroups.com
Thanks, but I don't want to have to change all the code twice. It would become a pretty large effort with the volume of code and libraries. 

Will wait for the migration tools instead so this can be done once and be over.


Andrew Apell

unread,
Mar 27, 2020, 3:57:53 PM3/27/20
to Google Apps Script Community
I scoured through all the "best practices" I could find while writing my code, so V8 found me ready for the migration.
I cannot imagine having to rewrite my code at this point...

Adam Morris

unread,
Mar 28, 2020, 9:42:14 AM3/28/20
to Google Apps Script Community
With massive changes like this we have to expect some pain points. The transition from Python 2 to Python 3 was also full of nightmares.

I think in general the ecosphere could do with a bit of moderizing the approach a bit. There's a significant advantage in being able to rewrite our code so that it's more readable and just better.

But, and this is the kicker for me …

Once you've solved the problem it isn't easy enough to reuse the code. I really wish there was a package manager or something that would allow us to include into our projects, by name, that add to the project from github.

That way all these rewrites would be more meaningful.
Reply all
Reply to author
Forward
0 new messages