310 karma · joined September 21, 2012
https://jvilk.com/
You can actually polyfill WeakMap and WeakSet. You can't do the same for weak references.
If that sounds like fun, I take pull requests [0]. :)
If they didn't.... then it might be sufficient, but I am not sure how well the browser cache handles large files! How long until it evicts them? Is there an upper bound on the size of cached items? etc.
Unfortunately, that is impossible due to differing requirements; I've actually talked with the teavm and bck2brwsr folks [0]. Doppio requires asynchronous function calls to support preemptive multithreading. TeaVM, GWT, and bck2brwsr all map Java methods directly to synchronous JavaScript methods, preventing them from supporting multithreading.
This is actually one of the larger differences we describe in the academic paper that sets Doppio apart from those projects and Emscripten [1].
[0] Start of the conversation: https://groups.google.com/d/msg/plasma-umass-gsoc/uuZk09CGIM...
[1] PLDI 2014 paper (Sorry, I know I'm linking this a lot in the comments thread, but I promise it's a fun read!): https://plasma-umass.github.io/doppio-demo/paper.pdf
The nitty gritty details are in the PLDI 2014 paper [0]. Some details have slightly changed, though (e.g. DoppioJVM supports JDK8 now).
[0] Doppio: Breaking the Browser Language Barrier paper from PLDI 2014: https://plasma-umass.github.io/doppio-demo/paper.pdf
A recent contributor is starting to add a JIT to Doppio, which is a step in the right direction [1].
[0] Our academic paper from PLDI 2014 has more details, although the project has evolved since then (it's now JDK8 compatible, for example): https://plasma-umass.github.io/doppio-demo/paper.pdf
The authors of this project can preload the JDK with a progress bar and stash it into IndexedDB, since Doppio's file system, BrowserFS, supports arbitrary backends [1].
If you find any issues with Doppio or have any requests, feel free to open up an issue on our GitHub issue tracker.
(I'm the primary author of Doppio.)
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
This bug actually causes a ~40% slowdown in one of my projects, since I use sendMessage() in a Worker context to quickly yield to the browser. I didn't mention it, since I figured it may have been fairly obscure... I'm somewhat glad to hear that others are experiencing pain from it. It gives me some hope that it'll eventually be addressed!
I think there's a chicken-and-egg problem with regards to Web Workers: Developers do not use Web Workers because they are hard to use/debug/develop with, and browser vendors do not improve their Web Worker implementations because they have limited adoption. Someone needs to break the cycle.
(Sidenote: I'm the author of BrowserFS, and helped implement this feature.)
(Sidenote: I'm the author of the BrowserFS library, and helped implement this feature.)
However, neither integrates with a debugger like a traditional IDE. You'll likely drop to a terminal or external tools to run / test / debug your program. (I'm sure they both have a plugin to make terminal commands a keyboard shortcut away, though.)
Hope that helps. It's a fantastic editor, although it can be a bit RAM heavy on my aging MacBook Air.
btw, I hope these questions make it clearer why I grumped a bit about the specification, and result in a more robust spec!
How does it deduce the return type of a foreign function? Can foreign functions return values?
Normally, ASM.js functions require an annotation on the return statement [0].
Some other FFIs require you to encode type information in some manner to uphold the guarantees of the language. It's not clear from scanning the specification if that is the case here, as the FFI is only briefly mentioned in passing.
Finally, ASM.js doesn't validate the return expression of external functions (it does for ASM.js code [0]). How does it deal with foreign functions that return values? What type does the return value take? Or does there need to be an annotation at the call site?
I would definitely lobby to get something smaller and concise into the spec under the "Putting it All Together" heading! You could modify the existing example in the spec to include an external function definition and call.
Essentially, a complete executable example of a simple ASM.js program that involves a foreign function, including processing return values. (I imagine if it's this simple, then return values are handled using the same annotations as ASM.js functions?)
While I understand that specs don't necessarily have to have examples, I believe it would benefit the community to have one in the ASM.js spec.
Thanks for clarifying here, though! I now understand.
Note that the FFI is a crucial component of ASM.js, as everything in the browser is external to ASM.js (DOM/any strings/any objects/etc). It seems weird that there's so much hype around ASM.js, yet there's very little written about the FFI or how to use it. Any project that uses ASM.js is going to need to interact with it.
Also, are there any projects besides Emscripten that use ASM.js, or is the push to put ASM.js into these browsers due purely to Emscripten?
First, many repositories are not a single language. For example, this PHP framework is reported as a CSS project [0]. While it has more lines of CSS than PHP, it only has a single CSS file [1].
Second, GitHub has a problem with correctly identifying programming languages. For example, PrimeCoin [1] is identified as one of the most popular TypeScript repositories, but it has 0 lines of TypeScript code. Instead, it has... large localization files with the extension *.ts [2]. BitCoin used to have the same problem, but it looks like GitHub hack fixed it for that particular repository as less popular forks of BitCoin still have this issue.
It took me a few minutes to find these examples, just by examining trending repositories [4]. I'm sure there are many more. So do not be rash in drawing conclusions from this data! :)
[0] https://github.com/laravel/laravel
[1] https://github.com/laravel/laravel/blob/master/public/css/ap...
[2] https://github.com/primecoin/primecoin
[3] https://github.com/primecoin/primecoin/tree/master/src/qt/lo...
TypeScript infers the types of local variables. For example, the following unannotated code would cause the TypeScript type checker to fail:
// error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'.
[1, 2, 3].join(4);
However, even when the TypeScript typechecker fails, TypeScript still produces JavaScript output. As a result, you can use TypeScript to incrementally type your program, and simply choose to ignore type checking errors. TypeScript only fails to produce output if there's a syntax error, or if you are using TypeScript import statements without specifying a module type.