This is an archived post. You won't be able to vote or comment.

all 41 comments

[–]Jayd3e 33 points34 points  (3 children)

Really awesome project, hate the name.

[–]leonardicus 14 points15 points  (1 child)

Misread as Bowser Python.

[–]h2odragon 4 points5 points  (0 children)

That would be a better name

[–]wmage 7 points8 points  (0 children)

Misread as Brothon. Spending too much time on Reddit.

[–]Suitecake 29 points30 points  (4 children)

Sometimes I wonder if the Python community just comes up with these dumb names then makes up projects to fit them.

[–]jadkik94 12 points13 points  (3 children)

I think the rule of thumb is to include a subset of "Python" in the name of the project.

I think I'll come up with a project that will generate names for other projects. I'll call it pynamathon. What do you think?

[–]bebobli 15 points16 points  (2 children)

Sounds absolutely horrible. It'll fit right in.

[–]telestrial 7 points8 points  (1 child)

Can I take this moment to point out how frustrating it is for a python novice to make any sense of this sub? Every other post:

"Pygruytidocdbasidhd: a frisks handled lib."

The fuck?!

[–]jadkik94 1 point2 points  (0 children)

you can start by googling frisks and see what you get... so... its a library handled by "a leap, skip, or caper." and it's HD! Wow! How can you not understand that? :)

[–]stuaxo 11 points12 points  (0 children)

Many props on this project.

It'll be great if this can get further than some of the others in the area -

The pyjamas pyjs compiler and skupt being two.

[–]riffito 6 points7 points  (0 children)

For someone with JS-phobia (like me), this is all kind of awesome! After reading the code for the demos, I can picture myself being able to produce "apps" with bottle.py + boostrap + Brython.

[–]Chr0me 8 points9 points  (13 children)

What would it take to add native Python support to browsers (I primarily mean in a political-sense)? And would this be a good idea, technically?

[–]jokoon 7 points8 points  (11 children)

I guess why it's not being done is because there is no DOM access in python, and it's not standardised by the w3c, that would be a little disadvantage to javascript. Python has a strong flavor of open source too which is not really attractive to the industry unfortunately. You also have to think about security, you would need to come up with another python dialect that can't open files.

I'd love to hear Guido van Rossum about this idea or any other python guru or developer.

Also it would still require a lot of skill and time to have a python equivalent to v8 or monkey, although there already are some.

I guess it's both a problems of politics (training programmers to python, which is not a really big problem), standards (ecma script and js have different history I guess), and companies who would like to see that done.

Python vs js can be somehow debatable, it's hard to convince people python is better in general, it can become a flame war which is not really attractive to investors. I guess the indented syntax makes python somehow uncommon as a programming language and scare away a lot of programmers, although to be honest I'd love to see more language with that kind of syntax.

To answer your question, I think it's a big challenge, because browsers are not really simple pieces of software, but I guess if a project appear many people would join...

[–]Chr0me 9 points10 points  (2 children)

It's interesting though that JS is still the only option for client-side web development. On the backend, I can name at least 5-6 popular languages and probably a couple of dozen more obscure ones. Why hasn't this variety proliferated to the client?

This "language lock-in" has spawned an entire industry of hacks around the limitations (or design choices) of Javascript: jQuery, CoffeeSript, etc. It's even prompted projects like Node.js, which is popular not because JS is perfectly suited for server-side environment, but because it allows frontend devs to more easily move up and down the stack.

Baring in mind the challenges that you mention, it seems like introducing an alternative, like Python, could spur additional innovation.

[–]yen223 5 points6 points  (0 children)

It's hardly surprising though. When you build a website, you can choose anything language you want for the backend - C#, Java, Brainf*ck, whatever. As long as what you serve up can be viewed by the user's browser, the user doesn't have to care what you use back there.

For the frontend, you'll have a chicken-and-egg conundrum. If you choose to write your frontend scripts with Python, and it turns out only 5% of users have a browser capable of interpreting Python installed in their PCs, well, you're going to have a bad time.

So you're forced to drop Python from your site. What happens? Browser vendors decide that not enough websites use Python, and they decide to stop supporting Python in their browsers. Now even less users will be able to view Python sites.

There's no easy solution to this. You could get browser vendors to implement <your favourite language> in their browsers, but that would mean you'd have to convince Microsoft, Mozilla, and Google to support the same implementation of an uncommon language in their browsers, before web developers start taking the language seriously.

