18

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

Seki
  • 11,135
  • 7
  • 46
  • 70
minhee
  • 5,688
  • 5
  • 43
  • 81
  • As the next best thing, how about [Python compiled by C to LLVM implemented in JavaScript](http://syntensity.com/static/python.html)? – Kerrek SB Sep 17 '11 at 00:30
  • 4
    Why would you want this? I'm curious now! – hugomg Sep 17 '11 at 00:41
  • @missingno Actually, I’m developing a web application in Python and just want to use [CoffeeScript](http://jashkenas.github.com/coffee-script/) instead of JavaScript **without any other dependencies** especially node.js setup. – minhee Sep 17 '11 at 01:50

6 Answers6

9

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

basicxman
  • 2,095
  • 14
  • 21
7

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

Alex Gaynor
  • 14,353
  • 9
  • 63
  • 113
3

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.

NT3RP
  • 15,262
  • 9
  • 61
  • 97
2

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.

Guðmundur Bjarni
  • 4,082
  • 1
  • 18
  • 14
1

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.

Community
  • 1
  • 1
Sumukh Barve
  • 1,414
  • 15
  • 12
0

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

Nathan Jones
  • 4,904
  • 9
  • 44
  • 70