Jaspy – A Python VM written in JavaScript
github.com
github.com
What are the most common use cases for JS, that might be a barrier to an unfamiliar developer, requiring some learning? I believe that making an ajax request and some trivial DOM manipulation covers a lot (say, send ajax request to the server and add some text returned to a dom element). In order to do that, you don't need some fancy framework, plain simple JS will do it. Arguably, it will be even easier to do it in JS than in e.g. Python, because there are tons of examples on the web in case you need to extend the functionality. Occasionally, you will need some visualization (chart or something), but then it's mostly just finding some library and transforming the data into the required format, that's simple enough to do with a language that you are not an expert in.
After all, isn't web development already accessible? I would argue that this is the most accessible of software development, with huge amount of high quality, accessible learning resources and various frameworks that enable to develop complex features rather quickly, if needed.
True, there's always something that can be improved but I don't think that Python-to-JS solves anything.
However, I genuinely believe that a project such as this is a cool side project to explore and improve your software development skills :) so often 'why would you...' can be answered with simply 'because it's fun'.
A person without interest in web development, such as a scientist who wishes to publish a blog, should be fine with a pre-baked solution like Wordpress. Even if they're comfortable with Python, there's no reason to replicate what "core" Wordpress does, which is no small undertaking. Also, a person working in a field that just happens to use a sprinkle of programming would have to learn a lot of tangential junk just to replicate what pre-baked solutions do, and they would probably do it poorly.
It would be better if such individuals just paid for an affordable solution or used something like Wordpress.
One of the challenges of Python is its objects are quite complex/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'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's part of the fun of writing these things.
Best of luck on the VM! If you need a file system to plug into the VM for loading modules/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/DoppioJVM. You can also cop things from Ninia, as it is MIT licensed.
Oh yeah, and if you need a Python compiler/parser, you can simply run the PyPy interpreter's parser+compiler [6] in your intepreter once it is reasonably complete. It is written in 100% Python!
[1] https://github.com/plasma-umass/ninia
[2] https://github.com/plasma-umass/doppio
[3] https://github.com/plasma-umass/Ninia/wiki/Mapping-Python-Ob...
[4] https://github.com/jvilk/browserfs
>JS engines in browsers should evolve to more general VMs, for which you can implement/port other languages.
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.
It's not just that everybody and their dog will write their own framework (as now), they'll split even more and do it for 10 languages... And expect the same dilution of effort for libs too...
I'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...
The Java world also historically had a parent company giving strong guidance.
The Java world also has strong standard libs and tended to include everything and the kitchen sink in them (including full blown servers, XML/XSLT parsers) in the SDK (and EE SDK). Heck, it even has a full JS interpreter there.
Even so, there was huge fragmentation of effort for things like web frameworks (Struts, WebWork, Spring, Cocoon, Turbine, Tapestry, and many many more). Actually, if you were doing Java in 2000-2010 it was a running joke how everybody would write their own framework.
And I would argue that all the resources diverted to numerous Java-derivative languages (like Kotlin, Ceylon, Xtend, etc) would be better of in making Java better, or creating a single, community driven, Java successor, if there was a process (and access) for that.
As it is, they are all doomed to remain niche players, and ultimately fail, while languages like C# and Swift march on.
In any case monopoly is bad. People are writing frameworks and languages that transpile to JS because they are not happy with the default option. In addition to more general VM there also should be a more robust standard library, that any language targeting it will have access to.
So far they have been conservative and focused only on typing but they could offer insane value if they started offering a full language expirience like Dart
A package manager is not necessary, it can work with npm.
A build system is not necessary, existing build systems support it.
I believe they will eventually do full polyfill. However, the compiler is very high quality and that doesn't happen by accident. They have to make hard design decisions to keep releasing features so regularly (they release features faster than I can keep up with sometimes).
For now, you can target es6 and chain with babel.
And, ultimately, your code still ends up being a load of garbage boilerplate code like you're writing oldschool Java from the early 2000s.
It's a nasty language written on top of a nastier one, lipstick on a pig.
I don't see it as a long term solution. It's just the next coffeescript. It's part of the problem rather than a solution, the problem being the massive churn in the JS ecosystem as we desperately hunt for a way of writing JS code that isn't awful.
The actual solution is to give us other languages in the browser. We need Python or Ruby or Go or C# or PHP or whatever. We need real choice, not javascript 2.0.
If Firefox wanted to stay relevant today it could stop dogmatically promoting a broken language and that's what they'd be working on right now. They're too rigidly fixated on the past though.
It can work with NPM - but what about bower, JSPM, whatever else hipster package manager everyone else uses ?
It should specify TS supports NPM by default and it's the official package manager - you can use others at your own risk. Ditto for build system.
Saying you can target ES6 with babel is completely missing my point - Dart developer experience is much much better than TS simply because it does all of these things - out of the box and without any decisions/interventions/ridiculously complicated build setups and dependency chains
What style would that be? JS is a dynamic language, but as dynamic languages go it isn't the first and it is certainly not the best. What is has going for it is near monopoly in browser space and a ton of optimization.
Of course I'd prefer Haskell, but if one can earn money with JS...
> Speed is explicitly not a main goal of this project.
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.
And it's not all roses on the other side either, I've looked into the fullstack solutions that are all JS and promise the world and best future possible but ended up being lackluster in things like SEO.
There is already support for threading and I am also planing to implement a filesystem as well as multiprocessing using WebWorkers. Even sockets will be possible with node.js.
Then yes, you can do "pip install".
There is also a module that allows you to use native JS libraries like JQuery.