Show HN: Myjs An accidental pure-Python JavaScript interpreter

Hi HN! byteface here. myjs was a recent accident I'd like to share.

Several years ago I began writing DOM API's in Python as a curiosity: https://github.com/byteface/domonic/

Every now and then I do another pass rolling in more features from the MDN pages. I have lots of unit tests but found that porting real code and libraries was a useful test of the DOM compatibility. But I didn't want to pollute the core any further as had already ported d3 and jquery.

So I created a new repo called domonic-libs: https://github.com/byteface/domonic-libs/

Anyways a couple of days ago while porting some js libraries faithfully to run against dom.py and javascript.py I came across Acorn (a Javascript parser) and coverted it into pure python.

Once Acorn.py was producing an AST, I mapped that against domonic's Javascript and DOM nodes and to my surprise... actual JS code started executing inside the Python process!

Give it a try:

pipx install myjs

Would love to hear your thoughts, edge cases to test, or feedback!

7 points byteface 2 months ago 0 comments

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton