Script# - bringing the C# developer experience to the JavaScript/AJAX world

Thursday, May 25, 2006 6:24 AM
Microsoft MVP Logo

[via Nikhil Kothari]

Nikhil’s blog is one of those that no matter how infrequent he posts, I’ll never delete the subscription and always read his posts before others. Why? Because his work and posts are genuinely new and forward thinking.

He’s one of the primary drivers behind ATLAS. He’s also the guy behind the Web Development Helper that I’ve blogged about in the past (and continue to use). He’s at it again…

Earlier this week, he dropped a post on his blog about a side project he’s been working on: Script#:

Script# brings the C# developer experience (programming and tooling) to Javascript/Ajax world. Yep, I am finally publicly sharing a spare time project I've been working on the side in an off and on manner for some time now.

A Better Scripting EnvironmentThe fundamental goal was to improve the state of the art in scripting. This goes way beyond the usual things that come to mind at first thought: compile-time checking, and intellisense or statement completion. I do think these are super-useful, and would be valuable in and of themselves. As we worked on Atlas we were also thinking of a great tools experience, and we explored different approaches and technologies for achieving this. Script# is a prototype of one such exploration. It attempts to address some programming environment requirements:

  • A clean language with the natural constructs. Today with script, you can go a long ways in simulating OOP (classes, interfaces, inheritance etc.), but the simulations are thrown at the face of the developer. Various C# constructs such as properties, events, and syntax for defining inheritance go a long way in making the code readable. Similarly modifier keywords like public vs. protected vs. internal, sealed vs. virtual etc. help define a better object model. All of this can be brought into the scripting world.
  • Easier refactoring and exploration. Script development could benefit immensely from the refactoring, and class browsing support already present in the IDE and in tools such as .NET Reflector. Both lend themselves to having a more manageable code base over time.
  • Ability to generate documentation. Again doc-comments from C# and the existing infrastructure could be leveraged here.
  • Ability to customize the script code easily. For example, I'll show debug vs. release and minimization below. The same idea could apply to building a version of the script that had more error checking or logging built in when you do need to run diagnostics. The approach could also be used to include instrumentation for the purposes of profiling, measuring code coverage, etc. Another interesting aspect of this project is that it will be able to generate script catering to multiple script profiles such as the current Javascript language, as well as Javascript 2 when it appears.

If you didn’t draw the link here’s the skinny: Today, when you build a C# class library, Visual Studio (or MSBuild) generates MSIL. Script# enables you to build a C# class library but instead of building to MSIL, you build to JavaScript. All the while, you get to keep your rich development experience (debugging & intellisense), even getting intellisense for the browser DOM.

This is ~way~ cool and has already generated quite a buzz (63 comments within 3 days). He’s posted a short 10 minute video of using Script# to create a C# class library and building a DLL and associated JS file you can use in your web project.

Admittedly, it’s not even at the CTP stage… it’s a genuine prototype. Just think… the ability to have a rich development and debugging experience in Visual Studio and build JavaScript… well to me that’s incredible. Can’t wait to play with the prototype!

» Script# Prototype

comments powered by Disqus