On Wed, Dec 7, 2011 at 10:08 AM, Apexi 200sx <[email protected]> wrote:
> Is there no particular reason for the comment regarding JS() will
> cause you grief

By including JS() you have essentially eliminated the entire Python
toolchain and are just using Python syntax and semantics as a medium
to write JavaScript. In that case why not skip the complexity of
compiling and write directly in JavaScript?

I guess most people that use Pyjamas use it because they like
programming in Python and enjoy all of the tools that come with it to
do development. It doesn't make sense to invest in Pyjamas if you are
going to then make it difficult/impossible to actually run the app
with Python during development.

The "grief" mentioned I think is in the sense that by using JS() you
can no longer debug your code using CPython.

There are a lot of disadvantages to using Pyjamas such as the code
being generated is significantly larger than hand written javascript,
it is also nowhere near as performant as hand written javascript.
Given these significant downsides and then adding more downsides by
eliminating the Python tool chain the only thing you're left with is
the Python syntax and semantics.

Why not just use CoffeeScript then? You'd have much less generated
code and it would likely run faster than pyjamas generated javascript.
And you'd still have a nicer syntax than pure javascript. CoffeeScript
also interacts directly with JavaScript libraries so there will be no
wrapping necessary.

> and also unless I want to provide a nicer OO wrapper
> around a JS library (like the widgets do with pyjamas as they wrap
> HTML elements) there's no particular need for wrapping JS libs with a
> python wrapper like GWT has to do because of static checking ?

The widgets in Pyjamas use the DOM, this DOM is available to Python
through web browser bindings. So, when you run the Python desktop
version of pyjamas your python code is directly interacting with the
DOM model exactly as the javascript code would be doing. This lets you
debug and run your application with no javascript in sight using all
of the standard Python tools, debuggers, etc.

By calling JS() you are introducing something that doesn't exist in
the desktop version of pyjamas, can't be debugged in Python, etc.

In summary, pyjamas wrapping HTML elements (via the DOM) is nothing
like using JS() to wrap a javascript library, at least not when it
comes to desktop version of pyjamas (in pyjs all of this is irrelevant
of course).

> Are there any pitfalls to watch out for when using JS libs

Other than not being able to run/test/debug your app with CPython I
don't know. Given the downsides I never bothered to try using JS().

 - lex

Reply via email to