An actually usable .NET virtual machine in javascript (github.com)
Small comment: I see this as a dart contender, from what I hear, there is a Visual Studio debugger coming, meaning we will be able to debug c#, but have it walk through javascript on page. Sounds amazing to me, thought I should share.
Follow the link in the readme to more detailed documentation. The amazing thing here, is that the produced javascript is small enough to warrant using it for real projects.
The compiler is not yet open source, they said that if there is more interest, they will open it later.
24 comments
[ 4.6 ms ] story [ 44.5 ms ] threadThe compiler is not yet open source, they said that if there is more interest, they will open it later.
Boggles the mind.
What does this mean? How do closures behave any differently when a delegate is assigned as an event handler?
A closure is created for the anonymous function, allowing access (by reference) to the non-local variables in the containing method.
I don't know what you mean by "has closures but not when evented."
True about the new patterns, btw. I guess you'd need to port a jQuery to .NET first in order to be productive.
No language is really like x86 machine code, either, but that doesn't seem to have stopped people from writing anything-to-x86 compilers.
This is absolutely not yet ready for real use, but can convert a sub-set of CIL to JavaScript and is fully open source :)
Update:
il2js and Cil2Js work significantly differently. il2js interprets the .NET IL in a JavaScript virtual machine, whereas Cil2Js directly converts the .NET IL into JavaScript.
Having now looked at this il2js project in more detail, it appears to have some subtle (and some not-so-subtle) differences between running on .NET and running in JS. For example, integer division will return a double in JS; Stack<T>.Last() returns wrong end of stack on JS; no/little support for non-primitive value types; etc... Hopefully these will be sorted out soon, as it's these sorts of inconsistencies that can lead to extreme frustration.
I am unconvinced that a JS VM is a good technique, as I suspect it will be an order of magnitude slower that the same IL converted to JS (although I have no test data to prove this).
However, these aside, it's an impressive project.
In mscorlib however, there are many methods that are implemented directly by the .NET runtime; i.e. they are not implemented in CIL. Cil2Js will provide replacements for these, either written directly in JS, or in CIL (compiled from C# source) that will provide identical functionality.
For example, string.Length is not implemened in CIL. In fact, may of the methods on 'basic' types such as System.String, System.Array, System.Int32, etc... are implemented internally by the .NET runtime.
Uptake was hampered in the past by the author's unwillingness to open-source the compiler; I'm not sure what the community is like at this time. http://stackoverflow.com/questions/1579192/should-i-use-scri...
http://blogs.msdn.com/b/ie/archive/2011/11/22/evolving-ecmas...
(see "Larger Scale JavaScript" in there). Given that, I am assuming it is quite mature and usable.
Unfortunately from what I can tell, expertise on usage of Script# stays locked up within each company (eg. 'a variant of Script#' from the blog post). Perhaps I am demonstrating my ignorance, but the most public activity I could find was the project's GitHub issues list.