Comments on Profile Post by Poryg

  1. Poryg
    Poryg
    The biggest issue I see people say with eval is that eval can be used to run malicious code. But well, that is easily possible in MV even without eval thanks to the accessible code. However, Nw.js allows compilation of JS code into the native NW.js code and safe running, yay!
    Mar 17, 2018
    caethyril likes this.
  2. starlight dream
    starlight dream
    You're not allowed to post statuses in a foreign language.
    Mar 17, 2018
    Llareian, Shaz and Rhino like this.
  3. Jonforum
  4. Poryg
    Poryg
    @Jonforum I ran the test and noticed that function constructor is only 2% faster than eval. Since function constructor, as a self-invoking function, creates a brand new scope, I think I'll be standing by eval. But thank you :)
    Just a heads up, I'm using eval for dynamically generated commands, so I can't use function declaration there.
    Mar 17, 2018
  5. Jonforum
    Jonforum
    nope pure js can execute 756,302,912 per/s and eval 3,317,482 per/s, i don't know you get different result !?
    Mar 17, 2018
  6. Poryg
    Poryg
    function declaration: 9,777,846
    function constructor: 6,888
    eval: 6,748

    As you can see, the difference between function constructor and eval is very small in my case. Function declaration has a huge number, but that doesn't allow dynamically generated functions, so it's useless to compare.
    Mar 17, 2018
  7. Jonforum
  8. Jonforum
    Jonforum
    pur code can execute x1500 time fast than eval code, you find this small ?
    Mar 17, 2018
  9. Poryg
    Poryg
    Chromium 62.0.3202
    Function constructor 1,043,924
    Function declaration 213,159,001
    eval 3,211,979
    In the second link you sent me eval handles 3x more than function constructor.
    Mar 17, 2018
  10. Poryg
    Poryg
    Pure code is pure code, but pure code doesn't allow for dynamic code. Again, I am using eval for dynamic code, so pure code is irrelevant here.
    Mar 17, 2018
  11. Kvothe
    Kvothe
    For dynamic change on code I think that is ok. I mean, on my Behavior NPC system, there is a part where call eval, but I just call to execute a function that exist on class. But the best of best is avoid it
    Mar 17, 2018