Giter Site home page Giter Site logo

jaspy's Introduction

Jaspy

pypi build coverage docs gitter

Jaspy is a Python VM written entirely from scratch in JavaScript with some unique features. Jaspy supports multiple threads, comes with an integrated debugger which offers remote debugging and provides a flexible preprocessor based architecture. Speed is explicitly not a main goal of this project. Jaspy aims to illustrate how web programming on the client side could be done by exploring new ways.

Features

  • suspendable interpreter with support for threading and greenlets
  • integrated debugger and interactive remote debugging (CLI, PyCharm, …)
  • flexible preprocessor based architecture to optimize Jaspy for your needs
  • easily extensible with native JavaScript modules (time, dom, …)
  • full support for meta-classes, builtin subclassing and operator overloading
  • asynchronous imports and arbitrary-length integers based on BigInteger.js

Quickstart

Jaspy comes with an integrated development server and interactive debugger!

First clone the repository and build the interpreter:

git clone --recursive https://github.com/koehlma/jaspy.git; cd jaspy
python3 build.py  # compile the interpreter

Install dependencies for the interactive console, if they are not installed already:

pip3 install --user -r requirements.txt
pip3 install --user ptpython pygments

Switch to the example directory and start the server in interactive mode:

cd example
PYTHONPATH=../ python3 -m jaspy.cli --interactive

Visit http://localhost:8080/hello.html in your browser and click run:

Jaspy Screencast

Alternatives

There are already many other Python-to-JavaScript approaches out there:

Most of them are faster than Jaspy but none of them offers the unique features of Jaspy, which are the fully suspendable interpreter with threading support, the integrated debugger and the flexible, preprocessor based architecture.

State

This project is still in an alpha state. The APIs are unstable, it is untested and not ready for productive use. Some of the features listed above aren't yet implemented.

Todo

If you like the ideas of Jaspy feel free to join, there are many things to do:

  • implement all the batteries-included-builtin stuff of Python
  • implement native JS modules for the DOM, JS objects and some Web APIs
  • improve the debugger and make it fully compatible to the PyDev protocol
  • implement a parser and bytecode compiler in JavaScript
  • complete and adjust the implementation of the Python bytecode VM
  • support for Apache Cordova (Jaspy for cross platform mobile applications)
  • implement a neat UI library on top of Jaspy (using a flexbox based grid)
  • implement a just-in-time compiler to speed things up
  • add a virtual file system (consider using: BrowserFS)
  • … and, of course, your own great ideas and cool features

Structure

libs:third-party dependencies
modules:bundled native JavaScript modules
src:JavaScript source files (need to be preprocessed)
jaspy:Python server, converter and remote debugger

Credits

Many thanks to the Brython project for the inspiration for many parts of code of the builtin-classes. Many thanks also to the book “500 Lines or Less” which is a good starting point if you want to know how the interpreter works.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.