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
- Follow the "Hello World" tutorial
- 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 thesourcedirectory)make build⇒ generates the production (optimized) version work (into abuilddirectory)make api⇒ creates an api viewer for all qooxdoo classes and also your own classes (into anapidirectory)
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.
