|
1 |
| -<p> |
2 |
| -There are so many things you should be doing to determine the cause |
3 |
| -of "it ain't working" it's almost unreal. But before answering |
4 |
| -in more detail, it's important that you know what pyjamas is and |
5 |
| -is not. First off: pyjamas is a compiler, not a debugger. It's the |
6 |
| -equivalent of "gcc". Actually, if you know how gcc works, pyjsbuild |
7 |
| -is the equivalent of "gcc" and pyjscompile is the equivalent of, |
8 |
| -for example, "/usr/lib/gcc/x86_64-linux-gnu/4.3.3/cc1". In other |
9 |
| -words, gcc and pyjsbuild are the general-purpose "front-ends", |
10 |
| -and cc1 and pyjscompile are the actual nitty-gritty compilers. |
11 |
| -</p> |
12 |
| -<p> |
13 |
| -You <i>need</i> to be aware of this because you cannot expect pyjamas, |
14 |
| -a specialist compiler, to also take on the task of being the debugger, |
15 |
| -or to incorporate the tasks performed by tools such as pylint, or to be |
16 |
| -the virtual machine under which the javascript executes, or to be |
17 |
| -a javascript code-compressor, or to do any other task <i>other</i> than |
18 |
| -actual compiling. |
19 |
| -</p> |
20 |
| -<p> |
21 |
| -With that in mind, here are some things that you can do: |
22 |
| -<ul> |
23 |
| -<li /> Add the -d option to the build process: pyjsbuild -d {myapp.py}. |
24 |
| - It's the equivalent of adding "-g" to gcc. |
25 |
| - -d will enable a horrendous amount of extra output in the |
26 |
| - application, including actually placing the line numbers and |
27 |
| - module name into the javascript output, for each and every single |
28 |
| - line of code being executed (!) Also, a stacktrace will be |
29 |
| - recorded so that if there are any exceptions in your application, |
30 |
| - an Alert will come up with the full stacktrace (just like in |
31 |
| - "real" python applications). |
32 |
| -<li /> Watch the Javascript Console. |
33 |
| -<li /> Watch the Javascript Console. |
34 |
| -<li /> Watch the Javascript Console. |
35 |
| -<li /> Did we say, and emphasise enough, that you need to watch the Javascript |
36 |
| - Console? |
37 |
| -<li /> You need to watch the javascript console. |
38 |
| -<li /> You need to watch the javascript console because that is where |
39 |
| - runtime javascript errors are shown. Most web applications are written |
40 |
| - so badly that the errors are usually silently ignored by browsers, |
41 |
| - so as not to frighten users. As a developer, you cannot ignore |
42 |
| - the errors (not if you expect to actually be able to write an app, |
43 |
| - that is...) |
44 |
| -<li /> If you are using Firefox, install <i>both</i> Venkman <b>and</b> |
45 |
| - Firebug. You will need them both. Use them. get used to using them. |
46 |
| -<li /> If you are using IE, install the Script Debugger. use it. |
47 |
| -<li /> If you were debugging a c or c++ application, you would be using gdb. |
48 |
| - The javascript console, Firebug, Venkman, the Microsoft Script Debugger: |
49 |
| - these are all the equivalent of gdb. use them. You will suck at |
50 |
| - being a Web developer if you do not use these tools. |
51 |
| -<li /> Install <a href="http://pyjd.org">Pyjamas Desktop</a> and run your |
52 |
| - application under that. |
53 |
| -</ul> |
54 |
| -</p> |
55 |
| -<p> |
56 |
| -Overall, then, it's important to remember that pyjamas is a compiler, |
57 |
| -not an interpreter, not a debugger, syntax checker or anything else other |
58 |
| -than a compiler. This may be a bit of a shock if you are used to the |
59 |
| -python interpreter throwing helpful stack traces for you - which is what |
60 |
| -Pyjamas-Desktop is there for: it actually runs Pyjamas applications |
61 |
| -<i>as real python</i>, not as javascript. |
62 |
| - |
63 |
| -</p> |
64 |
| - |
| 1 | +<p> |
| 2 | +There are so many things you should be doing to determine the cause |
| 3 | +of "it ain't working" it's almost unreal. But before answering |
| 4 | +in more detail, it's important that you know what pyjamas is and |
| 5 | +is not. First off: pyjamas is a compiler, not a debugger. It's the |
| 6 | +equivalent of "gcc". Actually, if you know how gcc works, pyjsbuild |
| 7 | +is the equivalent of "gcc" and pyjscompile is the equivalent of, |
| 8 | +for example, "/usr/lib/gcc/x86_64-linux-gnu/4.3.3/cc1". In other |
| 9 | +words, gcc and pyjsbuild are the general-purpose "front-ends", |
| 10 | +and cc1 and pyjscompile are the actual nitty-gritty compilers. |
| 11 | +</p> |
| 12 | +<p> |
| 13 | +You <i>need</i> to be aware of this because you cannot expect pyjamas, |
| 14 | +a specialist compiler, to also take on the task of being the debugger, |
| 15 | +or to incorporate the tasks performed by tools such as pylint, or to be |
| 16 | +the virtual machine under which the javascript executes, or to be |
| 17 | +a javascript code-compressor, or to do any other task <i>other</i> than |
| 18 | +actual compiling. |
| 19 | +</p> |
| 20 | +<p> |
| 21 | +With that in mind, here are some things that you can do: |
| 22 | +<ul> |
| 23 | +<li /> Add the -d option to the build process: pyjsbuild -d {myapp.py}. |
| 24 | + It's the equivalent of adding "-g" to gcc. |
| 25 | + -d will enable a horrendous amount of extra output in the |
| 26 | + application, including actually placing the line numbers and |
| 27 | + module name into the javascript output, for each and every single |
| 28 | + line of code being executed (!) Also, a stacktrace will be |
| 29 | + recorded so that if there are any exceptions in your application, |
| 30 | + an Alert will come up with the full stacktrace (just like in |
| 31 | + "real" python applications). |
| 32 | +<li /> Watch the Javascript Console. |
| 33 | +<li /> Watch the Javascript Console. |
| 34 | +<li /> Watch the Javascript Console. |
| 35 | +<li /> Did we say, and emphasise enough, that you need to watch the Javascript |
| 36 | + Console? |
| 37 | +<li /> You need to watch the javascript console. |
| 38 | +<li /> You need to watch the javascript console because that is where |
| 39 | + runtime javascript errors are shown. Most web applications are written |
| 40 | + so badly that the errors are usually silently ignored by browsers, |
| 41 | + so as not to frighten users. As a developer, you cannot ignore |
| 42 | + the errors (not if you expect to actually be able to write an app, |
| 43 | + that is...) |
| 44 | +<li /> If you are using Firefox, install <i>both</i> Venkman <b>and</b> |
| 45 | + Firebug. You will need them both. Use them. get used to using them. |
| 46 | +<li /> If you are using IE, install the Script Debugger. use it. |
| 47 | +<li /> If you were debugging a c or c++ application, you would be using gdb. |
| 48 | + The javascript console, Firebug, Venkman, the Microsoft Script Debugger: |
| 49 | + these are all the equivalent of gdb. use them. You will suck at |
| 50 | + being a Web developer if you do not use these tools. |
| 51 | +<li /> Install Pyjamas Desktop (part of pyjamas)</a> and run your |
| 52 | + application under that. |
| 53 | +</ul> |
| 54 | +</p> |
| 55 | +<p> |
| 56 | +Overall, then, it's important to remember that pyjamas is a compiler, |
| 57 | +not an interpreter, not a debugger, syntax checker or anything else other |
| 58 | +than a compiler. This may be a bit of a shock if you are used to the |
| 59 | +python interpreter throwing helpful stack traces for you - which is what |
| 60 | +Pyjamas-Desktop is there for: it actually runs Pyjamas applications |
| 61 | +<i>as real python</i>, not as javascript. |
| 62 | + |
| 63 | +</p> |
| 64 | +
|
0 commit comments