I think the asm.js optimizations do make a difference when used; see a benchmark of a physics engine ported with Emscripten: http://josephg.com/blog/chipmunkjs-and-emscripten (though it's a bit outdated). Regardless, if Emscripten is too slow in Chrome we can fall back on Native Client (and actually, there's a project called pepper.js that compiles Native Client modules into JavaScript with Emscripten), and just getting it running in the browser would be a great accomplishment.
@F.B. have you managed to compile Python using Emscripten? I tried but could not get the interpreter working, it just hung/crashed if I tried to bundle the standard library and complained about site.py otherwise. David On Friday, January 10, 2014 6:13:38 PM UTC-7, Aaron Meurer wrote: > > On Fri, Jan 10, 2014 at 2:57 PM, F. B. <franz....@gmail.com <javascript:>> > wrote: > > > > 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) 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) 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. > > Are you sure about that? I did the following test on my Mac (Chrome > 32.0.1700.72 beta, Firefox 26.0): > > def sieve(n): > primes = range(2, n+1) > for i in range(2, n+1): > for j in primes[:]: > if not j % i and j != i: > primes.remove(j) > return primes > > import time > > t = time.time();sieve(1000);print(time.time() - t) > > (yes I know it's inefficient; my point was just to find something that > did something nontrivial that took a reasonable but nontrivial amount > of time to complete). > > In Chrome, I get 0.555000066757; in Firefox I get 2.47399997711. I > also tried Safai 7.0.1 (I get 4.63800001144) and Opera because you > mentioned it (version 12.16, I get 4.44400000572). > > So maybe Chrome beta already has some of the ASM stuff in it, but > whatever it is, it's clearly the fastest here. > > For reference, when I run it in IPython in my terminal I get > 0.0159571170807. So it's still 30 times slower. > > Aaron Meurer > > > > > -- > > 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 sympy+un...@googlegroups.com <javascript:>. > > To post to this group, send email to sy...@googlegroups.com<javascript:>. > > > Visit this group at http://groups.google.com/group/sympy. > > For more options, visit https://groups.google.com/groups/opt_out. > -- 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 sympy+unsubscr...@googlegroups.com. To post to this group, send email to sympy@googlegroups.com. Visit this group at http://groups.google.com/group/sympy. For more options, visit https://groups.google.com/groups/opt_out.