pyjs and debugging

65 views
Skip to first unread message

Hauke Duden

unread,
Mar 13, 2014, 5:04:28 AM3/13/14
to pyjs-...@googlegroups.com
Hello everyone,

I am evaluating pyjs for a new project. But there is one important aspect that I am unclear about: is there a good way to debug pyjs applications? I am talking about real step-by-step debugging, not log messages.

One important aspect: we will most likely not use the pyjs GUI components. We prefer to use other existing Javascript libraries for that. So debugging would probably have to be within some kind of browser environment (?).

If I understood correctly then pyjs Desktop does not support the DOM and can only be used to debug applications that use the pyjs GUI components. Is that correct?

Is there source map support?

How are people debugging pyjs apps right now?

Please note that we are flexible on which development environments to use. So if one offers great integration with pyjs then it is no problem for us to switch to that.

Any hints and tips would be appreciated.

Best regards,

Hauke Duden

Adrien

unread,
Mar 13, 2014, 10:21:43 AM3/13/14
to pyjs-...@googlegroups.com
Hi,

On 03/13/2014 10:04 AM, Hauke Duden wrote:
> How are people debugging pyjs apps right now?

I debug with the Firefox web console only, adding some "print"
statements here and there until I manage to find the bug. This may sound
ridiculous but Venkman, the Javascript (step by step) debugger which is
recommended for development with Firefox [1], was running so slow that
it was not usable at all.

I don't know what other way you have to debug pyjamas applications... so
for myself, that's it: Python code live analyser (Pylint) and Firefox
web console.

I would be interested as well to know about other's experiences.

[1] http://pyj.be/#Developing

Cheers,
Adrien

Lex Berezhny

unread,
Mar 13, 2014, 10:26:28 AM3/13/14
to pyjs-...@googlegroups.com

I develop, debug and test the app in python using Python tools (PyCharm in my case).

If you are not using python tools then why the heck are you using pyjs?

There are much better solutions if you prefer debugging in browser such as CoffeeScript and many other "js preprocessors".

- lex

--

--- You received this message because you are subscribed to the Google Groups "Pyjs.org Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyjs-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hauke Duden

unread,
Mar 13, 2014, 10:37:19 AM3/13/14
to pyjs-...@googlegroups.com
We are using Python tools (also PyCharm, by the way). But the problem is that this only allows us to debug the part of the software that is pure Python. But as soon as third party Javascript libraries are involved (jQuery UI, etc) then we cannot debug in a pure Python environment anymore. This kind of code obviously requires a proper Javascript and DOM environment to run these third party JS libraries.

That is why I asked wether source maps are supported. If they are then we could debug the UI stuff in Google Chrome or Firefox. That would be fine for our purposes. But we really need some way to do step-by-step debugging (also for our UI stuff).

Hauke
To unsubscribe from this group and stop receiving emails from it, send an email to pyjs-users+...@googlegroups.com.

Stephen Waterbury

unread,
Mar 13, 2014, 10:45:51 AM3/13/14
to pyjs-...@googlegroups.com
I use the Web Developer plugin for Firefox for high-level notifications
of problems, or for deeper debugging, Chromium's javascript "console"
can be useful (of course, finding the section in your python code that
generated the offending section of javascript can be fun ... ah the
joys of forensic code inspection ... ;)

Steve

On 03/13/2014 10:37 AM, Hauke Duden wrote:
> We are using Python tools (also PyCharm, by the way). But the problem is
> that this only allows us to debug the part of the software that is pure
> Python. But as soon as third party Javascript libraries are involved
> (jQuery UI, etc) then we cannot debug in a pure Python environment
> anymore. This kind of code obviously requires a proper Javascript and
> DOM environment to run these third party JS libraries.
>
> That is why I asked wether source maps are supported. If they are then
> we could debug the UI stuff in Google Chrome or Firefox. That would be
> fine for our purposes. But we really need *some* way to do step-by-step
> debugging (also for our UI stuff).
>
> Hauke
>
> On Thursday, March 13, 2014 3:26:28 PM UTC+1, Lex Berezhny wrote:
>
> I develop, debug and test the app in python using Python tools
> (PyCharm in my case).
>
> If you are not using python tools then why the heck are you using pyjs?
>
> There are much better solutions if you prefer debugging in browser
> such as CoffeeScript and many other "js preprocessors".
>
> - lex
>
> On Mar 13, 2014 10:21 AM, "Adrien" <soul...@mailoo.org

Lex Berezhny

unread,
Mar 13, 2014, 10:46:43 AM3/13/14
to pyjs-...@googlegroups.com

Just develop the components separately.

Or if you really need to debug (during integration testing) than you can just debug the generated code. It's not that complicated, if you look through the generated code a few times it will start to make sense.

Source maps can create their own issues. It's better to look at the actual code being executed instead of source maps.

But my advice: don't write the code that calls jQuery in Python. It'll be a pain in many more ways than just debugging.

Either go full python or if you're using js libs than use them from js. You can communicate between the python and js world using a DOM element. This will let you unit test each side of the components and let you debug natively.

- lex

Hauke Duden

unread,
Mar 13, 2014, 11:08:58 AM3/13/14
to pyjs-...@googlegroups.com
Well, I guess that means that source maps are not supported by pyjs?

