Wednesday, July 22, 2009

Silverlight makes it possible to script the browser with Python and Ruby (IronPython and IronRuby of course), but the experience is very different to working with Javascript. That could all change thanks to a new project from MIX Online Labs called Gestalt.

Gestalt is a library released by MIX Online Labs that allows you to write Ruby, Python & XAML code in your (X)HTML pages. It enables you to build richer and more powerful web applications by marrying the benefits of expressive languages, modern compilers, AJAX & RIAs with the write » save » refresh development model of the web.

Amongst its features it promises:

Make way for Ruby & Python, JavaScript!Gestalt lets you write Ruby & Python within script tags (or linked scripts) right in your (X)HTML pages allowing you to do everything and more you've been used to doing in the page with JavaScript.

Transparently compiled and blazing fastWhen a user visits a page that uses Gestalt, we harness the power of the Dynamic Language Runtime (DLR) to transparently compile any Ruby, Python & XAML blobs before running the scripts.

"Look, Ma. No tools!"You need nothing more than a text editor to build your web pages. Since we like TextMate, we decided to release a bundle for it that gives you productive features like XAML tab completion & more.

The short version is that Gestalt allows you to write code in script tags in your html pages (or loading external scripts) specifying Python or Ruby as the language. By including a specific Javascript file that activates Silverlight this code, which has full access to the browser DOM, is executed with the Dynamic Language Runtime.

Jimmy Schementi gives more details and some specific examples in a blog post:

A simple Ruby-based web page using Gestalt would look like this:Gestalt adds “ruby” and “python” to the languages supported by the <script> tag. You can also include other files rather than writing the code in the HTML page:

<script> tag. You can also include other files rather than writing the code in the HTML page: My first reactions when hearing about this project was “Holy crap, wow, they got Ruby and Python running in the browser, that’s freakin’ awesome!” But I work on the Silverlight integration with IronRuby and IronPython, already letting you write Ruby and Python in the browser instead of JavaScript. Hmm. Not to my surprise, Gestalt uses IronRuby and IronPython in Silverlight to accomplish this. But damn, wouldn’t it be awesome if this is how the world worked?

Miguel de Icaza also has a blog entry on Gestalt and its place in the Mono world:

This addresses a part of Silverlight's story that I always felt was less than ideal. Without the Gestalt script, developers using Ruby or Python had to package their software on a ZIP file before sending down to the client.

All four pieces (Gestalt, the Dynamic Language Runtime, IronRuby and IronPython) are open source technologies that run on either Microsoft's Silverlight or our own open source Moonlight.