minhee
minhee

Reputation: 5828

Is there a JavaScript (ECMAScript) implementation written in Python?

Are there any JavaScript (ECMAScript) implementations written in pure Python? It is okay even if its implementation is very slow.

Upvotes: 18

Views: 3035

Answers (6)

Sumukh Barve
Sumukh Barve

Reputation: 1444

I created Jispy to embed JS in Python.

From the docs:

A JavaScript Interpreter In Python

Jispy is an interpreter for a strict subset of JavaScript, fondly called LittleJ (LJ). It employs recursive descent for parsing and is very easily extendable.

Built for embedding JavaScript

Jispy's original vision was to seamlessly allow embedding JavaScript programs in Python projects. By default, it doesn't expose the host's file system or any other sensitive element. Some checks on infinite looping and infinite recursion are provided to tackle possibly malicious code.

It comes with an interactive console, so you can get up and running in no time.

Hope this helps.

Upvotes: 1

Alex Gaynor
Alex Gaynor

Reputation: 15029

There is one, of an unknown level of completeness, written in RPython (a subset of Python, that is to say, it runs as normal Python): https://bitbucket.org/pypy/lang-js/overview

Upvotes: 7

Guðmundur Bjarni
Guðmundur Bjarni

Reputation: 4122

I would recommend that you just stick to node.js on your local development box, translate your CoffeeScript files over to JavaScript, and deploy the translated scripts with your apps.

I get that you want to avoid having node.js on your servers, that's all fair and good. Jumping through hoops with Python invoking JavaScript to translate CoffeeScript seems more hassle to me than it's worth.

Upvotes: 2

Nathan Jones
Nathan Jones

Reputation: 5174

Have you heard of PyV8? It's a Python wrapper of Google's V8 JavaScript engine. It may be what you're looking for.

Upvotes: 0

NT3RP
NT3RP

Reputation: 15370

You may want to take a look at pydermonkey or python-spidermonkey, both of which, I believe, are python implementations of the Mozilla javascript interpreter.

Upvotes: 3

basicxman
basicxman

Reputation: 2115

Doesn't seem to be under active development anymore but you could check out pynarcissus, http://code.google.com/p/pynarcissus/source/browse/trunk/jsparser.py

Seems like a binding to V8 (JavaScript interpreter in Google Chromium) is available also, http://www.advogato.org/article/985.html

Upvotes: 9

Related Questions