Live data from Hacker News

Why we need Python in the Browser

archlinux.me

81–90 of 132 posts

Re: Why we need Python in the Browser

#81
post #23

Python in the browser would ultimately lead to all the same problems as Javascript in the browser. In a few years, we'll be hearing: Clojure in the browser, Scala in the browser, Haskell in the browser. I've been programming in Python full-time for the past 6 months, and it's main deficiency are the same as JavaScript's: no (optional) static typing - I'm really sick of writing checks whether my function got values of…

> I'm really sick of writing checks whether my function got values of the correct types, and unittests testing if a class's/function's signature changed in an unexpected way. Sorry to be blunt, but if every one of your Python functions and methods begins with isinstance() checks for every parameter, you just missed the point of the entire language. Python was built on a foundation of ducktyping, with the mantra that…

Not every function, but often enough that it gets annoying.

It mostly happens when dealing with very tight systems, e.g. a RabbitMQ queue consumer fetching messages from an external system and writing stuff to MySQL & Cassandra.

The general issue is that there are some kinds of data types (integer, string, datetime) that cannot really be duck-typed, i.e. replaced by different objects. In my experience, it is better to catch such type errors sooner rather than later, therefore isinstance() checks.

Re: Why we need Python in the Browser

#82
If your python eventually compiles down to JavaScript it's worth doing. That way you can get the developers to hop on because it's easier to program. Browsers could then implement functions to directly process the python source and not the JS which would have speed benefits.

But I really feel there is no need for python in the browser. JS is good enough. If you want an easier way to write it use CoffeeScript.

Re: Why we need Python in the Browser

#83
post #54

I like Python, but JavaScript is sort of good at what it does: evented programming. In javascript it's really easy write a closure. I have not worked with asynchronous frameworks like twisted, but I'd image it's a little more awkward. Am I wrong?

Python also has lambda syntax, therefore closures are quite easy to do. Example: items.select {|e| e.isFoo} It's arguably more terse and superior to javascript in that particular feature as well.

That's Ruby, if I'm not mistaken. In Python you'd do

filter(lambda e: e.isFoo, items)

Re: Why we need Python in the Browser

#84
post #27

It seems that the primary method of disagreement used by only-JavaScript-in-the-browser advocates is as follows: 1. Talk about the "open web"; 2. Tell you to compile to JavaScript. I really don't understand why this is considered a reasonable response to people who just want to build things with the language they prefer, without being treated as second-class citizens.

Maybe because people are afraid to end up with a fragmented web all over again. Preference of language shouldn't really be a factor. The real question is that any change must be properly standardized and implemented by all browser vendors else you end up with "This webpage is written in python and is only supported by Chrome 39+ and Firefox 43+". Does using your prefered language really outvalue that? I think the byt…

Version fragmentation is nearly a non-issue if browser updates are automatic by default and non-intrusive. Firefox is slowly catching up, and Chrome is very good at this. IE would obviously need to substantially change its release cycle if it lost enough market share, though I imagine that won't happen for quite some time.

Re: Why we need Python in the Browser

#85
post #69
post #49

Earlier quoted context omitted.

I also prefer typed languages. I also don't like, the way classes are implemented in Python (the whole self thing). But I think Python has enough good stuff to make up for it. To a degree this is psychological, if you only focus on the bad stuff, you will end up hating every programming language you work with.

The self thing is one of my favourite feature in python, it is then shoo easy to refactor a method in a function, it makes very clear where things come from, etc.

I sometimes see C++ code where all the member variables start with "m_". I'd much rather have it enforced by the language than in a coding convention. (I personally find Ruby's explicit "@" prefix for member variables prettier than Python's explicit "self.", but that's minor.)

Re: Why we need Python in the Browser

#86
post #54

I like Python, but JavaScript is sort of good at what it does: evented programming. In javascript it's really easy write a closure. I have not worked with asynchronous frameworks like twisted, but I'd image it's a little more awkward. Am I wrong?

Python also has lambda syntax, therefore closures are quite easy to do. Example: items.select {|e| e.isFoo} It's arguably more terse and superior to javascript in that particular feature as well.

Besides being Ruby, that's not a closure, just an anonymous block/function. A closure closes over some non-local variables, while that block doesn't.

Re: Why we need Python in the Browser

#87
post #54

I like Python, but JavaScript is sort of good at what it does: evented programming. In javascript it's really easy write a closure. I have not worked with asynchronous frameworks like twisted, but I'd image it's a little more awkward. Am I wrong?

Python also has lambda syntax, therefore closures are quite easy to do. Example: items.select {|e| e.isFoo} It's arguably more terse and superior to javascript in that particular feature as well.

[deleted]

Re: Why we need Python in the Browser

#88
post #54

I like Python, but JavaScript is sort of good at what it does: evented programming. In javascript it's really easy write a closure. I have not worked with asynchronous frameworks like twisted, but I'd image it's a little more awkward. Am I wrong?

Python also has lambda syntax, therefore closures are quite easy to do. Example: items.select {|e| e.isFoo} It's arguably more terse and superior to javascript in that particular feature as well.

But... Uhhhh... that was Ruby you just showed there. And Python's anonymous functions are deliberately crippled because the Grand BDFL dislikes functional programming (often tried to be sneaked around by those dastardly Schemers, curse them!).

Re: Why we need Python in the Browser

#90

We don't need Python in the Browser. We need a VM SPEC for the browser, so we can have whatever language we damned well please in the browser. Why Google decided to go with Dart rather than publish a VM spec is beyond me.

Brendan Eich has talked about why bytecode + VM is a bad idea for a browser: http://www.aminutewithbrendan.com/pages/20101122

If you really want a VM, it already exists. It's called JavaScript, assembly language of the web.

I would hate for sites to start saying, "Requires the PyJSVM v0.8 or better to function, download it now!"

EDIT: in hindsight, this post was careless. I was wrong about the "PyJSVM" point, and I posted the minutewithbrendan link to provide commentary, not "Eich said it, so it must be true."

What I should have said:

JavaScript is so widely used today, that anything that comes along purporting to be better (such as bytecode, Dart, whatever) must be so much better as to provide a clear reason for developers and users. If it's just "better", then JS will remain dominant because it's good enough. Therefore, it makes sense to target JS from other langs. It's definitely not getting slower, and we're on the cusp of some great APIs!

Post reply on HN