Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support porting of Javascript to CSharp through Jurassic - feasible? #58

Closed
JimSEOW opened this issue Sep 28, 2016 · 3 comments
Closed
Labels

Comments

@JimSEOW
Copy link

JimSEOW commented Sep 28, 2016

Jurassic compile Javascript to IL, has anyone tried to convert the generated IL to cSharp? Currently I am evaluating if Jurassic could be used to support the porting of WebGL-based codes to C#.

Step1 involves wrapping non-3D Canvas dependent javascript functions with Jarassic. This would allow testing of 3D canvas dependent codes in C#.

Step2 (it would be great) if it is possible to compile non-3D canvas javascript codes to DLL. and reference the DLLs with C#

Step3 test the feasibility if the DLL could be converted to Csharp using tool like ILSpy. This would complete the complete porting from Javascript to C#.

Has anyone attempted? Could this be done? There are plenty of libraries support porting of Csharp to Javascript. There are hardly any robust Javascript to CSharp converter. Perhaps I am wrong.

@paulbartrum
Copy link
Owner

I've done this in the past, but the generated C# is pretty horrible. Jurassic only does very basic type inference, so simple code like this:

var x = y + z;

gets turned into something like this:

object x = TypeUtilities.Add(engine.Global["y"], engine.Global["z"]);

@JimSEOW
Copy link
Author

JimSEOW commented Sep 29, 2016

@paulbartrum Thanks for replying. I am still trying to figure out the potential of Jurassic.
According to this discussion

These are some of the options:

I am continue the discussion, perhaps this could lead to a FAQ that is part of "What Jurassic is and is not? (with regards to Javacript to Csharp converter). Thanks again for your contribution.

@paulbartrum
Copy link
Owner

Jurassic is not a JS to C# converter. It is a JS engine and runtime written in C#. With some effort, you could use it to generate c# code from JS code, but without a lot of effort the generated code will be slow and ugly.

I recommend you instead use a tool which is designed for this purpose. It sounds like "Universal transpiler" is your best bet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants