11 ms·
Python Webkit DOM Bindings
- TimothyFitz 16y agoThis would be more of a "Big Deal" if it hadn't been available for many years in Mozilla via PyXPCOM: https://developer.mozilla.org/en/PyDOM https://developer.mozilla.org/en/PyDOM That being said, there's definitely room for competition. PyXPCOM is far from a joy to work with.
- Raphael_Amiard 16y ago> 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
- macco 16y agoYou 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.
- endtime 16y ago>and these days, it's a lot faster too. I'd love to see some data on this point.
- Raphael_Amiard 16y agoIs this really that little known ? Well in this case, here you have it : http://shootout.alioth.debian.org/u32/benchmark.php?test=all&lang=python&lang2=v8 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
- endtime 16y agoAh, 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.
- deleted 16y ago[deleted]
- juiceandjuice 16y agoImplement 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)
- deleted 16y ago[deleted]
- shawndumas 16y agoPython + Javascript = CoffeeScript[1] ----- [1]: http://jashkenas.github.com/coffee-script/ http://jashkenas.github.com/coffee-script/
- Raphael_Amiard 16y agoI 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.
- pjscott 16y agoI 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.
- swannodette 16y agoA 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!).
- Raphael_Amiard 16y agoI 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.
- rdtsc 16y agoYour 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
- apl 16y agoI'm willing to bet that a solid 90% of all people desperately yearning for JVM (or similar) "in the browser" as well as stuff like these DOM bindings don't realize that JS is a powerful, decent, fast language. These days, at least. Instead of adding semi-functional alternatives, the web development community should focus on providing reasonable JS teaching and learning opportunities. Mozilla's JS Guide is surprisingly well hidden, a majority of JavaScript tutorials are shockingly inadequate: there's a lot of potential there. JS is neither awkward nor obtuse. Its shortcomings are exaggerated while its beauty is still a secret to many; that sucks.
- zokier 16y agoJS might be great language, but still it's only one language, and it doesn't fit everybody. Allowing more languages in client-side web code enables more people to create great web apps.
- aarongough 16y agoThese days Javascript is plenty fast enough to achieve this goal by simply writing other languages over the top of it... There are some examples of this happening already, HotRuby for instance.
- blacksmythe 16y agoBeing able to program on the client-side and server-side with the same language has some advantages. In addition, I imagine the number of people fluent in Python significantly exceeds those presently fluent in Javascript (not arguing against learning more languages, but a lot of people don't want to).
- davidbalbert 16y agoI'm a big fan of alternative client side languages (would love to see a ruby version of this project). The problem is wide spread adoption will take forever. You wouldn't be able to use another language in the browser until all vendors ship it and those browser versions become baseline. What would be cool is if browser vendors implemented client side VMs with a standard bytecode. Then new languages could be developed and delivered over time.
- zoomzoom 16y agoThis is the most critical point in the thread, it seems to me!
- barnaby 16y agoJavascript is a great, powerful and awesome language. Python is a great, powerful and awesome language. Birds of a feather flock together. I hope EVERY rendering engine gets Python support.
- jorangreef 16y agoIt's interesting that the author is motivated by WebKit being "restricted to being exclusively used from one of the world's most awkward and obtuse programming languages: javascript." I would hope that the leadership of such a project would at least demonstrate some kind of understanding of the language binding they wish to replace, objectively recognizing its contributions and shortcomings, with the professionalism to resist resorting to phrases like "world's most awkward or obtuse language".
- jeffesp 16y agoI have often thought that lua would make the perfect addition for client side scripting. There are some annoying bits of lua, but it seems like a compelling alternative to me.
- robwgibbons 16y agoThis article lost me when it called JavaScript awkward and obtuse. Sounds to me like they have little experience with JavaScript.
- macco 16y agoThe author is the project lead of the pyjamas web framework (http://pyjs.org http://pyjs.org). He knows some Javascript :). But he hates programming with html, css and Javascript.
- PostOnce 16y agoTo me, a page of Python is supremely readable. It's concise and perfectly understandable. A page of javascript looks like someone dropped a box of scrabble tiles. This is just me, a bad programmer who hasn't gone to college yet, who only knows one language well enough to make anything useful, and who has resisted learning javascript all this time. I knew someone would do something like this eventually, and now they have. And now I shall make something truly beautiful.