# Discussion regarding FriendlyGlobalFunctionBinder in FES

**URL:** <https://discourse.processing.org/t/discussion-regarding-friendlyglobalfunctionbinder-in-fes/29140>\
**Category:** Development\
**Created:** [April 5, 2021, 8:04pm UTC](https://discourse.processing.org/t/discussion-regarding-friendlyglobalfunctionbinder-in-fes/29140 "2021-04-05T20:04:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bhushan](https://avatars.discourse-cdn.com/v4/letter/b/a87d85/32.png) [@bhushan](https://discourse.processing.org/u/bhushan)\
**Post date:** [April 5, 2021, 8:04pm UTC](https://discourse.processing.org/t/discussion-regarding-friendlyglobalfunctionbinder-in-fes/29140/1 "2021-04-05T20:04:05Z")

</div>

While implementing ‘friendly error when user overwrites p5.js functions’ discussed in [this](https://github.com/processing/p5.js/issues/1317) issue,  
the approach taken was that (solved by [this](https://github.com/processing/p5.js/pull/1318) PR) at the start of the run, every function in p5.js is assigned a “binding” by using javascript accessors (i.e, by using getters, setters, by [Object.defineProperty](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty)) and every time user tries to override the function, the setter function is called and a friendly error is thrown.

[code for this lies here](https://github.com/processing/p5.js/blob/796754482ba3c25746d7ad7536e5a6b10e4995e4/src/core/main.js#L622)  
Everything works fine and FES is functioning well.

But, there seems to be a big performance tradeoff by taking this approach.  
There seems to be a benchmark test to test the performance of FES [here](https://github.com/processing/p5.js-website/blob/main/src/assets/learn/performance/code/friendly-error-system/sketch.js)  
The times when run were as follows,

##### FES disabled : 115ms

##### FES enabled, with this approach : around 280ms

##### FES enabled, but without using getters and setters : around 120ms

##### 

this may not seem like a huge deal, but see the difference between enabling and disabling the FES, it’s only 5ms. all the other workload is only from one simple functionality.

We can overcome this problem by 2 ways:

1. We can simply set all the p5.js functions to be unwritable, so no setters required. But, by taking this approach we cannot let the user to use the p5 function’s name as variables, which may not be favoured.
2. We should use another approach to reach the same functionality but without using any getters or setters. They are just like attaching a huge number of event listeners imo.

I am trying to solve this problem for the last couple of days but found nothing useful. Hope the community helps.

ps: also while researching about this topic, I stumbled upon many articles regarding why we should not use getters, setters at all in JavaScript, but didn’t find a valuable replacement for them.
