On Sunday, November 17, 2013 8:04:49 PM UTC+1, David Li wrote:
>
> There's also the more speculative ideas of using Emscripten (example: 
> http://repl.it/M4w<http://www.google.com/url?q=http%3A%2F%2Frepl.it%2FM4w&sa=D&sntz=1&usg=AFQjCNEx9nyndaK2q6euf6S3HplhrWmtSQ>)
>  
> or Portable Native Client to compile the Python interpreter to JavaScript, 
> then using that to run SymPy.
>

I came across this project and, yes, I believe this is the right solution 
to run sympy in a browser (I didn't try but it's very promising as a 
project).

Let me explain a bit. Emscripten is a tool to be used along with 
*clang*compiler to compile C/C++ code to Javascript. The Javascript code 
generated 
is very strange, there are only arrays and integers as variables. That kind 
of javascript follows the ASM.js standard, and is meant to resemble a 
low-level language such as assembler rather than a high-level language such 
as javascript.

The code is likely to run on most browser. The point is that Firefox can 
detect when the code follows the AMS.js standard, and in such cases the 
javascript source code is not processed by the standard javascript 
interpreter, rather it is translated back to machine code, resulting in a 
compiled program to some degree similar to what a C/C++ compiler would have 
output. Performance is slightly less than by using a C/C++ compiler.

This fast mode is currently supported by Firefox only, other browsers will 
still run AMS.js-compliant code, but will rely on their standard javascript 
interpreter, thus being slower. Google Chrome and Opera are currently 
working to introduce this feature into their browsers.

The point is, that it is possible to compile CPython into Javascript, so as 
to have a 100% python compatible interpreter inside the browser. The link 
pointed out by David Li 
(http://repl.it/M4w<http://www.google.com/url?q=http%3A%2F%2Frepl.it%2FM4w&sa=D&sntz=1&usg=AFQjCNEx9nyndaK2q6euf6S3HplhrWmtSQ>)
 
is CPython running inside the browser as javascript code. I would recommend 
to use Firefox, as other browsers will probably be very slow executing such 
an enormous amount of javascript with their standard interpreters.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to