Live data from Hacker News

A Python 3 implementation for client-side web programming

brython.info

101–110 of 120 posts

Re: A Python 3 implementation for client-side web programming

#101

I love this. I wish someone would do this for Ruby. Not CoffeeScript - I want to be able to write Ruby that manipulates DOM objects.

I dream of a day where I can choose what language to script a page in, using a native implementation, rather than being forced to use javascript.

Javascript is great, but I'd rather work in Python and have it be actual Python, not an interpreter written in an interpreted language.

Re: A Python 3 implementation for client-side web programming

#102
post #82

Earlier quoted context omitted.

Not that I have anything against Brython (which imo is a cool project, although I'm not so sure if it's practical yet), but since you asked for it, here's an example where it does differ from python: x = 0 def impure(): global x x += 1 return x print(0 In python, impure() would only be evaluated once returning True, but Brython's chaining evaluates it twice, and so it returns False instead. Of course, this example is…

Nifty example, but this is why we have integration test suites. PyPy, jython, ironpython etc all had/have incompatibilities as the language evolves and as they work out the quirks in their respective runtimes. This isn't compatible with cpython (afaik, none of the other runtimes have ever been COMPLETELY compatible, but this is much further off), but hell, it's pretty awesome. As an aside, I'd shoot anyone who did th…

Well... if brython is running the CPython integration tests to aim for proper compatibility then fair enough.

It is a cool project, whichever one of these python in javasript things is to become successful needs to aim for the same level of compatibility as say Jython or IronPython - yes it would take a long time, but this sort of thing is needed to be a useful implementation.

Re: A Python 3 implementation for client-side web programming

#103

Earlier quoted context omitted.

This is not a translator but an interpreter, there is no compilation. edit: except FUD, can you provide some points on which brython is failling, please ?

There's no support for metaclasses. type is missing entirely. nonlocal doesn't work. docstrings and some other double underscore names are just missing (__class__, __name__, etc.). Unicode literals don't work. dis obviously won't work since there isn't a bytecode compilation step. Scoping, like in the following code, behaves improperly: x = 1 def test(): print(x) x = 2

I wonder if it's worth adding some failing tests to the project about these..

Re: A Python 3 implementation for client-side web programming

#104

I love python and this is awesome. But I HATE magic global objects. 'ctx' seems to be at the heart of everything but is never explicitly passed into the scope or imported. This should really be fixed. Also "from html import *"? No no no. Never, not even once.

"ctx" is a very common name for the "context" with which you work when doing stuff in . There's nothing magical about it.

Also it's defined at the bottom of the script which, I admit, is a bit weird:

    if hasattr(canvas,'getContext'):
        ctx = canvas.getContext("2d")

from html import * looks bad, I agree, but I believe they did that to allow us to play with their toy from the console.

Re: A Python 3 implementation for client-side web programming

#105
post #99

Earlier quoted context omitted.

Here's eight options for you. Enjoy: https://github.com/jashkenas/coffee-script/wiki/List-of-lang...

Last time i checked it, it contained links to old/dead projects, which seems still the case. Anyway AFAIK there is no such a similar thing to Brython for ruby, and by that I mean a ruby implementation specifically written in JS and optimized to deal with DOM and browser environment in general (if anybody knows about something like that or is working on it please inform me). It'd be such a great thing to have!

opal is very much still alive: http://opalrb.org

Most of the work in the recent weeks has been improving the ruby js bridge so that calling js methods/functions from ruby is possible.

Re: A Python 3 implementation for client-side web programming

#106
post #103

Earlier quoted context omitted.

There's no support for metaclasses. type is missing entirely. nonlocal doesn't work. docstrings and some other double underscore names are just missing (__class__, __name__, etc.). Unicode literals don't work. dis obviously won't work since there isn't a bytecode compilation step. Scoping, like in the following code, behaves improperly: x = 1 def test(): print(x) x = 2

I wonder if it's worth adding some failing tests to the project about these..

Things like this are why projects like pypy use CPython's test suite whereever the behavior is not CPython specific, and have contributed many tests back to CPython as well. These aren't minutia of the language, they are well understood and tested features that most moderately sized software projects are likely to rely on at some point.

Re: A Python 3 implementation for client-side web programming

#107
post #26

Earlier quoted context omitted.

Javascript is a prerequisite of the modern web. Refusing to accept that is absurd.

First of all, he was commenting about this page not displaying ANY content at all. At the very least there should be a noscript tag to tell the user to enable JS. Second, I whitelist sites for javascript. There's nothing absurd about that. Honestly, I can't believe people run any and all JS on every random page they land on.

> First of all, he was commenting about this page not displaying ANY content at all. At the very least there should be a noscript tag to tell the user to enable JS.

For most sites that sounds like a good idea, but this is a Javascript project. The number of people interested in a Javscript framework that don't have Javascript enabled and are still befuddled when things don't work correctly must be vanishingly small.

Re: A Python 3 implementation for client-side web programming

#108

I love this. I wish someone would do this for Ruby. Not CoffeeScript - I want to be able to write Ruby that manipulates DOM objects.

Here's eight options for you. Enjoy: https://github.com/jashkenas/coffee-script/wiki/List-of-lang...

Thanks. Btw, I have nothing against Coffeescript per se. I just prefer Ruby :)

Re: A Python 3 implementation for client-side web programming

#109
post #40
post #28

Earlier quoted context omitted.

>Javascript is a prerequisite of the modern web. Citation needed.

JavaScript is like the electricity of the web. If you disable it, it's like walking around the real world with an "emp field", sure some things will still work, but it's kind of dumb to expect the modern technologies to work without their main food source. The technologies have evolved... Why are you trying to keep us in the stone age? Or why do you expect backwards compatibility?

the http protocol is the electricity of the web , not javascript. Javascript is more like the home automation of the web and you sure can live without it. IT is stupid to offer 0 content when javascript is turned off. Some people might check the content on tablets,phones or devices that dont have javascript turned on by default.

Re: A Python 3 implementation for client-side web programming

#110
post #74
post #59

Earlier quoted context omitted.

Obligatory https://www.destroyallsoftware.com/talks/wat

Wow. I had never seen that. There are literally tears streaming down my face I was laughing so hard.

I enjoyed it more this time than I did when I last saw it, perhaps because I was more familiar with the showcased peculiarities last time (the theme is garbage in, garbage out).
Post reply on HN