News for hackers. Stuff that matters.
Re:Python Webkit DOM Bindings by Raphael_Amiard on Thursday October 07, 2010 @01:47PM (#1768687)
> that are then restricted to being exclusively used from one of the world's most awkward and obtuse programming languages: javascript.

This is just flamebait. Javascript is just as capable as python, and these days, it's a lot faster too. Sure it has some boring idiosyncrasies, but so has python (one line lambdas are gonna be fun with heavily evented code such as DOM code).

There is room for everything in this world of technology, and i like the idea of this project, but please remove those corrosive and pointless statements from the main project page ..

EDIT : Well, downvoters ? Do you disagree with anything i said ? Because you are particularly silent at the moment, i can't see any of your replies. I stand by anything i said, calling javascript an awkward and obtuse language is flamebait, and implies a very shortsighted view of the technology the very individuals working on the project should know well. If you disagree with me, at least have the courtesy to explain why

Re:Python Webkit DOM Bindings by swannodette on Thursday October 07, 2010 @03:36PM (#1769166)
A counterpoint:

I've programmed JavaScript long enough and on large enough codebases to know that JavaScript leaves much be desired.

Problems:

  1) It's a language that has stood still since November 2000 as far as 
     standards go. 
  2) No sane package system (see #1) *everybody invents their own*
  3) Expression problem, altering prototypes is ridiculously powerful, 
     but it's monkey-patching (see #1)
  4) Browser environment is a ball-and-chain for the language's evolution (see #1)
  5) Lack of rich datatypes (no sets) (see #1)
  6) Object identity based equality (see #1)
  7) Little facility to define new rich datatypes (see #1)
And on and on. The reasons JavaScript isn't totally crippled given these and more issues is that the language is wonderfully small, has first class functions, functions have variable arity, supports apply/call, its functions are modifiable objects, the context of a function call can be rebound, and it has prototypal inheritance. From these powerful bits people have created a many, many libraries that make JavaScript programming downright fun.

But to say that JavaScript is an especially capable PL is, to me at least, a bit of joke- it was clearly designed to run in a very limited scope, in the browser. And remember, this is critique from someone that has used JavaScript in large UI projects day in and day out since 2005 (before jQuery!).

Re:Python Webkit DOM Bindings by Raphael_Amiard on Thursday October 07, 2010 @05:06PM (#1769534)
I mostly agree with your critique of javascript. I do not actually agree with 7. You do have the possibility of defining any datatypes you'd ever need. You just don't have the possibility of defining literal support for them.

All your other points are right on, but i feel that most are more the result of the history and constraints of javascript than anything else.

#3 is a language problem but is also the most arguable of your points. Ruby allows monkey patches and is one of the most appreciated languages in existence today. Also viable approachs to give the power of monkey patching without the drawbacks are just being thought today. Protocols in clojure looks good but still need the appreciation of time i'd say.

#6 is stupid i agree

Every other point are more the result of the history, and most importantly of the use case of javascript: - No sane package system sucks but a package system is hard to get right in a file based browser environnement. - Browser environnement, well yes, but that's precisely what we are talking about, you can't really say it's a problem, it's the very reason we're using javascript in the first place - Lack of rich datatypes is really bad. The lack of sets, but also of propers hash maps sucks. But more generally javascript lacks a proper standard library. Something that python definitely has. But it's also definitely harder to get right in a browser environnement, when you have got to ensure support from every browser on every platform.

But anyway, thanks for a proper critique of javascript.

Re:Python Webkit DOM Bindings by pjscott on Thursday October 07, 2010 @08:56PM (#1770161)
The lack of sets as a data type at the language level is a serious problem with JS. Most languages which implement sets as a library make some assumption about the elements: they're ordered, for example, or they all have a unique string serialization. If you want to make a set data type in JavaScript, the language doesn't give you any of those assumptions. You might end up just using linear search of unordered arrays. (This is actually very fast for small sets, but still.)

I wrote some more about this here:

http://finger-tree.blogspot.com/2010/09/sets-in-javascript.h...

And here is a library that offers sets in JS:

http://github.com/PeterScott/simplesets-nodejs

If you're using Node.js, you can get it with npm. It could be adapted to the browser pretty easily. This is what I use, and it makes my life so much easier.

Re:Python Webkit DOM Bindings by loewenskind on Friday October 08, 2010 @07:40AM (#1771280)
>Also viable approachs to give the power of monkey patching without the drawbacks are just being thought today.

No, they're actively being used: http://msdn.microsoft.com/en-us/library/bb383977.aspx

Re:Python Webkit DOM Bindings by othermaciej on Thursday October 07, 2010 @06:37PM (#1769804)
> 1) It's a language that has stood still since November 2000 as far as standards go.

That used to be true, but ECMA-262 5th edition was just published in December, 2009: http://www.ecma-international.org/publications/standards/Ecm...

And the next version is under active develpment; it will likely address many of your other points.

Re:Python Webkit DOM Bindings by rdtsc on Thursday October 07, 2010 @03:50PM (#1769236)
Your reply is just countfamebait and just as factually lacking as the article, that's probably why you are getting downvoted.

Here are a couple I can think of :

  * no namespaces and no  packaging system

  * conversion between types (1+"5"?)

  * object prototypes are unusual 

  * ignoring extra function arguments

EDIT: a couple more I thought of:

  * if ( a=b )  will assign a the value of b, in Python it's a syntax error
  
  * implicit semicolons inserted in place of linebreaks

  * inconsistent type conversion -- as in a switch statement 

  * cannot use interger keys in dictionaries
Re:Python Webkit DOM Bindings by shawndumas on Thursday October 07, 2010 @02:52PM (#1768978)
Python + Javascript = CoffeeScript[1]

-----

[1]: http://jashkenas.github.com/coffee-script/

Re:Python Webkit DOM Bindings by Raphael_Amiard on Thursday October 07, 2010 @03:06PM (#1769038)
I know coffeescript, and i use it for my main project, in parallel with Django. The project is particularly heavy on the client side.

I like having most of the conveniences of python, like list comprehensions, and it has a better syntax than javascript (i hate javascript syntax).

Also, coffeescript has some things that python hasn't, like a sane syntax for functions and lambdas, and some more (string interpolation is really neat when you're dealing with mostly text)

It does make things harder for debugging though, but i consider it a fair tradeoff.

Re:Python Webkit DOM Bindings by pjscott on Thursday October 07, 2010 @08:58PM (#1770171)
I like coffeescript, but it is definitely a very young language. When I installed it, I had to modify the emacs editing mode because the language syntax had changed recently.

I still use it, though, because it's just so much nicer than JavaScript in every other way.

Re:Python Webkit DOM Bindings by macco on Thursday October 07, 2010 @02:29PM (#1768884)
You are right, everybody should use the tool, he want's to use. The more interesting part of the article is having a alternative to Javascript in the DOM.
Re:Python Webkit DOM Bindings by endtime on Thursday October 07, 2010 @02:40PM (#1768929)
>and these days, it's a lot faster too.

I'd love to see some data on this point.

Re:Python Webkit DOM Bindings by Raphael_Amiard on Thursday October 07, 2010 @02:58PM (#1769010)
Is this really that little known ? Well in this case, here you have it : http://shootout.alioth.debian.org/u32/benchmark.php?test=all...

You can see it's on average 7 times faster than CPython. You can check with pypy (which is the fastest python implementation at the moment), it's basically the same deal.

Not only that, but the benchmark where CPython blows Javascript out of the water, uses gmpy, where Javascript uses a native javascript implementation. But python in the browser probably wouldn't have access to gmpy, unless javascript has access to a similar binding

Re:Python Webkit DOM Bindings by juiceandjuice on Thursday October 07, 2010 @10:12PM (#1770326)
Implement the algorithms in C/C++ and use ctypes with Python, then CPython wins :D

I've been using Pyjamas a lot actually. It works out good because of caching, but it's pretty heavy handed otherwise. The nice thing is being able to program everything in Python, pyjamas on the client and python stuff with mod_wsgi or mod_python on the server side (or Django, or whatever)

Re:Python Webkit DOM Bindings by endtime on Thursday October 07, 2010 @03:36PM (#1769165)
Ah, thanks. Didn't know about that site. Interestingly, the memory usage is almost always much lower in Python...I wonder how Python would hold up with psyco.