Ninia is a genus of snake, commonly called coffee snakes. In this case, it is also an implementation of Python on top of JavaScript.
Ninia is currently a work-in-progress, and actively welcomes contributions!
Supports a subset of Python 2.7.8 bytecode:
- Functions (including keyword and default arguments)
- Condition statements (
if
and comparisons of integers and booleans) - The four numeric types: Integer (32 and 64 bit), Long (arbitrary precision), Float, and Complex.
- Certain operations are unsupported, e.g. powers for complex numbers
- The
print
statement. - NOTE: This interpreter forces true division. That is,
5 / 2 == 2.5
. To force floor division, use the//
operator à la Python 3. - Opcode status: 65 of 119 defined and (mostly) working.
- node.js, npm, and bower
- Python 2.7 for compiling tests (
python2.7
should be in $PATH)
Compile the main JavaScript driver with make
, then
load browser/demo.html
in your browser of choice.
Click on "Choose File" and upload a .pyc file, then click "Process File". The output should appear in the Output area.
To create a .pyc file from a .py file, simply run:
python -m compileall file.py
Run the test suite with make test
.
Alternatively, follow the "Running" steps and load one of the
*test.pyc files from the pytests/ directory.
- Write a python file
testExample.py
somewhere in the pytests/ directory. - Add a new line to test.ts that gives a description for the test and a path to the test file:
["This is a sample test", "pytests/path/to/testExample"],
- Check that it runs with
make test
.
Theodore Sudol and Cibele Freire originally wrote Ninia as a class project for CMPSCI 630, a graduate-level software systems class. The PLASMA lab at UMass is continuing the project to experiment with bringing conventional programming languages to the web on top of JavaScript.
Ninia will reuse the common infrastructure present in Doppio and DoppioJVM to bring Python to the browser.