TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Jaspy – A Python VM written in JavaScript

126 pointsby mmarianiabout 9 years ago

12 comments

ruffreyabout 9 years ago
People often look at things like this like 'why would you...' But it is an interesting experiment that might make web programming more accessible. I think of my physicist cousin who uses python for data analysis. An option like this might lower the barrier to sharing data on the web - less JavaScript ecosystem knowledge required. JavaScript frontendy land moves so fast it can be overwhelming to outsiders, even if JavaScript itself is "easy."
评论 #11511293 未加载
评论 #11511664 未加载
评论 #11512399 未加载
评论 #11511299 未加载
评论 #11512983 未加载
jvilkabout 9 years ago
I actually embarked on a similar Python VM called Ninia [1] awhile back, but shelved it as other projects became more important. Ninia supports multiple threads and preempts execution to give the browser breathing space, just like my JVM in JavaScript, DoppioJVM [2].<p>One of the challenges of Python is its objects are quite complex&#x2F;ad-hoc, and can be overridden by the user. I mapped out [3] how I wanted to map Python objects to JavaScript objects, but never had the time to implement it fully. (That document covers Python 2.7; I&#x27;m sure there are differences for 3.) It looks like this project has a lot of work to do if it wants to have parity with a native Python VM! But that&#x27;s part of the fun of writing these things.<p>Best of luck on the VM! If you need a file system to plug into the VM for loading modules&#x2F;implementing the FS API, do check out my BrowserFS library [4], which is currently in use at the Internet Archive [5] and is also used in Ninia&#x2F;DoppioJVM. You can also cop things from Ninia, as it is MIT licensed.<p>Oh yeah, and if you need a Python compiler&#x2F;parser, you can simply run the PyPy interpreter&#x27;s parser+compiler [6] in your intepreter once it is reasonably complete. It is written in 100% Python!<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;plasma-umass&#x2F;ninia" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;plasma-umass&#x2F;ninia</a><p>[2] <a href="https:&#x2F;&#x2F;github.com&#x2F;plasma-umass&#x2F;doppio" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;plasma-umass&#x2F;doppio</a><p>[3] <a href="https:&#x2F;&#x2F;github.com&#x2F;plasma-umass&#x2F;Ninia&#x2F;wiki&#x2F;Mapping-Python-Objects-to-JavaScript-Objects" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;plasma-umass&#x2F;Ninia&#x2F;wiki&#x2F;Mapping-Python-Ob...</a><p>[4] <a href="https:&#x2F;&#x2F;github.com&#x2F;jvilk&#x2F;browserfs" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;jvilk&#x2F;browserfs</a><p>[5] <a href="http:&#x2F;&#x2F;ascii.textfiles.com&#x2F;archives&#x2F;4924" rel="nofollow">http:&#x2F;&#x2F;ascii.textfiles.com&#x2F;archives&#x2F;4924</a><p>[6] <a href="https:&#x2F;&#x2F;pypy.readthedocs.org&#x2F;en&#x2F;latest&#x2F;interpreter.html" rel="nofollow">https:&#x2F;&#x2F;pypy.readthedocs.org&#x2F;en&#x2F;latest&#x2F;interpreter.html</a>
评论 #11512816 未加载
coldteaabout 9 years ago
I often see this wish expressed (also in here by somebody):<p>&gt;<i>JS engines in browsers should evolve to more general VMs, for which you can implement&#x2F;port other languages.</i><p>You do understand that when this happens (and is spread enough to use in production), the web framework and tooling fatigue will be 2-3 times worse.<p>It&#x27;s not just that everybody and their dog will write their own framework (as now), they&#x27;ll split even more and do it for 10 languages... And expect the same dilution of effort for libs too...<p>I&#x27;d actually prefer a better JS replacement, that is, a new, single, language that draws from it and gets rid of all the caveats fixed (lack of ints, coercion rules, small std lib, optional types, even better designed for high speed JITing etc), than seeing Python, Clojure, Ruby, Lua, PHP and 200 others re-implemented in web assembly...
评论 #11514033 未加载
评论 #11514030 未加载
评论 #11513154 未加载
评论 #11513089 未加载
Gladdyuabout 9 years ago
As a general trend with reimplementing stuff in JS, I don&#x27;t quite know whether this is exciting or horrifying...
评论 #11511477 未加载
thegigaraptorabout 9 years ago
I wish people would take time to actually learn javascript. I used to see it as a shitty toy language up until 2012. It opened me up to a completely different style of programming.
评论 #11511635 未加载
评论 #11511620 未加载
评论 #11511747 未加载
mshenfieldabout 9 years ago
I think the most salient application for client-side Python (or Ruby) are for companies already entrenched in server side frameworks like Django and Ruby on Rails. For all Django provides, developing in it still feels constrained to a server heavy mid-2000&#x27;s web development paradigm. While frameworks like React and Ember are pushing the envelope on web applications by allowing you to render HTML apps on the server and on the client, to do something similar in Python means duplicating rendering logic between a server-side template language and a front-end framework like Angular, React, or Backbone&#x2F;Marionette.<p>Some technologies tackle a part of this problem, like pybars, which allows using Handlebars templates in both a python and javascript process. But it would remove a mountain of mental overhead and code duplication, if feasible, to write an entire web application in Python.
评论 #11513825 未加载
koehlmaabout 9 years ago
Oh wow, thanks for the great feedback to all of you!
thewhitetulipabout 9 years ago
This will be interesting for codeschool.com and elearning projects, now they can have everything without requiring the backend at all to evaluate the commands that the user sends.
footaabout 9 years ago
I&#x27;d be interested to see how threading support was implemented, seems difficult to do in a browser environment.
评论 #11512429 未加载
mrcactu5about 9 years ago
are we limited to certain libraries for now? I am guessing we can&#x27;t do pip install, but maybe this version of Python can interact with other javascrupt (e.g. JQuery)?
评论 #11512838 未加载
andrewvijayabout 9 years ago
Going through the code and finding new unknown stuffs already!
harunurhanabout 9 years ago
But why?