Wednesday, October 01, 2008

Dynamic Languages in Silverlight 2 RC0

I've just released the Silverlight Dynamic Languages SDK with the newest DLR, IronRuby, IronPython, and JScript binaries and sources to work against Silverlight 2 RC0!

 

Download the SDK!

 

This release works with Silverlight 2 RC0. Keep in mind this is a developer release, so no "end-user" runtime exists. This is why the "not-installed" experience doesn't take you directly to the download, but to a page where you can install the tools.

As usual, report any issues on the Issue Tracker, and feel free to ask any questions on the Discussions tab.

This release has slightly refactored Microsoft.Scripting.Silverlight, adding two new types: "Package" and "Configuration". You can use "Package" to access files inside the XAP, and "Configuration" can be used to detect languages available in Silverlight.

Hosting

In past releases, if you wanted to host the DLR you needed to create your own ScriptRuntimeSetup which uses Microsoft.Scripting.Silverlight.BrowserScriptHost to tell your hosted scripts about how Silverlight. Your code would look like this:

using Microsoft.Scripting.Silverlight;
using Microsoft.Scripting.Hosting;

//...

var setup = new ScriptRuntimeSetup();
setup.HostType = typeof(BrowserScriptHost);
var runtime = new ScriptRuntime(setup);

//...

Now, since the ScriptRuntimeSetup we use to run user code is public, you can simply this code to:

using Microsoft.Scripting.Silverlight;
using Microsoft.Scripting.Hosting;

//...

var runtime = DynamicApplication.Current.Runtime;

// or if you wanted to create your own runtime, reuse the setup

var runtime = new ScriptRuntime(DynamicApplication.Current.Runtime.Setup);

//...

Future

Blah, blah, blah, I always talk about the future. Has anything happened? Nope. Well, it will eventually. Just keep pestering. If you have no idea what I'm talking about, take a look at my last post.

3 comments:

Eloff said...

RC0 slipped in one major breaking change with regard to dynamic languages.

Font URI is Restricted to Assembly Resource
Who Is Affected: Silverlight 2 Beta1 or Beta 2 applications (not Silverlight 1.0 applications) that reference fonts (or zip of fonts) via the URI syntax in the Control.FontFamily, TextBlock.FontFamily or Glyphs.FontUri attributes and where the fonts are not embedded within the assembly (dll) of the control or application.
Fix Required
You can specify a font (or in some cases a zip of fonts) in URI format via the Control.FontFamily, TextBlock.FontFamily and the Glyphs.FontUri attributes. If you are, you will need to ensure your font is marked as a "resource" in the project system.

What does that mean for us dynamic language guys? We have no compile time resources or assemblies. How can we still use custom fonts?

Jimmy Schementi said...

That it did, and it sucks. That's why "3dtext" was removed from the samples ... it depended on loading a custom font for the Glyphs. When this was announced, I screamed bloody murder and no one listened. It was removed because a "major customer" had concerns about font protection. Which is stupid, since assembly resources are no more protected than inside the XAP.

Anyway, long story short, I'm trying to come up with a solution that will work in the short-term (maybe building some functionality into Microsoft.Scripting.Silverlight to allow this), and then how to fix this for the next SL release. Ugh. Betcha Moonlight will let us do it ;)

Eloff said...

Wow, that is stupid. Sometime I'd like to create a little Silverlight font ripper and release it to the web as my way of getting even :)

Good luck finding a workaround for this.