Javascript on Parrot

rohit jangid

Short description: The Project focus on implementing a bootstrapped JavaScript Compiler on Parrot using the already existing tools like Cafe and nodejs. the Aim is to transform the code generator of Cafe and compile it using nodejs to generate parrot friendly PIR/PBC code.

 NAME: Rohit Jangid 

 

EMAIL ID: rohit.nsit08@gmail.com 

 

 GOOGLE ID: rohit.nsit08 

 

 OTHER CONTACT INFO: 

 

 Irc nick-name on #parrot channel: rohit_nsit08 

 

 skype id : rohit_nsit08 

 

 PROJECT TITLE: 

 

 JavaScript on Parrot 

 

 ABSTRACT: 

 

The project is based on implementing a JavaScript compiler using JavaScript. The existing compiler projects like cafe/jasper would be used for front-end. Reusing already built code will be of utmost priority, which requires use of parser generators like Jison or PEG.js etc. The primary attempt is to customize the backend (code generator) of cafe to make it generate parrot friendly PIR/PBC code. Cafe project is most likely to provide much needed compiler infrastructure. 

 

 BENEFITS TO THE PARROT VM AND OPEN SOURCE COMMUNITY: 

 

 JavaScript is one of the most popular and preferred scripting language among users and hackers on the internet. All such people will be benefited with its inclusion in parrot list of interpreters. Successful implementation of JavaScript compiler would encourage JavaScript developer community in improvising the same. It is important since all the present browsers are JavaScript enabled but there are very few command line tools available for it. There are compilers already available in JavaScript like 'Rhino' from Mozilla, which is written in java and is one of the frequently used tool in this regard. However, Rhino has performance issues and limitations with size of byte code generated by it (which I faced myself). Currently ‘narwhal’ is using 'rhino'. 'node.js', another compiler, which uses much better Google’s v8 engine is built in C++. But there are no such compilers in JavaScript. Though there exists a JavaScript compiler on parrot "ECMASCRIPT", but is not very usable in its current form due to lack of people workingon it and its dependencies on old NQP and PGE. In short, there is a need for a better, fast, optimized command-line JavaScript compiler with better features. So we can offer this service on parrot, which will contribute to the Open-Source Community also. Since good tools are already available in JavaScript like parser generators and interpreters, bootstrapped compiler becomes a very good option to start with. So, here is my proposal on how i will proceed and develop a bootstrapped JavaScript compiler written entirely in JavaScript. DELIVERABLES: A bootstrapped JavaScript compiler on Parrot. Test-suite with examples using rosella and ‘jspec’ testing framework An efficient build infrastructure compatible with major plateform Project documentation that will help future developers to carry on work further. 

 

 PROJECT DETAILS: 

 

 1. The project is based on bootstrapping concept to make a JavaScript -in- JavaScript on parrot compiler using already an already existing compiler. 

 

 2. The primary attempt will be to transform the code generator of already available JavaScript parser “cafe” (which is using jison to generate parser) to generate PIR/PBC code. 

 

 3. I will use already available compiler/interpreter node.js which is using Google’s v8 engine or ‘narwhal’ which is using ‘rhino’ engine as bootstrap compiler (stage 0 compiler) to generate parrot friendly PIR/PBC code. 

 

4. Javascript uses prototype based object model which is different from Parrot's usuall class based Object Model. For correct Implementation JavaScript Objects will be derived from the Parrot's Hash Types (which uses PMCs).

If problems occur, creating a Custom Object Model will be the last option.  

 

 5. I will compile generated PIR code in parrot to get a independent stand-alone executable compiler, this will become our STAGE 1 compiler which will be able to compile its own source code. 

 

 6. Further modifications will be made to Stage 1 compiler by adding support for modules written in other languages. Any modification to stage 1 will result in a feature rich stage 2 compiler. 

 

 7. At this stage, we’ll be having a running JavaScript compiler on parrot platform.

 

8. Necessary optimizations and tests would be conducted to ensure stable working of stage 1 compiler. 

 

9. If all goes well, I will attempt to transform original AST into parrots PAST OBJECT so that I can use optimizations and other facilities available on Parrot.. 

 

10. Modification in the generated source code would be done followed by compiling it in itself in cycles for further improvements to get desired performance.

 

11.Test-suite will be implemented in two parts:

Part1: Before we have stage 1 ready, testing will be implemented using rosella test.pbc

Part2: After stage 1, we’ll be having a running JavaScript compiler so now we can attempt to use ‘jspec’ testing framework for this stage, in combination with rosella. 

 

12. For documentation purpose, jsdoc has been chosen as it is open source with lots of organizations already using it for their JavaScript documentation. 

 

 My current status: 

 

I’m currently experimenting on node.js, cafe, and jison combination. I have done good study of cafe and working to get PIR code generating back-end. I am in touch with author of cafe, jison and node.js to get more knowledge of their tools. I am also studying code base of winxed which is a JavaScript like language already implemented on parrot. 

 

 

 PROJECT SCHEDULE: 

 

 March 28 – April 25: Work on project details, search for loop holes to ensure proper understanding of project and getting familiar with parrot organization. Study ECMAScript, JavaScript language specification. Study test-suits and testing framework, getting familiar to use Github. 

 

 Target: To get acquaint with the in-depth details of the project, and testing framework. 

 

 

 April 26 – May 15: Complete all the work on cafe, jison and nodejs resolve all issues if any. Study the code generator’s code in café.

