none
Roslyn to build a C# to javascript transformer ?

    全般的な情報交換

  • I wonder if the Roslyn project will make it easier to create another project that will compile C# to javascript, like GWT does for Java, or like Dart does.

    I would bet that if Script Sharp was implemented with Roslyn, it could be even more powerful (support for lamdas, generics, etc...). Regardless, I really believe that Microsoft needs an official team to build a world class C# to javascript transformer. Javascript is here to stay whether we want it or not...

    2011年11月20日 2:35

すべての返信

  • If JavaScript is here to stay wouldn't it be prudent that you (all of us) learn and write JavaScript? I don't see what the purpose/benefits of a C# to JavaScript transformer would be.
    http://www.matlus.com
    2011年11月21日 15:46
  • Well, if assembly language is here to stay, wouldn't it be prudent to learn it ? I'm pushing it a little but some people have actually argued that javascript was the assembly of the web (such as Erik Meijer, you can google "javascript assembly langugage").

    Now I personally don't think that javascript is as bad as assembly, but it certainly lacks a lot of modern constructs (no built in concept of namespace).

    I have learned and used javascript but I've found it's pretty hard to structure large application in big teams (even with jQuery). There is a reason why many languages/framework can be compiled to js.

    However I do think that you have a point and that even with a C# to javascript tool we would still need to know js and be able to tweak it where necessary...

    2011年11月21日 22:25
  • Did you ever make any progress with this question? Have you tried to re-implement a ScriptSharp type converter in Roslyn? Is it possible at this time?

    p.s. I agree that there is a use scenario for this as I have been using ScriptSharp. I am finding it delivers far more maintainable code than if I were to write in only Javascript. The beauty of the approach is that when I want to do Javascript I do Javascript, when I want to build nicely refactorable objects I use ScriptSharp to do the heavy lifting for me. I lose none of the beauty of JS, and I retain some of the elegance of C#. Unfortunately, ScriptSharp is a a bit limited at the moment and it's development is relatively slow. It would be nice to re-do the compiler.

    2012年3月9日 13:39
  • After also using Script# for quite some time I agree that it helps tremendously on larger more complex projects. This is especially true if you're writing javascript at a framework level, and not simply functional blocks associated with single pages.

    As such, I started writing an experimental C# to javascript compiler using Roslyn a while back. I've been able to reproduce much of the functionality of Script#, although some of the limitations of the Roslyn CTP have introduced a few annoying issues. Although, all of those should iron out as Roslyn becomes more mature. I've also been working on some interesting ideas, such as an extensible pre/post processing model, where the end user could alter the input (syntax tree) and/or the output (javascript). For instance, I'm trying to allow support for any OO framework by allowing those artifacts to be rendered by templates.

    Anyway, if you're interested in trying out an early cut and providing some feedback, I should have something available soon.

    2012年3月10日 13:55
  • Barry, 

    That's really interesting stuff. I've been looking into the feasibility of this kind of solution today and as you seem to have demonstrated, it is eminently doable and the restrictions Script# could be bypassed (though hats off to Nikhilk). 

    I'd love to have a look when you've got something available. But I'd also be interested to know where you've hit problems as a result of the Roslyn limitations as I'm going to have a day prototyping something tomorrow. 

    p.s. I've just found this which looks interesting. It's not you is it?

    2012年3月10日 17:45
  • That's not me, but that indeed looks interesting. It seems a lot of work has been put into it already.

    As far as Roslyn limitations, I'm mostly referring to parts of the language that haven't been implemented yet. You can find a list of what parts are not implemented for the October CTP in one of the sticky posts at the top of the forum. And I've hit a couple of oddities that I traced back to bugs that have already been submitted.

    I'm planning to try to have something up on Codeplex and/or Github by end of the month. I'll come back and update this post with a link after that happens.

    2012年3月11日 18:23
  • For anyone interested, I managed to finally get an initial version of this up on github. It still needs a lot of work, but the basics are in place.

    https://github.com/vannatech/blade


    2012年6月11日 19:08
  • Nikhil did this on the asp.net team about 7 or 8 years ago. It's called Script#. It's amazing. It's the secret sauce Microsoft doesn't like to tell you about that powers a good chunk of their web apps.

    http://projects.nikhilk.net/ScriptSharp

    --pm

    2012年8月2日 9:24
  • I have created one based on the open source NRefactory: www.saltarelle-compiler.com
    2012年8月7日 19:22