TIGSource Forums

Developer => Technical => Topic started by: BorisTheBrave on May 31, 2011, 08:17:37 AM



Title: C# -> Javascript translator
Post by: BorisTheBrave on May 31, 2011, 08:17:37 AM
http://hildr.luminance.org/Platformer/Platformer.html

It translates MSIL to Javascript, including re-bindings enough of the libraries including XNA to work. In the same vein that emscriptem does for LLVM bitcode, but with less of an impedance mismatch.

I gather it is quite a smart translator, too. It understands the classes and type of MSIL to generate the most idiomatic code, and recognizes control flow, so it is not just an unrolled interpreter.

Personally I'm fascinated. Looks like a lot more pleasant way of producing HTML5 games, (even though I kinda like javascript).

(via reddit) (http://www.reddit.com/r/programming/comments/ho76f/i_wrote_a_net_to_javascript_compiler_heres_the/)


Title: Re: C# -> Javascript translator
Post by: Dacke on May 31, 2011, 08:26:21 AM
Do you know how it compares to GWT (https://code.google.com/webtoolkit/)?
(GWT does Java to JavaScript compilation)


Title: Re: C# -> Javascript translator
Post by: BorisTheBrave on May 31, 2011, 09:52:02 AM
Well the guy making it has a focus on games.


Title: Re: C# -> Javascript translator
Post by: Dacke on May 31, 2011, 10:59:18 AM
You mean that it will be limited in that it will only be for games? Or that it will do games better because it is specialized?


Title: Re: C# -> Javascript translator
Post by: BorisTheBrave on May 31, 2011, 11:49:48 AM
I'm not the spokesperson here. I just meant that he chose a game for his first demo, and ported at least some of XNA.


Title: Re: C# -> Javascript translator
Post by: Dacke on May 31, 2011, 12:01:30 PM
I find it very impressive and am asking questions because I want to know more. But if you don't know the answers, that's totally fine too.


Title: Re: C# -> Javascript translator
Post by: Kaelan on May 31, 2011, 03:47:22 PM
I'm not the spokesperson here. I just meant that he chose a game for his first demo, and ported at least some of XNA.
My first demo was actually a toy C# raytracer somebody wrote, since all I needed to get that up and running was to implement a few System.Drawing.Bitmap methods atop canvas. This is the fourth demo I've ported, and it's the first one that ran well and was still a 'real' application (scare quotes because really, it's just a tutorial).

It's not focused on games, but my personal focus is games, since that's what I want to run in the browser. It's certainly designed to work for regular applications/libraries just as well as it does for games.

Conceptually it is similar to GWT, but there are lots of philosophical differences - GWT is basically designed to generate obfuscated, 'read-only' JS code, and the result either works or it doesn't. JSIL attempts to produce readable, debuggable JS that corresponds as closely to the original author's intent as possible, so that getting things up and running is straightforward and people running your app in the browser aren't forced to live as second-class citizens.


Title: Re: C# -> Javascript translator
Post by: increpare on May 31, 2011, 04:30:39 PM
Woah, Kaelan, really great stuff!


Title: Re: C# -> Javascript translator
Post by: Rob Lach on May 31, 2011, 10:14:28 PM
I stumbled upon this today and was pretty impressed. I've always thought about doing something like this but I fear my js skills aren't up to the task.


Title: Re: C# -> Javascript translator
Post by: MikeSw on June 02, 2011, 12:15:56 AM
Amaizing! I can;t wait for the time we'll be able to write html 5 games in C#  :tearsofjoy:


Title: Re: C# -> Javascript translator
Post by: danelkhen on June 11, 2011, 09:06:08 AM
Hey,

SharpKit converts direct C# source files into JavaScript, and also have CLR support.
http://sharpkit.net (http://sharpkit.net)

Cheers


Title: Re: C# -> Javascript translator
Post by: Eibx on June 13, 2011, 04:00:45 AM
Even though this does translate C# to Javascript - I do see it more as a XNA to HTML5 translator.

But this very impressive. We have once used Silversprite (XNA to Silverlight), but this actually seems to work better - it's way more smooth.





Title: Re: C# -> Javascript translator
Post by: Kaelan on July 04, 2011, 12:52:34 AM
If anyone here has a game built with XNA (or just C#) that you'd like to port to JavaScript, drop me a note. I'd be glad to help you get up and running, and identify any problems in JSIL I can fix to make your stuff work.