You can use WebSharper and get it with F#. It even has commercial backing. Comes with a neat little RPC system so you can effortlessly decide which code runs where.
There were also other projects that allowed this with C#, I just forget their names.
I don't think so. It failed with Silverlight, and was nasty with ASP.NET webforms. Microsoft now champions ASP.NET MVC on the server and TypeScript on the client. They also use TypeScript to write huge JavaScript apps for consumers.
This might be a perfect backdoor in getting .NET into some frontend projects. Depending on the dev and PM, I find there can be significant pushback on going all-out using WebSharper or anything that isn't JS or close to it.
This way, the JS output can be considered source, checked in, diffs might make sense, and the real source could be hidden in a tarball until it's too late.
I get you can port some code,but you're not going to port your xaml code to javascript with this.How do you write dom manipulation in C# then compile it directly to usable javascript?
at first glance, i thought the mere edge cases alone (listed under limitations in the readme) would be sufficient reason to stay well away from this c# -> js route.
however on second glance ... there have been numerous times where I have written c# server side with 'UI Model' Classes that use to serialize to XML/json for consumption by the client/browser and corresponding models in javascript/typescript. The C# -> Typescript conversion would save me a lot of time (and automate keeping the two in sync) and I would imagine for that niche case it would be totally worth it.
I've used Typelite and T4TS to generate Typescript definition files (interfaces effectively) for my C# code. I'm not sure about going further than that and exposing logic.
It seems great! thanks! By .NET in this context, do you mean you translate from CIL to TypeScript? does it mean it works with any .NET language? also, it's amazing it's written in C#.
TypeScript's written in TS/JS? Yikes. Certainly better off writing it in a better language and then crosscompiling to JS for the people that want to do "npm install typescript".
I'm thinking that they probably didn't want to scare away web devs that don't like .NET.
I believe that their compiler also runs under Node.JS, which is easily a much lighter cross-platform solution than requiring Mono (which would be needed for a C# compiler).
I find that the TypeScript compiler is annoyingly slow and I cringe imagining a workflow that involves another compiler in front of the TypeScript compiler. Granted, you'd probably do most of your tests and such at the C# level and only step into JS as the final step... but iterating through those last steps would be annoying.
Especially when you consider a "just hit reload" development cycle as the competition.
Our TypeScript project is ~20K SLOC. It compiles in roughly (I haven't measured exactly) the same amount of time it takes to compile 100 SLOC.
Since the Typescript compiler itself is > 2MB of minified js, it doesn't surprise me that compiling any TS has at least a second overhead.
What's more important to me is that:
- The compiler performance scales as the codebase increases in size.
- Incremental builds are fast. (ie the -watch option).
So far I have found both to be true. Incremental builds take < .5 sec on my laptop. That means I get a cute red-squiggly in Visual Studio in a convenient amount of time. Ultimately, that's half the reason for using TS in the first place; if it didn't improve our productivity, we wouldn't be using it.
I wrote myself a similar tool for myself using NRefactory so I can fill you in:
I found that converting 10k of C# was incredibly quick and the overall build time was still totally dominated by the slow TypeScript compiler.
You are right that the development time is spent unit-testing C# and very rarely invoking the TS compiler so rather than making the workflow worse, it improves it immeasurably. The alternative to recompile TS each time and use Karma and Chrome dev tools is unbearably slow and clunky in comparison.
The real win I was after was that the quality of the test tools and debugger for .Net. Using a tool like TestDriven.Net from visual studio so from a r-click I have test coverage, performance, edit-and-continue and all the benefits of the Visual Studio debugger.
The generation to typescript is more of a publish step than part of the development cycle. I also convert the NUnit tests to Jasmine so I run the same test suite across the generated javascript. This does catch issues because there are differences, like lexical scoping, that my cs2ts tool did not try to solve.
I don't think the point here is to write your entire app in C#. TypeScript is already close enough.
I think the point is that you have some existing libraries that would be useful in a web application, you could go ahead and compile those down to TS and use them within your TS code.
Perhaps he's biased because he made TypeScript? Then again, this is from the main guy behind C#. The language that chose "delegate" as it's lambda keyword (fixed it later at least), decided tuples aren't worth supporting, went with C-style optional parameters after years of promoting overloads instead (both terrible ideas), and barely has type inference. (Just a few things that popped in the top of my mind.)
Write for the web seems like a lame excuse to not embrace better languages and deal with the issues in cross compilation.