3 ms·
Coincidently, I'm currently creating a similar project: https://github.com/chrisdunelm/Cil2Js https://github.com/chrisdunelm/Cil2Js This is absolutely not yet
by chrisb 15y ago
Coincidently, I'm currently creating a similar project: https://github.com/chrisdunelm/Cil2Js https://github.com/chrisdunelm/Cil2Js
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.
- Meai 15y agoIf I understand correctly, one advantage of il2js should be that all the core .NET libraries won't have to be ported to JS, as the needed library methods get expanded into IL.
- chrisb 15y agoThis will also happen in Cil2Js. Any .NET library method (including system libraries) that is implemented as CIL can be converted directly to JS. 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.