Pyjamas (software)
Encyclopedia
Pyjamas is a tool and framework for developing Ajax applications in Python
. It contains a stand-alone Python
-to-JavaScript
compiler, an Ajax framework
and widget toolkit
, and through use of these components, developers can write comprehensive applications, to run in all major web browsers, without writing a single line of JavaScript. Pyjamas is a port of Google Web Toolkit
from Java
to Python
as the input language.
instead of JavaScript
. The application is compiled to JavaScript
. Also included is an Ajax library and widget set that provides access to the DOM model of modern JavaScript-capable web browsers. The Ajax library and the widget set library are a hybrid mix of Python and JavaScript. Just as with GWT
, "Pyjamas is not its libraries", and neither is it "yet another Ajax framework". Ajax Frameworks
are strictly limited to providing pre-prepared specific functionality, written almost exclusively in tailor-made JavaScript. Both GWT and Pyjamas, being JavaScript compilers, allow the developer to work in the language with which they are familiar (Java or Python, respectively), to write their own custom widgets, either entirely from scratch or based on the existing available widgets, yet still target the full range of modern browsers. So, far from presenting web developers with a fait-accompli Ajax Framework, Pyjamas gives you the freedom to develop your own.
to compile its input into JavaScript, walking the abstract syntax tree
of the program being compiled. Although the compiler is stand-alone, the primary use of Pyjamas is for web development, so there is additional infrastructure for building web applications.
The DOM.py model library is an abstraction layer - a thin layer of Python on top of JavaScript code snippets - use of which provides access to the full document object model
of the target browser platform. As with any compiler, the JavaScript snippets are treated as inline assembler
.
Furthermore, on top of the DOM.py model library is an additional abstraction layer, ui.py, which provides the most useful layer to web developers: a full suite of widgets with which desktop application developers will be familiar. At present, the list of available widgets is a mixture of the complete set of widgets that were available in Google Web Toolkit
1.2, along with a few more that have been forward-ported from GWT 1.5.
pyjs Python-to-JavaScript Compiler
Python builtin and standard emulation library
Pyjamas DOM library
Pyjamas Web UI module
Pyjamas Desktop ports
and PyGTK
that a port of Pyjamas was made to run Pyjamas applications on the desktop, called Pyjamas-Desktop. The project uses Webkit
, XULRunner
or MSHTML as the underlying technology, and it is through these browser engines that Pyjamas manipulates the DOM model of the application. Pyjamas and Pyjamas Desktop allow writing cross-platform, cross-desktop, cross-browser and cross-widget applications that run on the web and on the desktop.
Python (programming language)
Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability. Python claims to "[combine] remarkable power with very clear syntax", and its standard library is large and comprehensive...
. It contains a stand-alone Python
Python (programming language)
Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability. Python claims to "[combine] remarkable power with very clear syntax", and its standard library is large and comprehensive...
-to-JavaScript
JavaScript
JavaScript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. It is a multi-paradigm language, supporting object-oriented, imperative, and functional programming styles....
compiler, an Ajax framework
Ajax framework
In web application development, an Ajax framework is a framework which leverages Ajax, a collection of technologies for building dynamic web pages on the client side...
and widget toolkit
Widget toolkit
In computing, a widget toolkit, widget library, or GUI toolkit is a set of widgets for use in designing applications with graphical user interfaces...
, and through use of these components, developers can write comprehensive applications, to run in all major web browsers, without writing a single line of JavaScript. Pyjamas is a port of Google Web Toolkit
Google Web Toolkit
Google Web Toolkit is an open source set of tools that allows web developers to create and maintain complex JavaScript front-end applications in Java. Other than a few native libraries, everything is Java source that can be built on any supported platform with the included GWT Ant build files...
from Java
Java (programming language)
Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities...
to Python
Python (programming language)
Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability. Python claims to "[combine] remarkable power with very clear syntax", and its standard library is large and comprehensive...
as the input language.
Development
Using Pyjamas, developers can write web applications in PythonPython (programming language)
Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability. Python claims to "[combine] remarkable power with very clear syntax", and its standard library is large and comprehensive...
instead of JavaScript
JavaScript
JavaScript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. It is a multi-paradigm language, supporting object-oriented, imperative, and functional programming styles....
. The application is compiled to JavaScript
JavaScript
JavaScript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. It is a multi-paradigm language, supporting object-oriented, imperative, and functional programming styles....
. Also included is an Ajax library and widget set that provides access to the DOM model of modern JavaScript-capable web browsers. The Ajax library and the widget set library are a hybrid mix of Python and JavaScript. Just as with GWT
Google Web Toolkit
Google Web Toolkit is an open source set of tools that allows web developers to create and maintain complex JavaScript front-end applications in Java. Other than a few native libraries, everything is Java source that can be built on any supported platform with the included GWT Ant build files...
, "Pyjamas is not its libraries", and neither is it "yet another Ajax framework". Ajax Frameworks
Ajax framework
In web application development, an Ajax framework is a framework which leverages Ajax, a collection of technologies for building dynamic web pages on the client side...
are strictly limited to providing pre-prepared specific functionality, written almost exclusively in tailor-made JavaScript. Both GWT and Pyjamas, being JavaScript compilers, allow the developer to work in the language with which they are familiar (Java or Python, respectively), to write their own custom widgets, either entirely from scratch or based on the existing available widgets, yet still target the full range of modern browsers. So, far from presenting web developers with a fait-accompli Ajax Framework, Pyjamas gives you the freedom to develop your own.
Design
The Pyjamas compiler is written in Python, and uses the Python programming languagePython (programming language)
Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability. Python claims to "[combine] remarkable power with very clear syntax", and its standard library is large and comprehensive...
to compile its input into JavaScript, walking the abstract syntax tree
Abstract syntax tree
In computer science, an abstract syntax tree , or just syntax tree, is a tree representation of the abstract syntactic structure of source code written in a programming language. Each node of the tree denotes a construct occurring in the source code. The syntax is 'abstract' in the sense that it...
of the program being compiled. Although the compiler is stand-alone, the primary use of Pyjamas is for web development, so there is additional infrastructure for building web applications.
The DOM.py model library is an abstraction layer - a thin layer of Python on top of JavaScript code snippets - use of which provides access to the full document object model
Document Object Model
The Document Object Model is a cross-platform and language-independent convention for representing and interacting with objects in HTML, XHTML and XML documents. Aspects of the DOM may be addressed and manipulated within the syntax of the programming language in use...
of the target browser platform. As with any compiler, the JavaScript snippets are treated as inline assembler
Inline assembler
In computer programming, the inline assembler is a feature of some compilers that allows very low level code written in assembly to be embedded in a high level language like C or Ada...
.
Furthermore, on top of the DOM.py model library is an additional abstraction layer, ui.py, which provides the most useful layer to web developers: a full suite of widgets with which desktop application developers will be familiar. At present, the list of available widgets is a mixture of the complete set of widgets that were available in Google Web Toolkit
Google Web Toolkit
Google Web Toolkit is an open source set of tools that allows web developers to create and maintain complex JavaScript front-end applications in Java. Other than a few native libraries, everything is Java source that can be built on any supported platform with the included GWT Ant build files...
1.2, along with a few more that have been forward-ported from GWT 1.5.
Components
The major Pyjamas components include:pyjs Python-to-JavaScript Compiler
- Translates the Python programming language to the JavaScript programming language.
Python builtin and standard emulation library
- JavaScript implementations of the commonly used modules, builtins and classes in the Python standard runtime library (such as strings, lists, dictionaries, tuples, sets, getattr, map, filter, range etc.; basic exception handling, a basic datetime and a basic math module).
Pyjamas DOM library
- Modules for manipulating the browser DOMDocument Object ModelThe Document Object Model is a cross-platform and language-independent convention for representing and interacting with objects in HTML, XHTML and XML documents. Aspects of the DOM may be addressed and manipulated within the syntax of the programming language in use...
.
Pyjamas Web UI module
- A module for creating widgets as if the web browser was a Desktop Widget EngineWidget engineIn computer software, a widget engine is a software service available to users for running and displaying applets on a graphical user interface, such as that of the desktop.The widget model in widget engines is attractive because of ease of development...
.
Pyjamas Desktop ports
- Support for running Pyjamas apps as pure Python, under MSHTML, XULRunnerXULRunnerXULRunner is a runtime environment developed by the Mozilla Foundation to provide a common back-end for XUL-based applications. It replaced the Gecko Runtime Environment, a stalled project with a similar purpose....
or WebkitWebKitWebKit is a layout engine designed to allow web browsers to render web pages. WebKit powers Google Chrome and Apple Safari and by October 2011 held over 33% of the browser market share between them. It is also used as the basis for the experimental browser included with the Amazon Kindle ebook...
. Pyjamas Desktop is conceptually close to GWT "Hosted" mode, except that the applications can be deployed live, under Pyjamas Desktop, rather than be used exclusively as a debugging tool.
Pyjamas Desktop
The widget set library that comes with Pyjamas is so similar to PyQtPyQt
PyQt is a Python binding of the cross-platform GUI toolkit Qt. It is one of the alternatives for GUI programming in Python to Tkinter, which is bundled with Python. Other popular alternatives are PySide, PyGTK, and wxPython. Like Qt, PyQt is free software. PyQt is implemented as a Python...
and PyGTK
PyGTK
PyGTK is a set of Python wrappers for the GTK+ graphical user interface library. PyGTK is free software and licensed under the LGPL. It is analogous to PyQt and wxPython which are python wrappers for Qt and wxWidgets respectively. Its original author is the prominent GNOME developer James Henstridge...
that a port of Pyjamas was made to run Pyjamas applications on the desktop, called Pyjamas-Desktop. The project uses Webkit
WebKit
WebKit is a layout engine designed to allow web browsers to render web pages. WebKit powers Google Chrome and Apple Safari and by October 2011 held over 33% of the browser market share between them. It is also used as the basis for the experimental browser included with the Amazon Kindle ebook...
, XULRunner
XULRunner
XULRunner is a runtime environment developed by the Mozilla Foundation to provide a common back-end for XUL-based applications. It replaced the Gecko Runtime Environment, a stalled project with a similar purpose....
or MSHTML as the underlying technology, and it is through these browser engines that Pyjamas manipulates the DOM model of the application. Pyjamas and Pyjamas Desktop allow writing cross-platform, cross-desktop, cross-browser and cross-widget applications that run on the web and on the desktop.
Sites using Pyjamas
- Tickery (tickery.net)
- (lkcl.net)
- Nagare Web Framework (nagare.org)
- Beammail IMAP client (beammail.org)
- (campusmixes.com)
- Online Minesweeper (pymines.appspot.com)