Demo coala in browser
Closed this issue · 6 comments
So, I was trying to demo coala inside a browser using one of those python in browser implementations.
I wanted something like http://jshint.com/
I'm very enthusiastic about this. It's cool B-)
I tried skulpt in the beginning an then realized it uses python2.x So, I moved to brython
. I still faced some issues with brython. Filed a few bugs too:
- The coalib uses
subprocessing
, and brython cannot do that because a browser doesnt allow new processes. platform.system()
throws an error inConstants
.os.path.expanduser
doesn't work as home directory concept makes no sense.- There's some unusual error when trying to import
LineCountBear
->LocalBear
->Bear.py
which I have not yet figured out (throws no exception message).
@AbdealiJK I'm concerned about the performance. Creating AST, compiling/executing in browser would probably make it extremely slow. I read somewhere, the approximate comparison is something like:
JavaScript : 1ms
Python : 8ms
Brython: 1000ms
What's your view?
What other alternatives do we have ?
https://brythonista.wordpress.com/2015/03/28/comparing-the-speed-of-cpython-brython-skulpt-and-pypy-js/ says that brython is the fastest
Can you cite the source from where you got those stats ? And how old they are ? (Numbers have little meaning without proper context)
Keep in mind that running it in a server will probably be even slower as http
requests depend on internet speed. Which (at least for my internet) could be slower.
I think as long as we can show results from some simple bears like LineLengthBear, LineCountingBear, etc within 500ms it's cool. (For a file with 100 lines, this is like a 5000 statements being executed at max ?). That is 10 statements per second which I think it can do. We can limit people and let them only put in 100 lines max ?
Note: Yes, I realize these are rough calculations.
Also note that we cannot run any of the linter bears. As we'd have to make them compatible with brython - so, this in only for bears organically written in coala if we do brython. While if we do it in a server we can configure the server to do anything. Hence each has it's pros/cons.
Personally, I'd love to make this and contribute to brython appropriately to get it to work. As I really like brython. But the back up plan is to do it in our server (gitmate's server could do it ?)
If we can't run linter bears it's not really that helpful to most users IMO. A server side solution is much easier and more powerful, we'd just use a docker image based on coala/base and throw the code and coafile at it.
Yep, in hind sight, I agree that it's much easier and more flexible (powerful, I'm not sure of). :(
So we scratch the plan of doing brython and just do a simple server side solution for the website ? Probably using coala-json or so.
The gsoc project could then focus on more complicated things like you mentioned - Take in a github/gitlab url from the user and do analysis on it and show the coala-html page for that maybe ?
Yes, this is related to the website project so if both website and this happen students would probably work together on getting some base flask/angular website and then the task here is to build an API endpoint for the server first that does the analysis, and a JS application that shows results from that json. Further goals can be doing that for git repo's and caching results in a db possibly.
done at https://new.coala.io