Live data from Hacker News

A Python 3 implementation for client-side web programming

brython.info

81–90 of 120 posts

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

#81
post #80

I don't mean to rain on anyone's parade, but how come opalrb hasn't gotten this much attention on HN (although it is a bit different from this)? There seems to be this gah a fucking ruby developer/thing, again motif going on around HN (was hurtful at first) that makes it harder to discover cool and new ruby things! P.S: although Python is nit my goto language, I still find this brilliant!

Opalrb has been on the HN frontpage. Why is there always someone whining about their perception of HN user sentiments lately? There's even a post whining about the user sentiments in the comments of this post on the frontpage now.

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

#82

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 ?

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 that ^^ without a pretty amazing explaination.

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

#83

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 approach and the phrasing seems exactly right to me and not at all off-putting.

The goal of Brython is to replace javascript on the web, seems straightforward right? The way they go about it is to implement a compiler in javascript, and use that to bootstrap a python in the browser community. Seems like that is much easier than convincing Chrome/Firefox/IE to include a python compiler in their browser.

How would Brython replace javascript if it were precompiled on the server?

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

#84
post #39

Earlier quoted context omitted.

That's a silly complaint. Doesn't every language designer feel that their product is better than the thing it desires to replace?

A better question: Is python really any better than JavaScript? Sure, it has advantages here and there. But there are things I like about JavaScript that are better than python. For example, having anonymous functions that are more than a single expression inside a lambda. Yes, I know you can declare a function inside another and you get a closure. But, JavaScript's syntax is just nicer.

In all my Python years, I have never needed to write a long anonymous function. I consider it a bit of a code smell.

This isn't to say it's wrong to do in JS, just that the patterns in Python are different so you don't use this in practice.

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

#85
post #30

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

I really do hope this (or something like it) takes off. More choice in languages is better, and JS has been the only option for too long.

It would be amazing if browsers added interpreters natively, then we could check for a native interpreter and fall back to loading a JS one like brython.

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

#86

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 ?

That's not right, it is a translator/compiler. It simply translates a python code string into a JS code string, and then calls `eval()` on the JS code string. The `eval()` step can optionally be skipped so that you can precompile. This is much easier to implement than an interpreter anyway.

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

#87

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.

>You could also block all images and CSS; that would make for a really terrible web experience though.

The other day I was on a really spotty internet connection, lots and lots of packet loss. External CSS almost never loaded, images certainly never did. For some sites it was a pain, but for most it was bearable. Often it was an improvement, using a default font at a decent size right to the edge of my browser window. Lovely.

Of course, my browser always expected the extra crap to come down the wire, so it waited forever before actually displaying anything. If I wanted to read something in any reasonable amount of time I had to wait until the HTML was downloaded (i.e., when the title bar said something nice) then disconnect from the internet. This made my browser say, "Fuck it, let's try our best." Hitting "stop" resulted in a blank page...

I know I'm not the typical audience, but for me browsing with wget would have been a better experience.

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

#89

I don't get the point why should I use Python to run Javascript. JS has been in use around the web for a long time now and I don't see the need why should I go about using Python for the very same? Doesn't one language has a purpose of it's own? If it wasn't the case, then people would have worked on creating a unified language for all our needs.

Nobody says you should, it's purely a personal preference :)

Doesn't one language has a purpose of it's own?

Usually no, most domains are served by more than one language, otherwise we would all be using Perl to write server-side web applications.

While it's debatable whether JavaScript is particularly well suited for client-side web code, the fact is that having only one language of choice is mostly an historical accident.

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

#90
post #39

Earlier quoted context omitted.

A better question: Is python really any better than JavaScript? Sure, it has advantages here and there. But there are things I like about JavaScript that are better than python. For example, having anonymous functions that are more than a single expression inside a lambda. Yes, I know you can declare a function inside another and you get a closure. But, JavaScript's syntax is just nicer.

In all my Python years, I have never needed to write a long anonymous function. I consider it a bit of a code smell. This isn't to say it's wrong to do in JS, just that the patterns in Python are different so you don't use this in practice.

I have never needed to write a long anonymous function.

So two line of code is long now?

Post reply on HN