Live data from Hacker News

A Python 3 implementation for client-side web programming

brython.info

61–70 of 120 posts

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

#61

The way they position Brython is pretty off-putting and kind of confuses the issue. CoffeeScript page: "CoffeeScript is a little language that compiles into JavaScript." Brython page: "Brython is designed to replace Javascript as the scripting language for the Web." Maybe that's the end goal, but the reality is far from it. Of course JS is still required, and of course the Python gets compiled into JS. Finally, the a…

The argument for compiling the Python with the pre-processor seems roughly analogous to traditional arguments for compiling rather than interpreting languages - i.e. how many times the conversion from source code to machine instructions must be done. One isn't necessarily better than the other - sometimes human generated python source code in the browser may be more useful than machine generated javascript. If nothin…

I'm not sure what the commenter meant, and perhaps a silly comment to make, but doesn't python's strong indentation make it harder to simply include on a webpage? proxies, ad filters, and other optimizers might break the lines in unexpected places.

I guess it can be solved by gziping the file, or base64 encoding it. But this is also an argument (albeit trivial or weak) for compiling it on the server rather than the client.

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

#62

Earlier quoted context omitted.

Noscript seems like a fetish with some people and almost always it seems they expect the rest of us to accomodate their fetish.

You can safely ignore them. They are less than 2% of Internet traffic and they know how to turn js back on.

They leave a lot more than 2% of the comments, though.

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

#63

Why the hate on JavaScript? I know it's not the most elegant language in the world, but do we really need this? Instead of a program "x" run in "y", how about we just expand our horizons a bit and learn another language with different paradigms? Python is great for some stuff, but let JS do what it does.

I don't hate javascript, and there are good arguments to learn new languages. Absolutely. But it's a bit of a my-way-or-the-highway with client-side web.

I wish I could have a choice of the language to run in the browser, and still do all the things javascript can. Having some kind of a bytecode virtual machine on the browser, that many different languages can compile to, might be the best solution.

an interesting rant from Zed Shaw on this http://vimeo.com/43380467

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

#64

Earlier quoted context omitted.

Noscript allows you to turn the Javascript off. Requiring javascript to see any content at all is a little absurd.

You could also block all images and CSS; that would make for a really terrible web experience though. Why limit yourself intentionally? As a web developer I'm not going to accommodate for users that intentionally turn off features that we've been fighting for years to standardize on.

I don't know. I think a lot of pages would be better with much less "design". You know, pages like HN where the text content is the most interesting part. Or most blogs.

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

#65

It's too bad it didn't replace it on this page. Without JavaScript, this page is blank.

It's not the first time I had to turn on JavaScript to view a page. On the other hand, it is the first time that I have ever done so and discovered a totally logical reason for having to do so. I got something of value by tweeking NoScript - knowledge, not just ads. Then again, I'm a yokel.

I tried it and didn't get much value out of it: What appeared was mostly just JavaScript that should have been there all along, had the page not been broken. That animated clock? Yeah, well, I can do without it.

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

#66
post #9

Link to console demo from that page is broken, sadly. edit: looks like if you remove "_en" then you get to the right place, http://www.brython.info/tests/console.html Looks like pyjs, in that it has python syntax but JavaScript semantics, for example numbers turn into doubles here (but should be arbitrary-precision ints in Python).

Well, python 2.7:

    >>> a = 1/3
    >>> type(a)
    int
python 3.2

    >>> a = 1/3
    >>> type(a)
    
brython:

    print(type(1/3))
    

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

#67

Why the hate on JavaScript? I know it's not the most elegant language in the world, but do we really need this? Instead of a program "x" run in "y", how about we just expand our horizons a bit and learn another language with different paradigms? Python is great for some stuff, but let JS do what it does.

I don't hate javascript, and there are good arguments to learn new languages. Absolutely. But it's a bit of a my-way-or-the-highway with client-side web. I wish I could have a choice of the language to run in the browser, and still do all the things javascript can. Having some kind of a bytecode virtual machine on the browser, that many different languages can compile to, might be the best solution. an interesting ra…

The issue with web (although this could be expanded to apply to most languages) is where it's used/interpreted. Browsers aren't a quickly changing environment (haha, IE 6). It takes a few years to adopt the latest and greatest. Shit, it took nearly a decade for us to see native curved corners (border-radius).

Again, not that I don't agree, it's just hard to stay up to date with the greatest while still trying to support outdated tech like html tables.

The W3C is the 'authority', but is really at the hands of the major browser manufacturers. Implementing an interpreted version of Python sounds great, but is it worth the time and effort? Will it increase my productivity or compliance compared to JavaScript? As of now, nope.

I'm happy writing bastardized JS (not that my code is bastardized, rather that's just the language [took way too long to understand == vs ===]) for the web right now. Every day new tools and frameworks are developed to make it easier, and I just don't see the advantage and overhead just to write a weird version of python that compiles into JS.

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

#68

Earlier quoted context omitted.

> Someone has implemented Python in JavaScript. This isn't really true. This is far from a Python implementation. At best you could call it a Python-esque syntax to Javascript translator. And that's perhaps still useful. But to call this a Python implementation is quite simply a lie.

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 ?

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 isn't exactly something you'd usually see in actual code (heck, it's probably even bad practice in most situations) BUT the point here is that while most of python might be compatible with this, there exists some inconsistencies that causes one's previously working python code to fail (and these bugs would probably be very difficult to trace). Of course, Brython is still young and has time to hopefully fix these issues. (In fact, this is the second time I've tried this project. Back then they didn't even have the chaining feature working, so it's nice that they are making progress.)

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

#69
Being a front-end developer myself, I find such an idea a complete waste for people like me. We have put in a lot our time understanding how JS functions and most of the interactive interfaces you come across use jQuery. If Brython were to become a standard, then would you be writing a new JS library that would allow me work with DOM faster and in a better fashion?

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

#70
post #30

I can't believe all the negative comments here. Someone has implemented Python in JavaScript. I personally think that is incredible.

Agreed! I'm all for constructive criticism, but some of the comments in this thread are unnecessarily negative. This project looks really cool!
Post reply on HN