
NetJs: A .NET to TypeScript and JavaScript compiler - yulaow
https://github.com/praeclarum/Netjs
======
neil_s
The day I can write C# on both the server and client, instead of js with
Node.js, I'll be soooo happy.

~~~
AsmMAn
Is not exactly this the universal(or something so) .NET platform new promise?

~~~
janekk
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.

------
edtechdev
Looks nice, I added it to this list of languages that compile to JavaScript
(in the "C#, F#, .NET related languages" section):
[https://github.com/jashkenas/coffee-script/wiki/List-of-
lang...](https://github.com/jashkenas/coffee-script/wiki/List-of-languages-
that-compile-to-JS)

------
MichaelGG
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.

------
Revex
Seems pretty neat. Sort of like a GWT for .Net. Except with the added benefit
of being able to go into an intermediary form of TypeScript.

I see something like this really being beneficial when building a Single Page
Application, or porting a Desktop Application to a SPA.

~~~
camus2
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?

------
samirahmed
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.

~~~
cmdkeen
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.

------
AsmMAn
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#.

------
camus2
why did not MS write a pure C# typescript compiler?

the js one is so slow it's barely usable. It should be priority 1! write
something in C# or even C++,that should'nt be that hard,or is it?

~~~
_random_
Marketing and politics.

~~~
AsmMAn
It may change now Microsoft and Mono are working in .NET platform together.

------
dangoor
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.

~~~
sherbet
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.

~~~
dangoor
Thanks for that bit of data. That makes good sense, and I should give it
another try.

------
rdo
Here's what Anders thinks about C# to js cross compilation at about 2m 20s
into this interview at Build.

[http://channel9.msdn.com/Events/Build/2014/9-010](http://channel9.msdn.com/Events/Build/2014/9-010)

"That is darn near impossible to do with any level of fidelity that is
meaningful"

"If you're going to write for the web, write for the web."

~~~
MichaelGG
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.

------
visualR
Excellent. How did you know I wanted this? =)

------
soundoflight
This is really cool. I would love to see this mature a bit more.

------
onatm
why don't you just compile to js?

[http://i.imgur.com/0DgQh4e.jpg](http://i.imgur.com/0DgQh4e.jpg)

