JS-Python

From OLPC
Revision as of 12:19, 28 March 2008 by Kspreeti (talk | contribs) (New section)
Jump to: navigation, search

New section

       With the increased use of Open Source software development in the field of programming, it is no wonder that we have witnessed a greater influx of better and more efficient platforms for this coding. Open source development enables programmers to have more exposure and interaction with programming communities and to imbibe the best ideas in order to come up with an eclectic program, which is more efficient in all possible ways.

One of the most important platforms of this open source development is the Python Platform. Python is a high level programming language, which has an open, community based development model. It has the advantage of being a readable language, which can inculcate the high points of C, C++ and Java, and at the same time, provide the programmer the gain of dealing with a comparatively easier to use language.

On the other hand, client side web development languages such as JavaScript are gaining more and more momentum due to their inbuilt capabilities of adding functionality to web pages, validating forms and detecting browsers.

The aim of my project is to integrate these two highly useful platforms, in order to form an extremely powerful tool, via which it will be possible to use JavaScript functions on Python platforms. The functionality of this project is apparent in the fact that both Python and JavaScript have their own numerous advantages, but at the same time they also have their limitations.

Python forms a great tool for programming; it does not have the inbuilt features to aid in creation, packaging and distribution of various dynamic web based elements which are available in the web. These features include use of forms for data submission, use of various other web elements to provide users with an enriching experience, et al. These have become essential features of any application now. However, Python does not allow programmers to enjoy these.


On the other hand, JavaScript gives a great platform to provide users with the perfect web experience, including some major advantages like cross-browser support, validating data on the client, and being able to create more sophisticated user interfaces. JavaScript effects are also much faster to download than some other front-end technologies like Flash and Java applets. Nor do users need to download a plug-in before they can view your JavaScript. Other advantages include the fact that no extra tools are required to write JavaScript, any plain text or HTML editor will do. There is a thriving and supportive online community of JavaScript developers and information resources. However, JavaScript is not an independent language. It needs a program to act as a parasite on. JavaScript is included in HTML and PHP files to provide the web interface. But what about its functionality in open source development?

This is the question that we have to ask when we use Python to build various applications, wherein the user interface and the experience of the user forms a very important component. XPCOM or Cross Platform Component Object Model was introduced for this purpose. The goal of XPCOM is to allow different pieces of software to be developed and built independently of one another. In order to allow interoperability between components within an application, XPCOM separates the implementation of a component from the interface. XPCOM also provides several tools and libraries that enable the loading and manipulation of these components, services that help the developer write modular cross-platform code, and versioning support, so that components can be replaced or upgraded without breaking or having to recreate the application.

XPCOM has various components to it. PyXPCOM allows for communication between Python and XPCOM, such that a Python application can access XPCOM objects, and XPCOM can access any Python class that implements an XPCOM interface. With PyXPCOM, a developer can talk to XPCOM from a Python application. Similarly, XPConnect forms the JavaScript-XPCOM Bridge. But these interfaces create additional and complex programs. When we are faced with situations involving updating or memory retrieval, it would involve using a Javascript function on a Python interface. The reason why PyXPCOM is useful is because it allows us to build GUIs using Mozilla as the rendering engine but the application logic using Python and Perl. It is generally much quicker to build applications with Python and Perl than it is with C/C++ . Enabling this interface will allow a new breed of applications to be built that can utilize the Web for network transport and HTML (and XUL) for building the interface, but without relying on clumsy CGI/Servlets trying to hack a real user experience with just HTML. That is the whole point of XPCOM.

In such a situation, we can develop an inter browser functionality wrapping, which would enable users to have a JavaScript experience in Python interfaces directly, without having to depend on external programs. When handling applications such as Spreadsheet, Journal, Sharing, et al, the tasks would involve saving. While the applications themselves can be built on Python based programs such as Sugar, the functions such as Saving can be easily performed using JavaScript. Instead of depending completely of an external interface such as XPCOM, we can make an inbuilt function which mobilizes the inclusion of JavaScript into Python or vice versa.