Our research focus on the performance aspects of this problem. We propose a novel solution based on meta-programming and code rewriting, show some preliminary results based on a small set of experiments, and then review other approaches and compare them with our proposal.
For example, using the for-in statement to iterate an array object is at least 25 times slower than using a standard C-style-for to iterate the same array. Even more remarkable, different APIs generating the same, or semantically similar, results can show a big difference in execution times. For example, using the API document.getElementByTagName to find elements in the DOM can be 200 times faster than using the API document.querySelectorAll.
PumaScript’s main feature is the support for meta-functions, a mechanism similar to the programmable macro-expansion systems available in Lisp, Ruby, and other programming languages. Like other macro systems, PumaScript meta-functions can expand caller expressions inline. When called, a meta-function takes the decorated Abstract Syntax Tree (AST) of the arguments and returns an AST to be used as a replacement for the caller expression.
PumaScript meta-functions can execute any arbitrary computation, including calling other normal functions or meta-functions. Additionally, all meta-functions have access to special intrinsic functions which provide access to the program AST for introspection and re-writing of any portion of it.