I know that they are not perfect, but they don't need to be. If a complicated issue comes up where we need to check out the JS code then we can still do that. But we want to be able to debug in the source language in the normal cases.

The whole idea behind using pyjs is to use a language that makes it easy to write high quality and above all READABLE code in a language without obscure quirks like weird scoping or magical syntax or the like (which means Javascript and Coffeescript and most other JS compilers are out). But we still want to take advantage of all the great existing JS libraries.

With sourcemap support I think pyjs would be a great contender - especially since our server side code is also written in Python. But without source maps (or another way to debug integrated pyjs and js code) I think we will have to look elsewhere.

Jim Washington

unread,
Mar 13, 2014, 12:46:04 PM3/13/14
to pyjs-...@googlegroups.com, Hauke Duden

On Thursday, March 13, 2014 08:08:58 AM Hauke Duden wrote:

> Well, I guess that means that source maps are not supported by pyjs?

>

> I know that they are not perfect, but they don't need to be. If a

> complicated issue comes up where we need to check out the JS code then we

> can still do that. But we want to be able to debug in the source language

> in the normal cases.

>

> The whole idea behind using pyjs is to use a language that makes it easy to

> write high quality and above all READABLE code in a language without

> obscure quirks like weird scoping or magical syntax or the like (which

> means Javascript and Coffeescript and most other JS compilers are out). But

> we still want to take advantage of all the great existing JS libraries.

>

> With sourcemap support I think pyjs would be a great contender - especially

> since our server side code is also written in Python. But without source

> maps (or another way to debug integrated pyjs and js code) I think we will

> have to look elsewhere.

 

Give Dart a good look. Don't expect it to work well with IE < 9, or other really old browsers. It has essentially the same quick development turnaround as pyjs with the native client. Aside from the semicolons and curly braces, it feels a lot more like python than javascript. The recent release of Angular.dart makes it really worth investigating.

 

- Jim Washington

 

 

Glyph Lefkowitz

unread,
Mar 13, 2014, 3:17:17 PM3/13/14
to pyjs-...@googlegroups.com

On Mar 13, 2014, at 8:08 AM, Hauke Duden <hauke...@gmail.com> wrote:

Well, I guess that means that source maps are not supported by pyjs?

Pretty sure not.

I just filed this issue <https://github.com/pyjs/pyjs/issues/818> so this idea doesn't get lost.

-glyph

Glyph Lefkowitz

unread,
Mar 13, 2014, 3:17:52 PM3/13/14
to pyjs-...@googlegroups.com, Hauke Duden

On Mar 13, 2014, at 9:46 AM, Jim Washington <washing...@gmail.com> wrote:

Give Dart a good look. Don't expect it to work well with IE < 9, or other really old browsers. It has essentially the same quick development turnaround as pyjs with the native client. Aside from the semicolons and curly braces, it feels a lot more like python than javascript. The recent release of Angular.dart makes it really worth investigating.

I thought this was the PyJS list, not the "random suggestions for better JavaScript generators" list?

-glyph

Lex Berezhny

unread,
Mar 13, 2014, 5:31:44 PM3/13/14
to pyjs-...@googlegroups.com
If someone wants to use JavaScript development tools I think it's only honest to recommend that they use JavaScript as the language for development.

The great thing about Python is that you can use IDEs like PyCharm to develop and debug your app. The original poster admits to use PyCharm for server side code but for some bizarre reasons chooses to not for client side.

jQuery is great for JS style development but I think unnecessary if you're building Object Oriented UIs in Python. You can just keep a reference to the DOM elements as object members instead of searching the DOM each time via jQuery.

By using jQuery in pyjs you're defeating most of the advantages of Python.

 - lex

Hauke Duden

unread,
Mar 14, 2014, 3:19:10 AM3/14/14
to pyjs-...@googlegroups.com
The "bizarre reason" of why we want to debug our code integrated with JS is that we want to take advantage of the huge amount of great javascript UI libraries that are out there. Why would we ignore those and have to reimplement a lot of stuff in Python code? Pyjs can already interface with JS libraries, so I think it is reasonable to also want to debug such code.

I do not want this to get into a flame war about the preferred way to do UI development. But I actually think HTML+CSS+JS libraries (if done right) are a better way to implement a web user interface, compared to a pure GWT approach. To me it always seems that GWT ignores a lot of the advantages that a web UI can have and instead tries to bring everything back to the way apps are written on the desktop. This makes sense if you try to bring Java developers to web development (as was the original goal of Googles GWT), but nowadays there are a lot of great web developers out there that know and understand the browser. Combine that with the huge amount of JS libraries out there and you can rapidly develop great UIs.

As to the question of why we don't want to use JS directly: because it leads to hard-to-find bugs (for example, related to its brain dead scoping and handling of closures). I have also seen a tendency for it to produce code that is hard to read and understand for other developers.
Python is the complete opposite. It is very hard to write convoluted code in Python and it is in general a very clean and structured language. That is why we chose it for the server side and it would be great to be able to use it for client side code as well. But without source maps I do not think that can happen (at least not with pyjs).

@Jim Washington: thank you for the suggestion of Dart. It is one of the options we are looking at.
Reply all
Reply to author
Forward
0 new messages