
Show HN: Minimal, modern embedded V8 for Python - jbaviat
https://github.com/sqreen/PyMiniRacer
======
galazzah
What're the use cases for this?

~~~
jbaviat
One of PyMiniRacer author speaking.

Use cases are many. For instance, Rails uses ExecJS to minify assets, to
compile JavaScript assets from ES6 to older JS runtimes using Babel, for
compiling CoffeeScript... In another world - and that's Sqreen use case for
this, JavaScript is the 2016 alternative to Lua.

Furthermore, PyMiniRacer is a lightweight alternative to NodeJS if you are a
pythonist and need to run JavaScript, for production or for hacking :)

------
santa_boy
Cool. This looks similar to V8 for R that I use for data analysis.

Link to V8: [jeroenooms/V8: Embedded JavaScript Engine for
R]([https://github.com/jeroenooms/V8](https://github.com/jeroenooms/V8))

I use this sometimes because I am so comfortable with nodejs libraries like
Moment that I get lazy to figure out things using R.

------
ivan_ah
Could this be used to render React views on the server side? I'd love to use
something like [https://github.com/markfinger/python-
react](https://github.com/markfinger/python-react) but without the need to run
node.js server on the side.

Is there an example I can copy to imitate this approach?

~~~
jbaviat
It seems quite straightforward to me if you use:

1\. the C# example from React doc,
[https://facebook.github.io/react/docs/environments.html](https://facebook.github.io/react/docs/environments.html)

2\. The BabelJS example from PyMiniRacer:
[https://github.com/sqreen/PyMiniRacer/blob/master/helpers/ba...](https://github.com/sqreen/PyMiniRacer/blob/master/helpers/babel.py)

I would be glad to hear more about that :)

------
gardentheory
This seems pretty cool. I just tried using jslint to lint a file, it works!
[https://gist.github.com/ianjosephwilson/7c6c0a2c833e92b3a82c...](https://gist.github.com/ianjosephwilson/7c6c0a2c833e92b3a82c6d1c8e50286c)

~~~
jbaviat
The PyMiniRacer repository is also bundled with a BabelJS
([https://babeljs.io/](https://babeljs.io/)) example:

[https://github.com/sqreen/PyMiniRacer/blob/master/helpers/ba...](https://github.com/sqreen/PyMiniRacer/blob/master/helpers/babel.py)

You can easily try it once PyMiniRacer is installed to transpile JavaScript
files:

cat some-file.js | python helpers/babel.py

