Web browsers have evolved into indispensable software platforms for modern applications. Although JavaScript has become a de-facto lingua franca for developing web applications, the JavaScript software development tools and methodologies lag behind those of languages such as Java and C#. In particular, to enhance JavaScript programs with non-functional concerns (e.g., persistence, security, transactions, and logging) JavaScript developers need to modify the source code by hand. Developers then often end up having to maintain the resulting modified version separately for reasons that include poor design, the complexities of program evolution, and fundamental language limitations. The necessity to modify code by hand could be avoided if JavaScript had metadata facilities for developers to specify non-functional concerns declaratively. To address this problem, we present a novel declarative approach, T ransparent A utomated E nhancement for J ava S cript (TAE-JS) that enhances JavaScript programs with the ability to use declarative metadata. The metadata is expressed by means of Java annotations. We have implemented our technique in an open-source plug-in for the Eclipse IDE. This plug-in allows a developer to enhance the original version of a JavaScript program by specifying concerns declaratively using Java annotations. It then analyzes an original version of the program to automatically generate enhanced program versions by adding the declared concerns. We evaluated TAE-JS with four practical examples that enhance JavaScript programs by declaratively adding concerns such as persistence, security, transactions, and logging. In a user study with ten student developers and three professional engineers at PayPal, the participants viewed favorably TAE-JS's flexible declarative enhancement capabilities, seeing them as a valuable mechanism for implementing non-functional concerns in JavaScript programs. Our evaluation results are promising in demonstrating the potential benefits of our approach to complement existing JavaScript development tools.
Read full abstract