Target: Set up a working environment prepared to go for stage 1 compiler. 

 

 MILESTONE 0: All groundwork would be finished by this stage so as to start the actual coding. Discuss detailed plan of project, backup policy with the mentor. Finalize stage 0 compiler design. 

 

 University Exams: (tentative dates) May 16 – May 31 (absent during this time) Summer Vacations from August 1 

 

 

 ACTUAL CODING STARTS: 

 

 Every week will begin and end with a meeting with mentor discusssing the current status and plan for next week. 

 

 

Week 1) June 1-June6: Work on cafe backend, transform code generator to emit code in PIR/PBC. 

 

 

 Week 2) June 7-June 13: Carry on with backend code, work on implementing the Object Model, improving the code structure and add tests. 

 

 Week 3) June 14-June 22: Remove errors if any from the week 2 project. Build an executable and get the stage 1 compiler ready. 

 

MILESTONE 1: Compiler is able to generate PIR code.

 

 Week 4) June 23-June 29: Run the generated PIR code on Parrot. Remove all the errors from the compiler, add test- suite, and test for crash and failures. Debug and test work done. Start documentation up to this stage. 

 

  MILESTONE 2: Stage-1 Compiler Running on Parrot. 

 

 Week 5) June 30-July 6: Will attempt to transform parrot’s PAST from original AST. This will be done in parallel to the testing of stage 1 compiler. Add more test suites if necessary. 

 

 MILESTONE 3: More test-suites, and complete documentation till stage 1. 

 

 Week 6) July 7-july 13: Discuss PAST status with mentor and decide how to proceed further, make changes in plan if needed. 

 

 MILESTONE 4: PAST may or may not be introduced to compiler, depending on discussion with mentor and plan out for the next week. 

 

 Week 7) July 14-July 20: Work again on PAST with better strategy, add more tests, study about stage 2 features and how to implement them. 

 

 MILESTONE 5: Most probably a compiler with PAST, if failure occurs , stick to backup policy. 

 

 Week 8) July 21-July 27: project compilation upto stage 1 , complete any backlogs , this time is for compensate for any unknown break during previous weeks , complete documentation , finish final test suite till this stage. 

 

 MILESTONE 6: successful project finished upto stage 1. 

 

 Week 9) July 28-August 3: start hacking on stage 1 compiler ,to add special parrot features like cross library communication , start reading standard compilers api. Discuss with mentors about the necessary features that can be implemented.

 

 Week 10) August 4-August 10 : Work on the decided features , do necessary study. Keep discussing project improvements with mentor , start to think about test suite for new compiler (JSpec or any other), Discuss about the new test-suite with mentor and start making tests 

 

 

MILESTONE 7: Decided features implemented on Compiler.

 

 Week 11)August 11-August 17: Create more tests and test the features if any added , work on more features . test the compiler for all previous stages to ensure everything is intact and working perfectly if not , stick to backup policy and stop further work and finish main compiler (stage 1) to ensure it’s working perfectly . 

 

 MILESTONE 8: All features Implemented, Test Suite Finished. Project working smoothly on Parrot.


 Week 12) August 18-August 22: Wind up the project , complete documentation work , improve code structure ,confirm project status with the mentor .

MILESTONE 9: a complete successful GSOC project. 


 REFERENCES AND LIKELY MENTORS: 

 

 Discussed project idea with 

 

 Whiteknight* (Andrew Whitworth) 

 

 Dukeleto* (Jonathan "Duke" Leto) 

 

 (* irc nick-names) 

 

 

 

 LICENSE: 

 

 I will be happy to use Artistic 2.0 license for my project. 

 

 

 

 PROBLEM RESOLUTION: 

 

 Clear the project details before the actual coding to avoid confusion later. Keep in touch with mentor and the authors of the tools and libraries if used any. Make Backup policy in such a way to keep focus on imp goals to avoid major problems that can stop project’s progress. Generate useful tests to reduce errors and crashes. Testing at various stages of compiler design to ensure sustained development and in case of any problem, I will be able to go to previous stage. 

 

 

 

 BACKUP PLAN: 

 

 Test the code after every significant change in source code to ensure stable configuration. In case of failures in stage 2 compiler , go back to stage 1 compiler and ensure it’s working perfectly , if not make it work and add more tests and get back to where we left the project. Build compiler in stages and sub-stages so that moving back and forth from one sub stage to other is possible in case of sudden failure. Highest priority is the working stage 1 compiler , stage 2 and inclusion of PAST will be attempted only after a stable stage 1 compiler. 

 

 

 

 BIO: 

 

 Hello, 

 

My name is Rohit Jangid, and I’m a computer science student from NSIT (http://www.nsit.ac.in) college, India. I have been programming from my school time and have good knowledge in various types of languages and platform. C/C++, JavaScript and Java are my primary languages, have also worked extensively in j2ee technology like Servlets and Jsp for web-applications. I am open source promoter and infact love working on Linux. I’m very dedicated towards my work and can learn new things very quickly and I believe that makes me a good candidate to work on this project. Though I am new to Parrot and compiler design, I’ve done extensive study in this subject while interacting with Parrot members on Irc. My semester course for next semester contains “compiler design” as a subject also, This is also one of the motivating factor that attracts me to this project. I’m familiar with basic project development on Linux and version control system like bazaar and Git. My hobbies include listening to music and playing basketball. I have a technical Blog where I put everything I learn. I’m pursuing a graduate course and currently in 3rd year, and have necessary documents that can prove my admission and that makes me an eligible student for GSOC , I’ll clarify the legal requirements if needed.