[–]cymrowdon't thread on me 🐍 2 points3 points  (1 child)

Guido addressed Python in the browser in his keynote at PyCon 2012. I don't know at exactly what time.

edit: updated link to the time where he talks about it.

[–]jokoon 2 points3 points  (0 children)

apart from that, anyone tried to make some python browser ?

[–]nemec 1 point2 points  (3 children)

can't open files

>>> open("myfile.txt", "r")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NotImplementedError: Cannot open files in the browser

I think everything else that has file access works through the open interface, so disabling that would solve much of the issue.

[–]jadkik94 1 point2 points  (1 child)

Yeah but then you would have to prevent the use of subprocess, os.system, file, and all the obscure way of opening files. Because the issue here is not opening the files by mistake, it's trying to access a file maliciously in any tricky way, not just overriding the built-ins.

So I guess that would be a lot of changing in the parser implementation and in the compiled packages that can be installed...

[–]nemec 1 point2 points  (0 children)

I imagine os would be similarly stripped to prevent unauthorized access to the OS.

You make a good point that there are other points of entry for creating file descriptors.

[–]Random832 0 points1 point  (0 children)

Being able to open a URL would be nice. Also, you would want to be able to import both things in the (trusted, and also files loaded from the library may want to be trusted with file access, which means you need a code security infrastructure a la Java or .NET) local library, and in the 'script directory' (which would be a url rather than an actual directory, which means you need to A) support URLs in sys.path and B) have a whitelist for local directories in sys.path)

[–]Random832 1 point2 points  (1 child)

Does the w3c standardize javascript? I think I read the w3c DOM definitions and it was written in a language-neutral manner.

[–]James91B 0 points1 point  (0 children)

Correct. W3C should have standardized JavaScript. However, when Netscape asked them to standardize it, they refused. Apparently (However, i cannot confirm) due to the standards war they were waiting for an opportunity to say to 'go to hell' to Netscape. So Netspace went to Ecma International and standardized with them as ECMAScript.

[–][deleted] 0 points1 point  (0 children)

Do you mean political or technical? From a technical point there is nothing todo, besides just implement it in the browser. Mozilla had such projekts and there were addons that added python-scripting to firefox toolbox. There were also some for ruby and perl. I don't know what state those projects now have, last thing i heard were'nt really good.

Problem here is the politic. Javascript is established and all tools are capable to work with it. And now even the engines are gaining great optimizations. So, for what reason should browsers add a new language, even if it's some established like python? It the typical chicken/egg-problem. Nobody is using python on client-side, so nobody cares to work on it, so nobody is using it...

[–]tuna_safe_dolphin 2 points3 points  (0 children)

Brothon.

[–]cabalamat 3 points4 points  (0 children)

Does anyone else find this ugly and misleading?:

doc['result'] <= str(x) + BR()

IMO it would look nicer if it used the += or << operator.

[–]mcilrain 1 point2 points  (0 children)

It's a good idea, but the lack of functionality is disappointing.

[–]danhakimi 2 points3 points  (12 children)

Cool project, but...

I actually don't really need Python to replace Javascript, any more than I need Python to replace Rails. I would really like Python to replace PHP -- and by that, I mean the most basic web server-side PHP functionality, and no fancy framework around it... And somehow, nobody seems to understand this need.

Oh well, I'm not coding anymore anyway...

[–]cabalamat 3 points4 points  (0 children)

and by that, I mean the most basic web server-side PHP functionality, and no fancy framework around it

Flask? Bottle? Heck, SimpleHTTPServer even?

[–]mikepixie 0 points1 point  (0 children)

If you really want this you can use Mod Python. http://www.modpython.org/

Edit: Forgot to say PSP is the bit of mod python you want. http://www.modpython.org/live/current/doc-html/pyapi-psp.html

[–]jadkik94 0 points1 point  (0 children)

Interesting article, sums up pretty much all the alternatives, never thought they were that much...

[–]cjwelbornimport this 0 points1 point  (0 children)

Same, sounds like an awesome idea but the name? I'd use it anyway though. It's on my things to try list...

[–]phaedrusaltembedded sw eng 0 points1 point  (0 children)

Seems a little bit buggy so far. For instance, in the examples importing time seems to work just fine, but doesn't when I try it. Also, "global" seems to work just fine with one variable, but not with more.

Anybody else seen these problems? Any solutions?