Isomorphic Django?

286 views
Skip to first unread message

Benjamin Melki

unread,
Mar 14, 2015, 7:13:54 PM3/14/15
to django-d...@googlegroups.com
Hi are there any plans for isomorphic django version?
That runs python on both server and client (via transpiled js on the client) like volt framework that appeared on ruby world?

Tim Graham

unread,
Mar 14, 2015, 7:25:55 PM3/14/15
to django-d...@googlegroups.com
I have not seen any discussion about such a thing.

Russell Keith-Magee

unread,
Mar 14, 2015, 8:47:29 PM3/14/15
to Django Developers
Hi Benjamin,

A few more details to whet your appetite (because this is a thing I've been *thinking* about, but don't have anything to show)

The biggest sticking point at the moment is getting Python on the client side. I'm aware of many attempts:

 * Brython (http://www.brython.info) is an in-browser implementation of Python 3
 * Skulpt (http://www.skulpt.org) is another in-browser implementation of Python, but only supports Py2.6
 * PyPy.js (http://pypyjs.org/demo/) uses a clever intersection of PyPy, emscripten and asm.js to *compile* CPython into JavaScript.
 * pyjs (http://pyjs.org) is a traditional transpiler. This project has been around for a while (longer than Django), but it's a bit behind in it's Python development - it supports most of Py 2.5, and some of Py 2.6.

PyPy.js is a technically interesting approach - for certain carefully selected benchmarks, it's actually *faster* than native CPython on the same machine [1]. There's are 2 *big* buts, though - the initial download size is *huge* (20MB), and "faster" is heavily qualified by "after a JIT warmup".

Brython and Skulpt now the most "useful" at the moment, but they're both 650k and 450k downloads, respectively. That's a big chunk to require as a download, especially over a mobile connection. Yes, it can be cached, but first time visitors on slow connections are going to have a big lag.

pyjs takes the traditional transpiler approach, but it's also the least up to date.

Another approach - and one I've experimented with - is to port a Python bytecode interpreter to Javascript. This is a lot smaller than a full Python interpreter, because you don't need to carry the parsing side of the environment to the browser - you can rely on the server side to compile the bytecode, and then ship that bytecode (which is available by introspection to the running interpreter) directly to the browser. I got something working (albeit very slow and inefficient) in around 20k. 

I don't know how this compares to the Ruby world - but without a highly efficient way of running Python in the browser, isomorphic web development isn't an option.

However, assuming such an transpiling/execution option existed, I'd suggest that it wouldn't be developed as part of the Django project itself - it would be better suited as a third party tool - tightly integrated with Django's components, but independently developed and maintained.

Yours,
Russ Magee %-)


--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/6738eee6-ac93-4851-9ed2-fd869357432d%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages