Share JavaScript code between .NET desktop and browser

I have a set of core, complex JavaScript data structures/classes, I want to be able to use JavaScript as JavaScript in the browser and run with .NET 3.5 on the desktop. Is it possible to convert the Web Is the friendly JavaScript compiled into an assembly that my C# code can access?

>Hosted JScript – Is there a compiler available that can generate something that can run on the desktop CLR? I have only seen the published examples of the Silverlight runtime. It doesn’t sound like it is officially available on the desktop, but I am willing to try something that is not so lucky, such as can I use the Silverlight tool to compile and then run it on the desktop CLR?
> JScript .NET-It sounds like it has enough custom language extensions, it would be very difficult to run the same code in the browser, but maybe there is a way…?

If none of these work, I think my options are:

>There is a C# version and a JavaScript version, I have to keep in sync (oops).
> Write a variety of preprocessors that run at compile time to convert my JavaScript into JScript .NET or something that I can compile into a .NET assembly.
>Script#: It looks like this will turn the C# code into JavaScript code. Because I prefer to be able to directly adjust the JavaScript code a lot, it’s not great, but it works.

Can anyone use these options successfully?

JScript.Net is actually mainly EMCAScript3 compatible. As long as you treat the code as a processing library ( Just do processing, etc.-use callbacks to interact with the program), you should be fine. I am doing something similar, using javascript as my core parsing library, and then using it in python, dotnet and php.

I have a set of core, complex JavaScript data structures/classes, I want to be able to use JavaScript as JavaScript in the browser and run with .NET 3.5 on the desktop. Is it possible to be web friendly Is JavaScript compiled into an assembly that my C# code can access?

>Hosted JScript – Is there a compiler available that can generate something that can run on the desktop CLR? I have only seen the published examples of the Silverlight runtime. It doesn’t sound like it is officially available on the desktop, but I am willing to try something that is not so lucky, such as can I use the Silverlight tool to compile and then run it on the desktop CLR?
> JScript .NET-It sounds like it has enough custom language extensions, it would be very difficult to run the same code in the browser, but maybe there is a way…?

If none of these work, I think my options are:

>There is a C# version and a JavaScript version, I have to keep in sync (oops).
> Write a variety of preprocessors that run at compile time to convert my JavaScript into JScript .NET or something that I can compile into a .NET assembly.
>Script#: It looks like this will turn the C# code into JavaScript code. Because I prefer to be able to directly adjust the JavaScript code a lot, it’s not great, but it works.

Can anyone use these options successfully?

JScript.Net is actually mainly EMCAScript3 compatible. As long as you treat the code as a processing library (only processing, etc.-use callbacks to communicate with the program) Interactive), you should be fine. I am doing something similar, using javascript as my core parsing library, and then using it in python, dotnet and php.

Leave a Comment

Your email address will not be published.