C-Sharp as a scripting language

scriptcs.net logo Here’s a cool technology you might not have heard of: scriptcs. Gives you the ability to use C# as a scripting language. It does this using the Rosyln compiler. So here’s an example below, taken directly from the scriptcs website:

using System;
using System.IO;
using System.Web.Http;
using System.Web.Http.SelfHost;

var address = "http://localhost:8080";
var conf = new HttpSelfHostConfiguration(new Uri(address));
conf.Routes.MapHttpRoute(
	name: "DefaultApi", 
	routeTemplate: "api/{controller}/{id}", 
	defaults: new { id = RouteParameter.Optional }
);

var server = new HttpSelfHostServer(conf);
server.OpenAsync().Wait();
Console.WriteLine("Listening...");
Console.ReadKey(); 

This is a simple way to startup a self-hosted server. But look at the various missing pieces here, no project file, no solution, no classes, no references (they happen through nugget packages) just a quick, frictionless, server. How elegant. scriptcs was started by Glenn Block (he contributed to WCF, MEF, node.js for Azure, among other things).

Comments