Tag Archives: DuoCode

Hello DuoCode – translating C# to JavaScript!

via Hello DuoCode – translating C# to JavaScript!.

Once upon a time there was created a wonderful, general purpose programming language called C#. Many developers around the world embraced C#, and began writing all of their applications in C#, which ran on the user’s personal computers, and everyone was happy. Over the years, however, the landscape shifted – everything became more mobile, and there came a need to run some of those projects on the web. As it happened, the language of the web is JavaScript, and while it is ideal for writing applications that run in the browser, it’s not always possible (or viable) to rewrite significant parts of core business logic in JavaScript. There have been many attempts over the years to create languages that translate to JavaScript (TypeScript, CoffeeScript, to name a few), but none really provide the raw power and tooling, available to C# developers. Until now!

Enter DuoCode.

With DuoCode, our goal from the start was to create the best and most complete C# to JavaScript compiler, using the best technology available to date: the .NET Compiler Platform, formerly known as Microsoft “Roslyn”. Roslyn allows us to fully “understand” C# and all of its features (including the new C# 6 language features), and accurately convert them to corresponding JavaScript. With DuoCode, you use things like Generics, Reflection, LINQ and dynamic, while still enjoying full Visual Studio support for IntelliSense, syntax highlighting, and even debugging your original C# code in your browser!

Let’s start with our *Hello World” example. Given the following C# code: