Document Information

Last modified:
2008/04/10 13:26 by hughgibson

From Python to JavaScript

If you are a Python programmer and you know only little about JavaScript, the following explanations and comparisons might help getting you started with qooxdoo application development:

Feature Comparison

Here is an overview table that relates Python and JavaScript (or qooxdoo where appropriate) features.

  Python JavaScript/qooxdoo
local object self (arbitrary, e.g. "self.x") this (fixed, e.g. "this.x")
blocks through indentation (layout) through braces {...}
class definition class key word qx.Class.define() class constructor, see class declaration
loop constructs while ...
for ... in ...
while (...)
for (...; ...; ...)
for (... in ...)
do {...} while (...);
objects class instances; member access only through x.m map instances; member access through x.m and x['m']
Data structures Flexible data structures using {} for dict and [] for list Just about the same using JSON notation. Dict keys can only be simple as dicts are implemented as objects. API varies; qooxdoo provides some more functions.
local scope all variables in a function/method are local, unless you declare them global all variables in a function/method are global, unless you declare them local with var
function values functions have to be declared with def, but are then first-class values and can be assigned; lambdas are unnamed, parameterized expressions that can be used in place of an expression functions are created with function and can be named or unnamed (closures); they are first-class values and can be assigned
interactive shell python full-featured shell, part of the Python core distribution browser plugins like Firebug plugin for Firefox; full-featured shell with 'inspect' feature for current application; command line interpreters like Mozilla's SpiderMonkey, or the Rhino shell (but those lack the browser APIs)

Further Tips and Hints

  • You need to use a terminal (which as a Python programmer you are already comfortable with) to take advantage of the development tools that come with qooxdoo. Particularly, the “build process” generates applications for you and is used with simple shell commands.
  • Anyways, when using skeletons, you need to know these commands:
    • make ⇒ generates the development version work (into the source directory)
    • make build ⇒ generates the production (optimized) version work (into a build directory)
    • make api ⇒ creates an api viewer for all qooxdoo classes and also your own classes (into an api directory)

Summary: when using a new framework/ language/etc. the issue is not the language. You’ll be spending more time learning the tools. Javascript is actually quite similar to Python, since both are dynamically typed languages with easy reflection. It would be much harder if you were used to statically typed languages such as Java or C.

Information

Last modified:
2008/04/10 13:26 by hughgibson

Account

Not logged in

 
 

Job Offers

To further improve qooxdoo we are seeking javascript developers. Read more...

Rich Ajax Platform (RAP)

RAP uses qooxdoo, Java and the Eclipse development model to build rich web applications. Read more...

qooxdoo Web Toolkit (QWT)

Similar to GWT this framework allows to create impressive qooxdoo applications just using Java. Read more...

Pustefix

Pustefix is a MVC-based web application framework using Java and XML/XSLT. Read more...

 
SourceForge.net Logo

Bad Behavior has blocked 0 potential spam attempts in the last 7 days.