Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rohit-nsit08/891156 to your computer and use it in GitHub Desktop.
Save rohit-nsit08/891156 to your computer and use it in GitHub Desktop.
my Proposal for javascript compiler on Parrot
NAME: Rohit Jangid
EMAIL ID: rohit.nsit08@gmail.com
GOOGLE ID: rohit.nsit08
OTHER CONTACT INFO:
Irc nick-name on #parrot channel: rohit_nsit08
PROJECT TITLE: JavaScript on Parrot
ABSTRACT:
The project is based on implementing a JavaScript compiler to be written mostly or entirely using JavaScript. The existing compiler projects like cafe/jasper are most likely to be used for base development. 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 PARROTVM 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 benefit with its inclusion in parrot list of interpretors. It is important since all the present browsers have JavaScripting capabilities but there are very few command line tools available for it.
There are compilers already available in javascript like 'Rhino', which is written in java and is one of the sought after tool in this regard, but has 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 and 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 working on 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 we can proceed and develop a bootstrapped JavaScript compiler written entirely in JavaScript.
DELIVERABLES:
A basic JavaScript compiler, with a suitable test-suite, a suitable build infrastructure compatible with major systems and a project documentation that will help future developers to carry on work further. Providing a good build infrastructure and documentation will be highly important for building a community and maintain after the summer.
PROJECT DETAILS:
1. The project is based on bootstrapping concept to make a javascript -in- javascript on parrot 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. 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. 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
5. Further modifications will be made to Stage 1 compiler to add support for modules written in other languages .Any modification to stage 1 will result in a feature rich stage 2 compiler.
6. At this stage , we’ll be having a running javascript compiler on parrot platform
7. Perform tests and necessary optimizations, to ensure stable working of stage 1 compiler
8. If all goes well, Attempt to transform original AST into parrots PAST OBJECT so that we can use optimizations and other facilities available.
9. Modify the generated source code and compile it in itself in cycles for further improvements and get desired performance
10. For test-suite, It will be implemented in two parts ,
Part1: before we have stage 0 ready, testing will be implemented using rosella test.pbc
Part2: after stage 1, we’ll be having a running javascript compiler so we can attempt to use ‘jspec’ testing framework for this stage, in combination of rosella.
11. For documentation purpose, jsdoc has been chosen as it is open source with lots of organisations already using it for their documentation.
My current status: I’m currently experimenting on node.js, cafe, and jison combination and in touch with author of cafe and jison and node.js to sort out the issues which i am facing right now.
PROJECT SCHEDULE:
March 28 – April 25: work on project details ,search for loop holes to ensure proper understanding of project and work ahead , getting familiar to parrot organisation , do some study on test-suits and testing framework, using Github.
Target : to get acquaint with the in-depth details of the projects, 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 cafe ,
Target: to get a working environment set up prepared to go for stage 1 compiler
Milestone 0: all groundwork must be finished by this stage to be in best state to start the actual coding, detailed plan of project, backup policy and to be finalised with the mentor, finalize stage 0 compiler whether nodejs or narwhal
University Exams: <tentative dates> May 16 – May 31 <absence during this time>
Summer Vacations start
ACTUAL CODING STARTS:
Week 1) June 1-June6: Work on (cafe/jasper)backend<will have been finalised by this time> backend , transform code generator to emit code in PIR/PBC.
Milestone 1: a partial/complete backend with few tests to check correctness
Week 2)June 7-June 13: carry on with backend code , work on improving the code structure and add more tests.
Milestone 2: compiler is able to generate PIR code,<may require further impovements>
Week 3) June 14-June 22: run the generated PIR code on Parrot , remove errors if any from the (week 2 project) build an executable and get the stage 1 compiler ready .
Milestone 3: A running (may be with error or warnings) stage 1 compiler on parrot, successful compilation of ‘jspec’ or any other javascript program to test the compiler.
Week 4) June 23-June 29: remove all the errors from the compiler , add test suits , test for crash and failures, debug, test. Start documentation up to this stage.
Milestone 4: An improved stage 1 compiler 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 suits if necessary.
Milestone 5: more code with test-suits, 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 accordingly,
Milestone 6: PAST may or may not be introduced to compiler, whatever the output discuss status with mentor and plan out for the next week
Week 7) July 14-July 20 : attempt again on PAST with better strategy , more tests to be added in the compiler , study about stage 2 features and how to implement them
Milestone 7: 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 in during previous weeks , complete documentation , finish final test suite till this stage ,
Milestone 8: 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
Milestone 9: features to be added decided ,Work started on one choosen feature.
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 10: clear about the features and how to implement them , atleast one feature ready for compilation.
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 11: atleast 2 or 3 features added in compiler, work completed on test-suite. A working compiler existing 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 12: a complete successful GSOC project
References and Likely Mentors:
REFERENCES AND LIKELY MENTORS:
Discussed project idea with
Whiteknight
Dukeleto
Moritz
PROBLEM RESOLUTION
Clear the project details to maximum possible level before the actual coding to avoid confustion later.
Keep in touch with mentor and the authors of the tools and libraries if used any
Plan Backup policy in such a way to keep focus on imp goals to avoid major problems that can stop projects forward progress .
Generate usefull tests to reduce errors and crashes.
Testing at various stages of compiler design to ensure sustained development and in case of any problem , we can 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 (6th semester) from NSIT college, India. I’ve been programming from my school time and have a vast experience 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’m open source promoter and infact love working on Linux. I’m very dedicated towards my work and can learn things quickly and I believe that makes me a good candidate to work on this project. I’m new to parrot but now I’m reading and experimenting on it. Our semester course for next semester contains “compiler design” as a subject also, This is also one of the motivating factor that attracts me to my project. I’m familiar with basic project development on Linux and version control system like bazaar and launchpad, recently started using github for parrot. I’m pursuing a graduate course and currently in 3rd year, and have necessary documents that can prove my admission. I believe that makes me an eligible student for gsoc , I’ll clarify the legal requirements if needed
@Whiteknight
Copy link

You're planning to have your PIR code generator completed in a week? Impressive. Look at existing compilers to see the output they produce. with NQP you can write "parrot-nqp --target=pir" to see the PIR code it generates. For winxed, you can use "winxed -c" to compile down to PIR code. Seeing the sequences that other compilers use can be very helpful, and give you some good examples to follow. You can read through some examples like this during exams week :)

In Week 2, what makes a "satisfactory" back end?

In Week 3 you talk about making the code work correctly. You should find some existing software to use as a target. For instance, jspec. When jspec compiles and runs on your compiler, you can call that a milestone. Pick a good target to use, when you can compile the target, you call the backend a success. Self-compiling cafe is a good example.

"test-suits" -> "test suites" (small spelling change)

Personally, I would like your week 9 features (cross-library and compiler API) to happen before weeks 6-8. I think this is more important.

Your proposal is looking very nice! Keep up the good work!

@rohit-nsit08
Copy link
Author

rohit-nsit08 commented Mar 29, 2011 via email

@rohit-nsit08
Copy link
Author

3rd version uploaded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment