Do we want to learn another programming language? - No, Python is the most popular language in the world
We had a requirement to allow users to define custom logic at runtime safely. We tried a JSON-based configuration, but, as complexities grew, that configuration became unmaintainable. Even UI-based drag’n drop interfaces become messy for bigger and more complex logic. And after a few failed attempts I decided to build my interpreter and introduce a new coding language to the world. And syntax-wise I choose to start with Python as it is the most familiar syntax among our target audience.
Main advantages of JSPython
- Safe scripting environment. You have full control over what functions and libraries you expose to JSPython and allow users to use.
- Works in a browser as well as offline on the server-side. You can integrate it easily with your web app in the browser and/or run jspy files offline with jspython-cli in the NodeJS environment
- The python-like syntax. Most of the language features (syntax, indentation, and expressions) are mirrored from Python. Also, added a few extras like Multiline lambdas, Null coalescing, single line conditions, etc
Where to start?
npm install jspython-interpreter
jsPython() .evaluate('print("Hello World!")') .then( r => console.log("Result => ", r), e => console.log("Error => ", error) )
Run JSPython in NodeJS with JSPython-CLI
Use JSPython-cli command line tool what allows you to run JSPython in NodeJS environment
jspython --file=path/to/jspython/file --param1=value --param
Any similar projects around?
Many people are asking about performance and maturity of the project. How does it compare to Python performance-wise?
Check out our basic playground https://jspython.dev/playground
Or more advanced examples build with WORKSHEETS Data Studio
JSPython was build to power our low code data management platform - Worksheet Systems. Which allows anybody to build database applications with ease, control and confidence. JSPython is used as a primary low code language to define UI behaviours, validations, build data transformational pipelines and much more.
However, it is open source project with a permissive BSD 3-Clause License.. So, feel free to adopt it into your own projects.