You can check out the web demo here: PyJamas KitchenSink.
I admit that I haven't yet had the time to play much with PyJamas, but I have a few theoretical reservations.
I don't think its hard to see why GWT has potential. JavaScript does have a somewhat deserved bad reputation. I learned to hate it back in 1998-2000 when I was a full time web developer working on sites that had to support all major browsers and lost a significant amount of hair while struggling with browser incompatibilities. Yes, times have changed and JavaScript/EcmaScript has come a long way, but it is still a pain in the neck when it comes to development and especially debugging. And as we all know, developers spend most of their time debugging.
Here's where Java comes in. It's strongly and statically typed, so the compiler can check all kinds of stupid mistakes. I notice how annoying it is when I switch to a dynamic language from Java that I don't find out about these until I actually run the code:
- wrong type or number of arguments when calling a method
- calling a non-existing method
- referring to a non-existing class
- missing imports
- etc.
Since dynamic languages don't have the luxury of the compiler catching these simple problems, there is a much stronger motivation to write an extensive unit test harness, so that these basic errors don't eat up too much of the developer's interactive debugging time. Having a test harness is a good thing, but having to write tests for trivial stuff that the compiler could check is, well unproductive.
Now its a matter of debate exactly how much time is saved or wasted by declaring your types and relying on the compiler to do these checks or not declaring them and creating a test harness and relying on shorter turnaround times instead.
Going back to PyJamas, I believe the problem is that Python and JavaScript are not different enough to have a significant productivity gain when you're writing and debugging Python code vs. JavaScript. All the silly mistakes will have to be caught at runtime.
I'm still looking forward to trying it out though since there is a good chance that I'm completely missing the point. :)
3 comments:
"Now its a matter of debate exactly how much time is saved or wasted by declaring your types and relying on the compiler to do these checks or not declaring them and creating a test harness and relying on shorter turnaround times instead."
Or not declaring your types
(just a tiny little bit) and relying on
the compiler to figure everything out at
compile time. Called type inference and been around for decades. Eventually,
things will converge towards type inference (I think even in C++ they
are planning on using the `auto' keyword
for type inference) it will take a while ;) Remember Ada and generics. It took Java a mere 20 years to arrive where Ada was at 1985. Another 20 years and we can expect to see limited type inference in mainstream languages, at that time, a technique already 50 years old.
Type inference in Java? Maybe for local variables. The specificity of the types used in method signatures is a conscious design decision. Encapsulation, information hiding, interface stability.
Even with my bias as the author of pyjamas, I agree that Java to Javascript provides certain benefits that Python to Javascript does not.
However, if you are already a Python programmer, pyjamas provides a way of working in a familiar environment, reusing your existing code, developing both client-side and server-side code in the same language, etc.
Post a Comment