Changes

Jump to: navigation, search

Processingjs gamepaper

257 bytes removed, 05:51, 16 January 2011
Processing.js in detail
While JavaScript and Java are fairly similar syntactically, there are some fundamental differences that has made this conversion challenging. The first is that we wanted to do this conversion dynamically when a web page is loaded. The code produced by Processing.js needed to be fully object oriented and we had to provide support to all native Java functions and objects that are supported by Processing. We also had to take into account the differences between working with web resources vs local resources. Furthermore we had to consider how we would handle some fundamental differences between Java and JavaScript such as typed vs. typeless variables, function overloading and variable name overloading.
The original code for Processing.js used regular expressions to convert Java into JavaScript when it was encountered. It did this by scanning for hints of Java code within the entire sketch and then replaced the Java code with its JavaScript equivalent. Due to the difference in how Java and JavaScript accessed object properties from methods inside an object, the with statement was used as a simple solution to avoid having to prepend all function calls with "this." or "Processing.". However, the use of the with statement also meant that the JavaScript generated would fall off Trace /*cite trace paper here... do we need to talk about trace in the back ground section???*/ making the code run slower than it needed to in some browsers. Later In later versions of Processing.js this method of scanning the entire sketch was replaced by the creation of an abstract syntax tree that broke up the code up the sketch into smaller pieces. Each piece was then had the regular expressions applied to change itinterpreted separately. This change made it was easier to apply the regular expressions correctly without accidentally converting code that was already working. It also made it easier to create proper inheritance structures and attach properties and methods to interpretation of the correct object in the hierarchy chain as smaller pieces of code was being converted at any one timesketch far cleaner.
==Browser Unification==

Navigation menu