edit: except FUD, can you provide some points on which brython is failling, please ?
x = 0
x += 1
print(0 < impure() <= 1)
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.
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.
x = 1
x = 2
n = 0
while n < 10:
n += 1
g = f()
I'm not sure if the developer is one person or if they wrote the landing page as well, but let's assume it is that same person.
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.
So two line of code is long now?
and walked: "through the valley"' he's and feared: not: "evil"!
# he.and_walked("through the valley").and_feared(not("evil"))!
drop down:' criminal scum!
eat: breakfast' you!
kill: with pistol' maim: blunt object' opponent's check dead:
print person's name's last
print person's last' name # ;)
# print person.name.last
if my's cookies's jar's empty::
print "Cookie Monster, why is the Cookie jar empty?"
why: cookie jar's empty:' cookie monster
# why cookie monster, why? :)
why: cookie jar's empty:' cookie monster's why: "?"
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.
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 approach seems a bit off. I would think it would be better for the Python to be compiled with a pre-processor, not done on the client.
If nothing else, it allows us to explore a new way of constructing web apps and determine whether it is better.
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.
Have any of these been used in production with any success. It seems like PyJS had most traction?
It looks as though, some developers are almost insulted by the idea, that someone tried to replace a language that is so commonly accepted, and that they have worked so hard to master.
This also happens in many other fields of science/technology, but I'm always surprised to see it among programmers who are considered very practical people.
I don't think it is universally true. Myself I know how much I can be taken away by a new technology or knowledge.
Ever met an Enterprise Architect?
I got something of value by tweeking NoScript - knowledge, not just ads. Then again, I'm a yokel.
The technologies have evolved... Why are you trying to keep us in the stone age? Or why do you expect backwards compatibility?
Which is why the HTML5 spec explicitly mentions disabling scripting?
"6.1.2 Enabling and disabling scripting
Scripting is enabled in a browsing context when all of the following conditions are true:
The user agent supports scripting.
The user has not disabled scripting for this browsing context at this time. (User agents may provide users with the option to disable scripting globally, or in a finer-grained manner, e.g. on a per-origin basis.)
The browsing context's active document's active sandboxing flag set does not have its sandboxed scripts browsing context flag set.
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.
Really? Blocking all images can really improve your web experience in some cases.
Of course. that's because their computers haven't been exploited and turned into zombies. It's hard to compete with the traffic that botnets create.
This should really be fixed.
Also "from html import *"? No no no. Never, not even once.
But the comment I replied to was a bit misleading (no doubt unintentionally): it made two quite valid complaints about coding practices, without mentioning that these are only in the demo code.
When I read that comment I thought, "WTF? Brython injects a magic 'ctx' global into your Python code?" It doesn't, so I thought it was worth pointing out that these are just sample code issues that wouldn't affect any code you write in Brython.
Also it's defined at the bottom of the script which, I admit, is a bit weird:
ctx = canvas.getContext("2d")
Perhaps a development plugin for Chrome would allow debugging in python?
edit: looks like if you remove "_en" then you get to the right place, http://www.brython.info/tests/console.html
>>> a = 1/3
>>> a = 1/3
x = 1
for i in range(100):
x = x*2
Not CoffeeScript - I want to be able to write Ruby that manipulates DOM objects.
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.
How is V8 wired into Chrome, or Rhino(?) into Firefox, for example? Is there a great technical barrier to making it possible for the user to install an interpreter of their choice? As I understand the course of the browser's history, it already seems to be moving to an OS-style program (or, in Chrome's case, it has BECOME an OS), so it seems like user-loaded language runtimes OUGHT to be on SOMEONE'S mind. And I'd be surprised if it hasn't already occurred to someone before, I just don't know the history.
Has anyone attempted to write a browser that allowed for such a thing? Or has JS just been the accepted scripting language, and no one has yet tried to push past?
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!
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.
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.
Python is great for some stuff, but let JS do what it does.
an interesting rant from Zed Shaw on this http://vimeo.com/43380467
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.
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.
Issues with the examples:
I got nobody walking on the 3d walker (Chrome on Ubuntu); also it was psychedelic fun clicking into negative territory on the pie chart.
there are open source projects that decompile them to runnable code, the original symbol names are even intact - this means you don't lose the original naming of variables, functions, arguments, etc.
No, browsers cannot magically run python now.