Category Archives: Silverlight

Updating the Simple Silverlight Countdown Blog badge

image When I was preparing for RIAPalooza, I created and blogged about Creating a Simple Silverlight Countdown Blog badge.

It was great but I wanted to updated it for the next event and realized that recompiling it was not really a user friendly option. The answer is that I updated the widget to have a level of parameterization so that I could easily update it without having to recode everything.

*Update – Source Code

The good news is that there’s a mechanism called InitParams that allows you to pass in initialization parameters on startup. I’m not wild about the mechanism itself as it’s just a key-value pair string and not individual parameters but it works. The alternative is to do something where you write some javascript that will call into the Silverlight object and set parameters. While that works, it wasn’t my first choice because you have to worry about the order of events, exposing objects as scriptable and so on.

<object data="data:application/x-silverlight-2," 
type="application/x-silverlight-2" width="100%" height="100%"> . . . <param name="initParams"
value="eventDate=01/13/2010,registrationUrl=www.codemash.com,
registerText=Check it out!,startImageUrl=logo_codemash_2010.jpg,
endImageUrl=logo_codemash_2009.jpg" /> . . .
</object>

Notice that there are multiple parameters here separated by commas. The first one is a date and the second one is a URL and so on.

To access that init parameter in the startup you need to open the App class found in App.xaml.cs and in any method use the Host object’s InitParams list.

string fieldValue = this.Host.InitParams[key];

For a lot of reasons, I wrap that up in a method as follows:

private string GetInitParam(string key)
{
    string fieldValue = "";
    if (this.Host.InitParams.ContainsKey(key))
    {
        fieldValue = this.Host.InitParams[key];
    }
    return fieldValue;
}

This allows me to quickly add a lot of new parameters and write the OnStartup method as follows:

private void OnStartup(object sender, StartupEventArgs e)
{
    string DateTimeString = GetInitParam("eventDate");
    DateTime eventDate = DateTime.MinValue;
    if (DateTimeString.Length > 0)
    {
        try
        {
            eventDate = DateTime.Parse(DateTimeString);
        }
        catch { }
    }

    string backGroundUrl = GetInitParam("background");
    string startImageUrl = GetInitParam("startImageUrl");
    string endImageUrl = GetInitParam("endImageUrl");
    string registrationUrl = GetInitParam("registrationUrl");
    string registerText = GetInitParam("registerText");

    // Load the main control here
    this.RootVisual = new Page(
        eventDate,
        backGroundUrl,
        startImageUrl,
        endImageUrl,
        registrationUrl,
        registerText);
}

Notice that I’m calling a custom constructor on the Page class. That looks as follows:

Timer _timer = null;
public Page()
    : this(DateTime.Now, "", "", "", "", "")
{}
public Page(DateTime eventDate, string backGroundImageUrl, 
string imageStartUrl, string imageEndUrl,
string registrationUrl, string registrationText) { EventDateTime = eventDate; // Required to initialize variables InitializeComponent(); if (backGroundImageUrl.Length > 0) { backGroundImage.Source = new BitmapImage(new Uri(backGroundImageUrl, UriKind.Relative)); } if (imageStartUrl.Length > 0) { image.Source = new BitmapImage(new Uri(imageStartUrl, UriKind.Relative)); } if (imageEndUrl.Length > 0) { image1.Source = new BitmapImage(new Uri(imageEndUrl, UriKind.Relative)); } if (registrationUrl.Length > 0) { linkRegistrationButton.NavigateUri = new Uri("http://" + registrationUrl); } if (registrationText.Length > 0) { linkRegistrationButton.Content = registrationText; } _timer = new Timer(new TimerCallback(Timer_Tick), null, 0, 1000); AnimateLogos.AutoReverse = true; AnimateLogos.RepeatBehavior = new RepeatBehavior(1000); AnimateLogos.Begin(); }

That’s all that was required for making it parameterized so that I can update it quickly.

Creating a Simple Silverlight Countdown Blog badge

image I’m going to be speaking at RIAPalooza in about two weeks, well more specifically at the time of this writing it’s 10 days, 12 hours, 48 minutes and 45 seconds. 🙂

I’m going to be tag teaming with Mike Labriola again talking about “10 questions about RIA you haven’t had the courage to ask”. We’ve got a short list of questions but are hoping to get some questions from the crowd as well. If you happen to have any questions, feel free to shoot them to me in the comments section on this post.

Anyways, we were discussing different ways to get the word out about RIAPalooza and someone mentioned that we didn’t have have a blog badge so I decided to create one.

I started by grabbing some art from the RIAPalooza web site. I started out in Expression Blend with a simple Silverlight project. Here are the steps that I took.

  1. Resize the Page.xaml user control to 100×200 to fit the blog badge size.
  2. Add the wood background that I grabbed from the RIAPalooza web site trimmed down to the blog badge size.
  3. Paste in the two other images, one for the logo (referred to as i and one for a a free t-shirt offer.
  4. Animate the two images to wiggle, spin, wiggle, wait, wiggle, spin, wiggle, wait, reverse.
    •  image
      To do this, I opened a timeline and started by rotating the first image -6 degrees and then a frame later rotating it to 6 degrees and then a frame later back to 0. This gives the images a nice little wiggle and catches the viewer’s eye without being too annoying. Well, I don’t think it’s too annoying but you can tell me…
    • image
      Then I kicked forward 2 seconds and did the wiggle again in preparation of swapping to two images. The wiggle makes a nice little transition before the action starts.
    • image
      At the end of the wiggle, I spun the image on it’s X axis over the span of half a second. That’s accomplished by setting the X Skew to zero.
    • On the same frame that the first logo hits an X Skew of zero, I make the other image visible with it’s X Skew to zero an proceed to transform it’s skew to 1 (normal) over the course of a half second.
    • Then I wiggled the t-shirt offer image in the same manner that I did the first logo.
    • Now, back in the code, I set a few properties and started the animation.
      AnimateLogos.AutoReverse = true;
      AnimateLogos.RepeatBehavior = new RepeatBehavior(1000);
      AnimateLogos.Begin();
  5. Now that the logos are moving, I needed a link to the site. Simple enough using a HyperLinkButton.
  6. Last thing I needed was to provide some type of count down. At first I just used a couple of labels and set the text.
    • First, I used a timer set to go every second and set the time
      _timer = newTimer(newTimerCallback(Timer_Tick), null, 0, 1000);
    • Next I used the dispatch object to work on the UI thread as follows:
      public void Timer_Tick(object state)
      {
          Dispatcher.BeginInvoke(() =>
            {
                try
                {
                    DateTime launchDate = new DateTime(2009, 5, 8, 8, 0, 0).ToUniversalTime();
                    TimeSpan span = launchDate.Subtract(DateTime.Now.ToUniversalTime());
      
                    txtDays.Text = string.Format("{0} Days", span.Days);
                    ...
                }
                catch
                {
                    //Eat all errors. We'll get another chance in a second...
                }
            }
          );
      }

There are a couple of things to notice about the code above. First, I just used everything as UniversalTime. I thought about trying to do the whole timezone thing but realized that it didn’t matter for a countdown because as long as everything was in the same timezone the math would be right.

Second, notice that I’m eating all of the errors in the timer. The basic error that I can get from this code is a threading issue and since this is low priority code, I didn’t care about the threading issue. It’s not like there’s a real recovery path other than trying again in a second.

Now that I had the simple countdown and badge done, I decided that I didn’t like the flat labels and wanted a real clock style count down. To accomplish this I started a Silverlight FlipClock project to build a reusable clock face.

Since I was creating a flipping clock with a separate top and bottom, it made sense to create a control to encapsulate those bits in user controls that I could reuse. There were two interesting parts here. First, how to get the text to cut off at the top and second, how to get the text to scale correctly with the number if we resized it.

image The first issue was solved by using a brush that cut off to an opacity of zero just under halfway. I did that on both the background and the textbox. The whole gradient is actually made up of three stop points. Two set to be the same color and opacity of 100% and a third that is set to the same color but opacity of zero. This third stop is just a hair further down than the second. The purpose of the second stop is to keep it from fading from top to bottom rather than having the hard like that I desired.

<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
    <GradientStop Color="#FFFFFFFF" Offset="0"/>
    <GradientStop Color="#FFFFFFFF" Offset="0.48"/>
    <GradientStop Color="#00FFFFFF" Offset="0.49"/>
</LinearGradientBrush>

The second issue was solved thanks to Laurent Bugnion. He pointed out that although Silverlight doesn’t have a scalable font, there is a VIewbox in the Silverlight Control Toolkit on Codeplex that will scale anything inside itself correctly.

<controls:Viewbox Height="Auto" HorizontalAlignment="Stretch" Margin="0,0,0,0"
VerticalAlignment="Stretch" Width="Auto" Content="Viewbox" Stretch="Fill">
<Grid x:Name="LayoutRoot" Background="{x:Null}">
. . .
</Grid>
</controls:Viewbox>

I added a simple property to set the value in the textbox.

public int Value
{
    get
    {
        return int.Parse(txtNumber.Text);
    }
    set
    {
        txtNumber.Text = value.ToString();
    }
}

Then I just played with the styling a little with a slight highlight on the top and the like.

Next, I created a FlippingNumber control that would be the base for the various numbers on the clock. To make it look right,  I actually needed 4 sections to the control. Two to show the current number and two to show the next number and we flip between them. I simply put two of the top and two of the bottom number controls one the page. The flip was just an animation similar to the flipping of the two images in the top of the badge. The only difference is that I skewed the controls a little to give it a slight 3d effect.

Once that was done, the rest of the number was built in code.

public FlippingNumber()
{
    InitializeComponent();

    FlipDown.Completed += new EventHandler(FlipDown_Completed);
}

void FlipDown_Completed(object sender, EventArgs e)
{
    numBottomBack.Value = _val;
    numTopFlip.Value = _val;
}

int _val = -9999;
public int Value
{
    get
    {
        return _val;
    }
    set
    {
        if (value != _val)
        {
            _val = value;
            numBottomFlip.Value = _val;
            numTopBack.Value = _val;

            FlipDown.Begin();
        }
    }
}

The other property that I added was so that the clock could adjust the speed at which the number flipped.

public double SpeedRatio
{
    get
    {
        return FlipDown.SpeedRatio;
    }
    set
    {
        FlipDown.SpeedRatio = value;
    }
}

Finally, I was ready to piece together the clock. That was a simple matter of placing 6 of the flipping number controls on the clock face. All that was left was set the time on the clock based on a value in the passed in TimeSpan.

TimeSpan _timeSpan;
public TimeSpan TimeSpan
{
    get
    {
        return _timeSpan;
    }
    set
    {
        _timeSpan = value;

        numSecondOne.Value = FirstCharacter(_timeSpan.Seconds);
        numSecondTwo.Value = SecondCharacter(_timeSpan.Seconds);

        numMinuteOne.Value = FirstCharacter(_timeSpan.Minutes);
        numMinuteTwo.Value = SecondCharacter(_timeSpan.Minutes);

        numHourOne.Value = FirstCharacter(_timeSpan.Hours);
        numHourTwo.Value = SecondCharacter(_timeSpan.Hours);
    }
}

private int FirstCharacter(int num)
{
    string s = string.Format("{0:00}", num);
    return int.Parse(s.Substring(1, 1));
}

private int SecondCharacter(int num)
{
    string s = string.Format("{0:00}", num);
    return int.Parse(s.Substring(0, 1));
}

The last thing on the badge that I did was change the timer control code on the overall blog badge to pass the time span into the clock face rather than parsing it into textboxes.

Now I wanted people to be able to use it from their own blog. To allow that to happen, I needed a put together a cross domain policy via the clientaccesspolicy.xml file.

<?xml version="1.0" encoding="utf-8"?>
<access-policy>
    <cross-domain-access>
        <policy>
            <allow-from http-request-headers="*">
                <domain uri="*"/>
            </allow-from>
            <grant-to>
                <resource path="/resources/SilverCountDown.xap" include-subpaths="true"/>
            </grant-to>
        </policy>
    </cross-domain-access>
</access-policy>

Notice that I’m allowing access from any domain but restricting access to only load the specific xap file.

Anyone who wants to put it on their blog can do so simply by leveraging the following object tag.

<div id="silverlightControlHost">
    <object data="data:application/x-silverlight," 
type="application/x-silverlight-2" width="100px" height="200px"> <param name="source" value="http://www.joshholmes.com/resources/SilverCountDown.xap"/> <param name="background" value="white" /> <param name="minRuntimeVersion" value="2.0.31005.0" /> <param name="autoUpgrade" value="true" /> <a href="http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;"> <img src=http://go.microsoft.com/fwlink/?LinkId=108181
alt="Get Microsoft Silverlight" style="border-style: none"/> </a> </object> <iframe style='visibility:hidden;height:0;width:0;border:0px'></iframe> </div>

Feel free to place the badge on your own blog to help promote RIAPalooza – When this year finishes, I’ll update the counter with next years dates as soon as we know it… 🙂

Also – I put the code up at http://www.joshholmes.com/resources/silvercountdown.zip. Feel free to take it and play with it.

UI Design for Developers Series, by Total Training.

image

I’m at an internal conference at Microsoft this week and one of the sessions that I attended was called Practical Design tips and tricks for Developers. It was a set of hands on labs that were created out of the Expression team. It was really slick and I learned a whole lot of new techniques and am feeling a whole lot more confident in my Expression Blend abilities. The really slick part is that you get to work through those same labs if you are interested because they have been posted on Arturo’s blog.

This 13 part video series will walk you through creating a workable color palate with a range of colors which all work together, creating brush resource out of those, creating shapes all the way from simple straight and curved lines to glass button effects with the simplest possible steps and really sets you up with the basics of what you need to know. It was really cool to be able to walk through those labs.

The labs are as follows:

1Principles of Design Series:  Learning about Balance using Expression Design

2Principles of Design Series:  Learning about Rhythm using Expression Design

3Principles of Design Series:  Learning about Emphasis using Expression Design

4Principles of Design Series:  Learning about Symmetry and Asymmetry using Expression Design

5Principles of Design Series: Learning about Unity using Expression Design

6Principles of Design Series:  Learning about Points, Lines, and Form using Expression Design

7Choosing Colors to Complement Your User Interface with Expression Design

8 – Experimenting with User Interface Colors with Expression Design

9 – Creating Mosaic and Tiled Patterns using Expression Design
10 – Learning to Create Icons using Expression Design
11 – Creating a Sample Icon using Expression Design
12 – Designing a Glassy Button using Expression Design
13 – Applying Effects to Bitmap Images using Expression Design

 

For links to the videos and digital assets that you need to accomplish the the labs, check out Arturo’s post on it at ux.artu.tv » Blog Archive » New Video Series: UI Design for Developers Series, by Total Training.

Ann Arbor Day of .Net

Wow I’ve been swamped. There’s so much to blog about in the past couple of weeks so I’m just going to catch some of the highlights.

Ann Arbor Day of .NET was on 5/5/2007. It was fantastic! It sold out at 250 people and of that there were 210 people show up. That’s actually really good as most free events have a 40% droppoff and they had less than 20% droppoff. The only downside on the day was that with less than a 20% droppoff – pizza was a little short at lunch.

They are actually thinking about going to every 6 months instead of every 12 months. I think this would be fantastic!

I kicked off the day with a session on User Experience technologies at Microsoft. I borrowed from some of the materials that we are putting together for the upcoming ArcReady (Check the site for dates and times across the entire central region – Detroit on 5/25 in two weeks for all those that attended Day of .Net). We dipped into WPF, AJAX and Silverlight. My favorite demo is the Silverlight Airlines Demo. It shows a truly out of the box user experience that’s not all glitz and glammor but a truly solid UI for a true business application. Many of the demos, while showing off the platform really well, are marketing apps that show lots of 3D and animation. My customers often look at the glitzy demos and say that they are not doing 3D so they don’t look at the technologies. What they are missing is that there are real benifits here with enabling truly rich interfaces that go well beyond text and pictures.

I had two more 30 minute sessions. In both of those sessions the overwhelming requests were to have more Silverlight content. I had nothing prepared for these sessions but they went really well. In the first session, I pulled Don Burnett, who started Michigan Interactive Designers, out of the crowd and asked him to do a tour around Expression Blend and Silverlight. He got up, completely unscripted, and did a fantastic job! I will definitely be bringing him in to do more demos and presentations – especially when we have a designer based crowd. It turns out that he used to work with Bill Wagner (my former business partner when I was at SRT Solutions) on the Lion King Animated Storybook.

In the second session, I was on my own but I showed Top Banana, the DLRConsole (python and javascript version – IronRuby will be released as a CTP from CodePlex later this year) and talked about the .NET support in Silverlight 1.1 Alpha. Yes – I actually wrote some Python and did a simple overview for people at the conference. It was a fun day!

Here are some of the resources that we talked about during the three talks:

•Windows Forms @ .NET FX Developer Center
http://windowsclient.net

•WPF @ MSDN Developer Center
http://msdn.microsoft.com/winfx/reference/presentation/default.aspx

•.NET 3.0 (WPF, WCF, WF) Community Site
http://windowsclient.net/

•Silverlight
http://www.silverlight.net

•ASP.NET AJAX @ ASP.NET Developer Center
http://msdn.microsoft.com/winfx/reference/presentation/default.aspx

•ASP.NET AJAX Community Site
http://ajax.asp.net/

•DirectX @ DirectX Development Center
http://msdn.microsoft.com/directx/

•Microsoft Visual Studio @ Visual Studio Developer Center
http://msdn.microsoft.com/vstudio/

•Microsoft Expression
www.microsoft.com/expression

 

Day of .NET site

Link to Day of .Net in Ann Arbor 2007 – Home

Don Burnett’s write-up of the event.

Link to Don.NET’s WPF Designers Blog: Eastern Michigan Day of Dot Net

 

Playing with JSON

Silverlight Plasma ReactorI was asked on Friday by a friend how one can consume JSON in Silverlight. At the time, I just said start with the System.Json namespace and I’ll get you a sample later. Well, here’s a sample and a peek into my head because I couldn’t just stop with creating the sample that he needed.

Download Solution – PlayingWithJSON.zip

*Update – gotta do a quick shoutout to Leon Gersing for his passionate defense of JavaScript and JSON. It’s part of what inspired me to spend as much time on this as I did.

Really short JSON overview

JSON, for those of you who don’t know, is a really simple data format heavily used with JavaScript. It’s a lot smaller and lighter than XML.

This is the JSON that I’m using in this example. As you can see, it’s just name/value pairs with a little bit of extra formatting. Curly Braces separate objects in a list. Commas separate values. Colons separate the names from the values. 

[
{“FirstName”:”Etta”,”LastName”:”James”,”Url”:”http:\/\/www.etta-james.com\/”},{“FirstName”:”Billie”,”LastName”:”Holiday”,”Url”:”http:\/\/www.billie-holiday.net\/”},{“FirstName”:”Ella”,”LastName”:”Fitzgerald”,”Url”:”http:\/\/en.wikipedia.org\/wiki\/Ella_Fitzgerald”}]
}

Creating the JSON service with ASP.NET MVC Framework

The first thing that I did was slap together an ASP.NET MVC Framework application to produce the JSON and host the Silverlight application. This was remarkably easy. I decided against going through the effort of creating a database because that’s not really the point of the exercise.

I created a simple class that to fill out and serialize and then returned it from a controller.

public class Artist
{
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public string Url { get; set; }
}

The next step was to create a simple controller that would return my list as JSON. As you can see, there’s a JsonResult that you can return right from a controller method.

public class ArtistsController : Controller
{
    public JsonResult GetAll()
    {
        List<Artist> artists = new List<Artist>();

        artists.Add(new Artist("Etta", "James", "http://www.etta-james.com/"));
        artists.Add(new Artist("Billie", "Holiday", "http://www.billie-holiday.net/"));
        artists.Add(new Artist("Ella", "Fitzgerald", "http://en.wikipedia.org/wiki/Ella_Fitzgerald"));

        return Json(artists);
    }
}

To test it, I just browsed to http://localhost:mylocalport/artists/getall. That returned the JSON file. As the browser doesn’t display JSON auto-magically, it prompted me to download a file and save it off.

Now, take notice of the URL. The ASP.NET MVC Framework is producing what’s called a RESTful Service. The parameters and all are simply in the URL. In the URL, “artists” takes us to a particular Controller called the ArtistsController and the “getall” calls the “GetAll()” method on that controller. We can further specify parameters and the like in the URL. Scott Guthrie has a great article that explains the URL routing and all at http://weblogs.asp.net/scottgu/archive/2007/12/03/asp-net-mvc-framework-part-2-url-routing.aspx.

Now that we are producing JSON from a services, we are ready to create a client.

Getting the JSON from the RESTful service.

The first client that I tried was the straight up System.Json namespace client. Since we are using a RESTful service, we can’t generate the proxy object in the same way that we’re used to with SOAP. Instead, we need to leverage the WebClient object.  This is done as follows:

void mainButton_Click(object sender, RoutedEventArgs e)
{
    Uri serviceUri = new Uri("/Artists/GetAll", UriKind.Relative);
    WebClient downloader = new WebClient();
    downloader.OpenReadCompleted += new OpenReadCompletedEventHandler(downloader_OpenReadCompleted);
    downloader.OpenReadAsync(serviceUri);
}

Notice that the URL that I’m using is relative. You can specify the full URL if the service is not on your own server. These calls, as all calls in Silverlight, are async. Therefore I wire up the downloader_OpenReadCompleted event and call OpenReadAsync. Simple enough?

Leveraging System.Json

Once the downloader returns, I can get the result off of the event arguments. Load is a static method on the JsonArray that will automatically parse out the results from the stream object. Then, I can just loop over the objects in the array and use them to fill out my own type that I’m ready to databind to.

void downloader_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
    JsonArray jsonArray = (JsonArray)JsonArray.Load(e.Result);

    List<Artist> artists = new List<Artist>();

    foreach (JsonObject jsonArtist in jsonArray)
    {
        Artist artist = new Artist();
        artist.FirstName = jsonArtist["FirstName"];
        artist.LastName = jsonArtist["LastName"];
        artist.Url = jsonArtist["Url"];

        artists.Add(artist);
    }

    dataGrid1.ItemsSource = artists;
}

This was fairly straight forward and simple, but I wasn’t ready to be done yet.

Leveraging LINQ

The next thing is to try LINQ against this JsonArray and see what happens.

void downloader_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
    JsonArray jsonArray = (JsonArray)JsonArray.Load(e.Result);

    var query = from artist in jsonArray
                select new Artist
                {
                    FirstName = (string)artist["FirstName"],
                    LastName = (string)artist["LastName"],
                    Url = (string)artist["Url"],
                };

    List<Artist> artists = query.ToList() as List<Artist>;
    dataGrid1.ItemsSource = artists;
}

Personally, I think that the LINQ version is a lot more powerful. It’s not immediately obvious in this simple example but there’s a ton that I could do with the LINQ query from filling out sub-types to filtering and so on.

JSON in JavaScript

JavaScript ReferenceBut then I started thinking about all of the different ways that one can get and parse out JSON directly in JavaScript (I mean it does have JavaScript right in the name).

First, I did it the old school way that I used to do back when I was doing a ton of JavaScript development.

Quick note here – before you start copying this code – this is NOT the way to do this in the modern era. I did it to prove a point. You really need to be leveraging one of the many great JavaScript frameworks that are out there in order to accomplish your JavaScript today. I’ll get to those in a minute.

Short version, you’re going to be doing an XMLHttpRequest directly. When that returns you’ll get an “onreadystatechange” event which you can respond to. If it’s actually ready, then you can call a JavaScript function called eval that will return and array of objects parsed out from the string that you pass in.

<script language="javascript" type="text/javascript">
    function GetJson(url) {
        // Create xmlhttprequest object
        var xmlhttp = null;
        if (window.XMLHttpRequest) {
            xmlhttp = new XMLHttpRequest();
            //make sure that Browser supports overrideMimeType
            if (typeof xmlhttp.overrideMimeType != 'undefined') {
                xmlhttp.overrideMimeType('text/xml');
            }
        }
        else if (window.ActiveXObject) {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        else {
            alert('Perhaps your browser does not support xmlhttprequests?');
        }

        // Create an HTTP GET request
        xmlhttp.open('GET', url, true);

        // Set the callback function
        xmlhttp.onreadystatechange = function() {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                var json = xmlhttp.responseText;

                var artists = eval(json);

                var newArtistList;
                newArtistList = "<ul>";

                for (var i in artists) {
                    var artist = artists[i];
                    newArtistList += "<li>"
                    + artist.FirstName + " "
                    + artist.LastName
                    + "</li>"
                }

                newArtistList += "<ul>";

                outputControl = document.getElementById("divOutput");
                outputControl.innerHTML = newArtistList;
            } else {
                // waiting for the call to complete
            }
        };

        // Make the actual request
        xmlhttp.send(null);
    }
</script>

Alright, that’s a lot of JavaScript to get through and understand. There are multiple possible problems here. First, that’s just a ton of code. Second, the same eval function that you are calling here is the same eval function used to dynamically execute a piece of JavaScript in a string. This means that you’re open to all kinds of possible attacks. Finally, there are a ton of frameworks that have come up in the past handful of years.

So, let’s go look at some of those frameworks.

Leveraging MS AJAX

The AJAX framework that I’ve been trying to learn lately is the MS AJAX one. It’s got a lot of power. First, notice that the WebRequest actually looks a lot like what I did in C#. Next, notice the JavaScriptSerializer object. This gives me some nice and easy serialization to and from JSON. The reason to use this is that it’s a much safer mechanism than eval. Lastly, notice the $get at the end. This is a nice and easy selector that does all of the heavy lifting of finding the object in the DOM and the like.

<script src="../../Scripts/MicrosoftAjax.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
    function GetJson() {
        var request = new Sys.Net.WebRequest();
        request.get_headers()['Content-Type'] = 'application/json; charset=utf-8';
        request.set_url('/Artists/GetAll');

        request.add_completed(Function.createDelegate(null, DisplayArtists));
        request.invoke();
    }

    function DisplayArtists(executor) {
        if (executor.get_responseAvailable()) {
            var json = executor.get_responseData();
            var artists = Sys.Serialization.JavaScriptSerializer.deserialize(json);

            var newArtistList;
            newArtistList = "<ul>";

            for (var i in artists) {
                var artist = artists[i];
                newArtistList += "<li>"
                + artist.FirstName + " "
                + artist.LastName
                + "</li>"
            }

            newArtistList += "<ul>";

            $get("divOutput").innerHTML = newArtistList;
        }
    }
</script>

This is a lot less code and a lot safer than what I was doing in raw JavaScript. However, I thought I should try this with a few more frameworks.

Leveraging Prototype

image A framework that I’ve used for a while and really like is Prototype.

This is a whole lot less code. Notice the “Ajax.Request”. That packages up all of the work of doing the network call behind one simple to use function. And on the response is a nice and easy method called evalJSON that will parse out the JSON string to an array of objects that you can loop over. Finally, notice the $() selector.

<script src="../../Scripts/prototype-1.6.0.2.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
    function GetJson() {
        new Ajax.Request('/Artists/GetAll', {
            method: 'get',
            onSuccess: DisplayArtists
        })
      }

      function DisplayArtists(transport) {
        var json = transport.responseText.evalJSON();
        var newArtistList;
        newArtistList = "<ul>";

        json.each(function(artist) {
            newArtistList += "<li>"
                    + artist.FirstName + " "
                    + artist.LastName
                    + "</li>"
        });

        newArtistList += "<ul>";

        $("divOutput").insert(newArtistList);
    }
</script>

I liked this a lot. A feature that I didn’t take advantage of is that Scriptaculous, which is a fantastic set of JavaScript libraries for visualization, weaves in with Prototype really easily.

Leveraging jQuery

image The last JavaScript framework that I tried was jQuery. One extra cool part about this one for me is that I get intellisense right in Visual Studio. Check out Scott Guthrie’s post on jQuery Intellisense in VS2008 to see how to enable it.

Notice that it’s got the same type of easy to use function that packages up the call to get the JSON. Since it knows that it’s JSON, the variable returned to the callback is already parsed out into a usable object. And lastly, notice the $() selector again. There is a subtle difference between this one and the Prototype selector in that the jQuery one uses a # to signify that it’s looking for an ID, . to signify objects with a given class and so on.

<script language="javascript" type="text/javascript">
    function GetJson() {
        $.getJSON("/Artists/GetAll",
          {},
          DisplayArtists);
      }

      function DisplayArtists(data) {
          var newArtistList;
        newArtistList = "<ul>";

        for(var i = 0; i < data.length;i++)
        {
            var artist = data[i];
            newArtistList += "<li>"
                + artist.FirstName + " "
                + artist.LastName
                + "</li>"
        }

        newArtistList += "<ul>";

        $("#divOutput").html(newArtistList);
    }
</script>

Now that I was done playing with different JavaScript libraries, I thought I’d see if I could piece it all back together.

Leveraging jQuery and Silverlight

I decided to try jQuery and Silverlight together, leveraging jQuery to get and parse the JSON and Silverlight to do the display. This turned out to be remarkably simple.

First, in order for Silverlight to call into the JavaScript, you just have to call HtmlPage.Window.Invoke. That dynamically looks up and executes the method named in the first parameter.

void mainButton_Click(object sender, RoutedEventArgs e)
{
    HtmlPage.Window.Invoke("GetJson", "/Artists/GetAll");
}

Now, I could have wired up the JavaScript to listen for the button click event directly but that’s a lot more code than what I’ve got here.

Next I had to enable the Silverlight objects for callbacks. Step 1 is to Register the class with the browser’s scripting engine.

public LeveragingJQuery()
{
    InitializeComponent();
    HtmlPage.RegisterScriptableObject("LeveragingJQuery", this);
...
}

Step 2 is to declare one of the methods as a ScriptableMember. This gives the scripting engine access to the method in question. There’s also ScriptableType for creating serializable objects but that’s not what we need here. Notice, however, that the object type passed in is a ScriptObject. The slick part about this object is that it’s got a “ConvertTo” method that will take the weakly typed objects that it contains and serialize them to the type of object that you specify. This made the C# code here REALLY simple.

[ScriptableMember]
public void CallBackFromJavaScript(ScriptObject artists)
{
    List<Artist> listofartists = artists.ConvertTo<List<Artist>>();
    dataGrid1.ItemsSource = listofartists;
}

What’s left is the JQuery in the browser that we’re talking to. Notice that the first part is exactly the same. The second part, however, is a little different. First, we have to get a reference to the Silverlight plugin itself. Since I’m in a form object, ASP.NET mangles the name a little bit but it wasn’t too hard to figure out the new name. Next, I have to get the object that I had registered with the RegisterScriptableObject method. Then, all that’s left is calling the method to pass in my array of Artists.

<script src="/Scripts/jquery-1.2.6.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
    function GetJson(url) {
        $.getJSON(url,
          {},
          DisplayArtists);
    }

    function DisplayArtists(artists) {
        var control = document.getElementById("ctl00_MainContent_SilverlightPlugin");
        var leveragingJSPage = control.Content.LeveragingJQuery;
        leveragingJSPage.CallBackFromJavaScript(artists);
    }
</script>

Conclusion

This is how I learn about new things. I’m not satisfied with just getting the job done in one and only one way. I want to try out 3, 4, 5 different ways to accomplish a given task. That way I know what the right way to do something is in a given context. For example, I don’t know that I’ll ever need to mingle jQuery and Silverlight. But, I know how it’s done now and know that it’s a lot simpler than I originally thought it would be.

JSON is a simple but powerful format. There are a ton of simple services, from flickr to twitter to many of your production applications that could be producing JSON. It saves bandwidth compared to XML and is a just as simple to use.

.NET Coffee Break Show on IronRuby and Silverlight

I was just on a cool webcast called the .NET Coffee Break Show. I did a short show on getting started with IronRuby and Silverlight.

Because the show is supposed to be just 30 minutes or so, I didn’t get into my usual preaching about the Ruby programming language or why people should use a dynamic language. Instead I just stated the fact that I really like Ruby and I really like Silverlight and I especially like the combination of the two.

To get started with IronRuby, check out the getting started guide with IronRuby by Justin Etheredge.

Now, it’s not absolutely necessary to go through all of those steps to get started with IronRuby in Silverlight. Instead, just download the Silverlight Dynamic Languages SDK. Under the Releases tab, there are a handful of downloads. The one that you want is the one that has “Everything”. This includes the languages, samples, quick start templates and more.

Steps to get started:

1. Unzip the SDLSDK into a directory. I put mine in my public downloads directory for ease of access.

2. Open a command prompt, cd to the sdlsdk directory and run the script:

script\sl ruby demo

This will run the template to generate a starter Silverlight application with IronRuby as it’s language. You could substitute in python or jscript as well.

3. cd to the directory demo and run the script

..\script\server /b

This will run Chiron and then launch a new browser window pointing to the directory. Chiron will first package up the dynamic language files into the XAP and then host a simple web server.

4. Browse to the index.html file. You should see a simple page with “Welcome to Ruby and Silverlight!” displayed in the Silverlight instance.

image

5. Under demo/ruby, open the file app.xaml. Alter it as follows:

<UserControl x:Class=”System.Windows.Controls.UserControl”
    xmlns=”http://schemas.microsoft.com/client/2007″
    xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”>

  <Grid x:Name=”layout_root” Background=”White”>
    <TextBlock x:Name=”message” FontSize=”30″ />
    <Button x:Name=”button_main”
        Height=”30″ Width=”100″
        HorizontalAlignment=”Right”
        VerticalAlignment=”Top”
        Margin=”0,10,10,0″
        Content=”Click”
        />
  </Grid>

</UserControl>

6. open the file app.rb. Alter it as follows:

require “silverlight”

class App < SilverlightApplication
  use_xaml

  def initialize
    message.text = “Welcome to Ruby and Silverlight!”
    button_main.click do |sender, args|
        button_main_click
    end
  end
  def button_main_click
      message.text = “Hello from the click handler”
  end
end

$app = App.new

The “do” in this case is wiring up a .NET delegate as the event handler for click event.

7. refresh the browser (or relaunch via Chiron per step 3 if you closed the browser).

image

There are a lot of other samples that are out there as well. Check out the ones under the sdlsdk/samples directory. Right now there’s a simple clock and a Flickr photoviewer that shows a lot of DOM and JavaScript integration.

You can also find samples at:

http://silverline.schementi.com/

If you want to play with IronRuby or IronPython you can get started playing in the DLRConsole found at http://silverlight.net/samples/sl2/dlrconsole/index.html. All the source for that is under the SDLSDK samples as well.

I’ll update the post once they put up the recording – .NET Coffee Break Show

European Silverlight Tour

Beat SchweglerIt’s been an amazing month. I had the opportunity to take a tour around Europe speaking about Silverlight. I got to see a lot of different countries, speak to a lot of different people, hear a lot of different visions and opinions and really experience how global of a company Microsoft truly is.

First, let me just say thanks to Beat Schwegler who set up the whole trip. He has an interesting role. He is the technical leader for DPE in Western Europe. He’s a great mentor and I’ve learned a lot from him.

So what was I talking about? I was really talking about building Rich Internet Applications with Silverlight from an architect’s perspective. The first part of the talk is really more about usability and user centric design than it is Silverlight in specific. The second part of the talk is an expanded version of a talk that I first did with Mike Labriola and later with James Ward. I added a ton of specific material about Silverlight to it. The whole deck is up on slide share and embedded below.

Spain

European Silverlight Tour 2008I started off my trip in Spain. Madrid to be exact. I had a few days to adjust to the jet lag before I had to speak. This was cool because I got to see a little of Madrid and get to know the people. This included, among others, Cesar De la Torre Llorente, Isabel Gomez Miragaya, David Salgado Bermejo and their manager Enrique Fernández.

I started off the “work” portion of the trip by doing a couple of interviews. The first of these was with a CIO magazine called Computing Magazine. I probably went a little too poindexter on the poor reporter on top of the slight language problem. Overall though, Cesar was pleased with the interview. The second interview was, thankfully for me, with a technical guy who runs a technical magazine out of Spain called .NET Mania.

For my public session, it was packed with close to a hundred people. They had very slightly overbooked the room anticipating some drop-off but there was a lot less drop-off than they usually get so it was jammed. The session went well, despite the language barrier. Beat had warned me that of all the countries, Spain would be the biggest issue as people speak less English there than anywhere else on my trip. France would be a close second but that wasn’t a scheduled stop. I just spoke as clearly and slowly as I could (and got thanked for it on the break). Even so, Cesar ran though a quick high level version of my session in Spanish as soon as I was done.

Many more pictures from Spain found in the sets Random Pictures from Spain and Speaking in Spain.

Switzerland

Very cool motorcycle shop in SwitzerlandAfter my session, I flew to Switzerland where I spoke at the partner council meeting organized by Ronnie Saurenmann and Stefano Malle from the Swiss DPE team. There were about 15 consultants from around Zurich that were there including Atif Aziz who I know from way back when I was doing a lot of training and Laurent Bunion who had just finished writing a new book called Silverlight 2 Unleashed for Sams. They obviously were prepared for the session and asked a ton of really tough question. It was cool though to see the excitement around the technologies. I want to send a big thanks out to Christian Gross who set me up with a user group meeting at Credit Suisse. I love talking about dynamic languages. Here I got to talk to the group about IronRuby and IronPython following a short session that Christian did on F# and the functional programming concepts in C#. It was a smart crowd with good questions.

Afterwards, I got to spend the weekend at my friend Christian’s house. We went hiking through the mountains and even saw this slick looking motorcycle outside of a Swiss custom bike shop…

More Pictures from Switzerland found in Random Pictures from Switzerland.

Denmark

Next up was JAOO in Denmark. We started out the week with a dinner organized by the Microsoft guys from Denmark including Daniel Mellgaard Frost and Martin Esmann.

JAOO was an awesome conference and I was honored to be part of it. They had an amazing number of industry greats:

Speaker Dinner at JAOO

  • Anders Hejlsberg, Technical Fellow, Microsoft
  • Martin Fowler, Chief Scientist at ThoughtWorks
  • Neal Ford, Ruby Shepherd at ThoughtWorks
  • Lars Bak, Google Inc. – one of the authors of the V8 JavaScript engine for Chrome
  • Michael T. Nygard, Author of “Release It! Design and Deploy Production-Ready Software”
  • Joe Duffy, Microsoft – author of the Parallel Extensions for .NET
  • Erik Meijer, Microsoft – Architect of Volta, parts of LINQ and much more
  • Glenn Vanderburg, Relevance Consulting
  • and the list goes on – check the rest of th
    em at http://jaoo.dk/aarhus-2008/speakers/

Josh Holmes and James WardOne of the things that I did was a joint session with James Ward from Adobe on the best and worst practices of building RIAs. We had about 175 people in this talk. The great thing about this talk is that when we are talking about applications, there are many practices that we can talk about. I’m prepping a much longer post with that deck that will go up later today or tomorrow.

Following that, I talked about Silverlight specifically with about about 150 people and had a full day tutorial on Friday with about 15 people. The tutorial was interesting as my video adapter on my laptop got damaged and I had to borrow one of the student’s computer. The interesting part there was me struggling through on a Danish keyboard… Definitely a different layout for all of the special characters.

Klassic 65 - Aarhus DenmarkI loved Denmark. The people were over the top friendly. After a dinner at Klassic 65, James Ward and I wanted to go grab a scotch before heading to bed. Sorin, the owner who had already dipped into his private wine collection for us, was trying to give us directions to a great scotch place. When we failed the test with all of his usual landmarks, he said – “Ok, then I’ll take you” and piled us all into his station wagon and drove us across town to the scotch place. That was cool! I really dug Klassic as they cook in the old ways. According to what I understood from Sorin, the cooks and much of the wait staff have to pass a certification test. Part of the testing is this antiquated set of methods that include doing the Flambé at the table with the crepes and so on. However, after doing it for the test, none of the restaurants actually use this knowledge. Sorin decided to go for it. His little shop has limited room and a very short set of dishes. They typically offer 4 starters, 4 entrees and 4 desserts and they do those few items amazingly well. The wine choices are far more plentiful. Sorin is a master as picking the wine for the meal.

I have to go back to JAOO every year just so that I get to go back to Denmark.

More pictures from Denmark found in the sets Klassic 65 in Aarhus, Speaking at JAOO with James Ward and Denmark.

Sweden

Speaking in SwedenI love Sweden. One of the conditions that I had for taking on the trip in the first place was that I get to spend a weekend in Sweden. It turned out that Richard Hale Shaw was wrapping up a class in Stockholm the day I arrived. We hung out that evening and had dinner at very cool local Jazz club.

Unfortunately, it rained all day Sunday. That aside, it was a great day. I had dinner in the old town (Gamla Stan) and hung out people watching all day. It’s one of my favorite pastimes.

Monday I met up with the local evangelism team, including Jonas Torstendahl and Robert Folkesson.

I did a public session at the Sheraton with about 50 people. It was a great audience – mostly consultants that came with solid questions. One of the attendees had actually already been doing quite a bit of Silverlight including a Greeting Card application that they are working on getting ready for release on Codeplex.

*update* – the Greeting Creator is on CodePlex at http://www.codeplex.com/greetingcreator.

More pictures from Sweden found in the set Views from the Nordic Light in Sweden and Speaking in Sweden.

BelgiumSpeaking in Belgium

I really wish that I had more time in Belgium and in Holland but I only had a day each. I got in on Monday night and was on the train Tuesday night. In the mean time, I got to meet several of the Belgian evangelists, including Philippe Destoop, and do a public session. I really liked the facility that we were in. It’s called Living Tomorrow and it’s all about the future of sustainable technologies. They had a set of solar panels out front that had an LED display that showed how much energy it had generated and how much of that energy had been used. The whole venue was the latest and greatest technologies from a number of different companies. They had touch panels on all of the refrigerators to show the ingredients. They had automated lights and lighting control in the auditorium. They had automated lawn mowers. They had an amazing amount of cool tech.

More pictures from Belgium found in Random Pictures from Belgium and Speaking in Belgium.

HollandSpeaking in Barneveld, Holland

Next up was Holland. I took the train into Amsterdam and then caught a cab out to near Barneveld where the session happened the next day. I stayed in a cool little spa type of an hotel that was nice and old school. Right down to the old fashioned iron key for my hotel.

The next day I caught a lift to the venue with Mark Voermans. It was an interesting session because part of the crowd was brand new to the technologies and was really interested in the first part of the session but lost in the second part. The other part of the crowd is already actively doing Silverlight development and was bored to tears in the first part and rapt in the second half. 

Following the public session, we had a two more meetings. One was an interview with Web Designer Magazine. Here I was joined by Martin Tirion, Holland’s User Experience Evangelist. The second one was with one of the TV stations to discuss their systems.

More pictures from Holland found in the set Speaking in Holland.

Ir
eland

From Holland I flew to Ireland. This was the final stop on the work tour. I started off with a long meeting with Sean Foley, the evangelism manager for Ireland. He had a tremendous amount of great insight into the the tech industry, Microsoft, politics and a ton more. It was great to meet him and learn from him.

I had a number of side meetings during the day and an evening event. The meetings were with two different training companies that are ramping up for Silverlight and a company that’s been doing Silverlight application development since Silverlight Alpha 1.1 called Zignals. They have a pretty cool set of chart controls specifically tailored for the financial industry. They had some really deep and technical questions. I’m hoping that I was able to help them out…

Dynamic Languages Crew in Dublin, IrelandThe next meeting was also really cool – Martha Rotter, the local DE, had set up an interview with a lot of the local dynamic languages folk from around Dublin. That included Ana Nelson from Ruby Ireland, Jaime Hemmett from PHP Ireland, and Sean O’Donnell and Vishal Vatsa from Python Ireland.

That was a ton of fun. I’ll be posting that on WiresideChat soon.

Speaking in Dublin, IrelandLast stop was the public session that I did in Ireland with about 75 people in attendance. It was a varied group ranging from consultants to people that work on the Live platform for Microsoft out of the Dublin office. It was impressive how many people came with good and solid questions ready to ask. There was even a couple of people with written lists of questions that they wanted to make sure that they wanted to get answered. Martha told me afterwards that the crowd is usually very reserved and doesn’t ask a lot of questions – but they were really enthusiastically engaged during my session.

More pictures from Ireland found in the sets Dynamic Languages in Ireland and Speaking in Dublin.

Conclusion

I learned a ton from my trip and hopefully was able to help people out. I’d love to hear from those that were in the various sessions about how they are applying anything that I talked about.

eRubyCon 2008 Day 3

I wrote a write up for eRubyCon 2008 Day 1 and eRubyCon 2008 Day 2.

Jerry Nummi's buddy icontheedgecase's buddy iconBTW – thank you to Jerry Nummi for all of the great pictures of eRubyCon. I haven’t had time to browse and put them in this post but I’ll do that tonight or tomorrow.

*Update – I added pictures…*

I’m sitting in the back of day 3 reflecting on the previous two days. It’s amazing the group of people that Joe has put together here to speak on Ruby in the enterprise.

Joe O'BrienJoe O’Brien started up the day with his DSL talk. I’ve heard the talk before but it’s still a fantastic talk. His sub-title on the talk “Why I love Ruby”. I like to add “(and Emacs chest thumping)” but that’s me… 🙂

I’m not going to explain DSLs here because I wrote about them after hearing this talk the first time at http://www.joshholmes.com/2008/04/25/DomainSpecificLanguagesDSL.aspx.

Honestly, part of what is so great about the talk is that Joe is just infectious in his passion and delivery. He, like a lot of great speakers, is a story teller. He told stories that ranged from past work in tech to past work prepping food displays for a cruise liner.

One of the stories that he told was about a large company that he did some consulting work for. They realized that the core issues at the company really came down to two people being able to communicate – a DBA and an Accountant. The issue was that they weren’t speaking the same language. One was speaking in rows, columns, triggers, sprocs and so on. The other was speaking in points, rates, forecasts and so on. The solution was to write an ORM that the accountant could understand that the DBA could work with. This came in the form of a DSL.

The food story was that the great sculptures on the table displays are actually food – not really edible but food non-the-less. It’s made from refined beef fat. There are many different forms, some softer and more moldable and some closer to marble than clay, and depending on what was needed, the master sculpture would pick a different form. Similarly, Joe picks a language that he can shape and mold to his needs. That’s what Ruby is for him.

Back to Emacs, one of the reasons that Joe loves Emacs is that you can shape the commands and key-bindings and the whole environment to shape your way of working rather than the other way around. I’m still not convinced. My biggest problem with Emacs is that the learning curve before you can be even mildly productive is giant. I understand that once you climb that mountain that the view is nice. I’m just not convinced that the incremental jump over my current tools will be enough to be worth it.

Interested in the talk? You can watch it from when Joe did it at the Mountain West Ruby conference.

Chris WanstrathChris Wanstrath followed Joe with a talk about GitHub. They have taken the Git source control and given it a centralized source server. The reality, as he explained it, with Git is that every person has a full blown copy of the repository. The interesting part is that people can go client to server or they can go peer to peer or any combination that you can possibly imagine. When they want to make a change, they actually fork the project.
Especially with the Git peer to peer checkins, it’s actually not a checkin. Nobody actually has write access to anyone else’s Git repository. When they are ready, they let the other devs know that they should pull and merge. They way that it works all the way up the list is that there are devs that make changes who let the project managers know that they should pull. That project manager is the “blessed version”.
The simplest explanation of GitHub is that it gives the individual programmer an offsite repository so that they don’t have to be online when the other members want to make a pull.  

Jim WeirichJim Weirich did the lunch time keynote called “What the Enterprise Can Learn From Your Mom”. In the spirit of the previous talk, he told us that all of his slides were up on GitHub already. He started out talking about Moores law. The first thing that he points out is that the number of transistors on the chip doesn’t mean that the chips will be faster – it might, and does in current times, mean that we get more cores. There’s a possibility of 100 core processors in the near future. Similar to our moms, we will have to learn how to do more and more things at one time. The fun part is that most people don’t know how to write multi-threaded applications… Jim went on to do a fantastic explanation of race conditions and threading at large. Somewhere in here I missed part of the talk trying to track down why the air-conditioning was not on. As I walked back in Jim was telling war stories about collecting real time data off of a jet engine in a multi-threading system. They designed a system that would only fail one in a million times – except that it was collecting data about a million times a day – oops. They had designed the system to fail once a day. Back to the drawing board…
Then Jim shifted gears. He started talking about “Blub Programmers” and languages other than Ruby. Jim is definitely the guy to do this. Jim is always playing with some bizarre language that would twist a normal brain like a pretzel.
First language that he talked about was Erlang. It’s a bizarre language. For example, you loop by writing tail recursion functions and most of the communication is done by sending process messages. The next language that he talked about was Closure Clojure (thanks Stuart Halloway for the correction). The interesting part about it, especially in light of the rest of his talk, is that it’s got different types of variables that are aware of multi-threading inherently.

Michael LetterleMichael Letterle followed Jim’s session with a session on IronRuby. To be far, I was supposed to follow Jim. However, I convinced to sw
itch me and Michael because I thought his talk was more core IronRuby than mine and would free me up to concentrate on Silverlight more than spending my time talking strictly about IronRuby. I was right and I liked the order. But I do deserve the comment that Michael started with where he called me an “ass” for making him get up right after Jim Weirick who is a phenomenal speaker.

Michael is one of the community contributor to the IronRuby project and has done a lot of work. He started with a lot of discussion about how the culture at Microsoft is shifting to be more and more open. With projects like CodePlex and Port25, there’s a lot of great new things.
Michael ran a lot of the test that were run at the Ruby Shootout in 2007 to see the differences and where things are now. While the functionality was largely complete, the perf was not great. It was a little worse than twice as slow as Jruby and MRI. As it’s still in beta and heavily under development, I’m not dismayed by that at the moment. If that’s still the case in a year, I will be.
Michael’s take on the talk was that since IronRuby is Iron, we should look at it with battleship grey windows applications. 🙂 He was adamant that there be an IronRuby talk that wasn’t about web technologies. He wrote a small windows app that hits a database and does normal IO type work similar to any and every enterprise application out there in the world. The next thing he did is fire up ir.cmd which is the IronRuby’s interpreted runtime. Then he attached to the running windows application and modified the application’s GUI and business logic to include tax information. Some of the cool things that he did was opening up base class library items and started adding Ruby things to them. For example, he added method_missing to the base Windows.Forms.Form class.

It’s awesome that there are guys like Michael out there in the world that are passionate Microsoft, Open Source, Ruby, .NET, Enterprise and Community. He’s a great ambassador from one world to the next carrying those passions with him everywhere he goes.

Josh Holmes– I followed Michael talking about Ruby in the Browser through Silverlight. I started out by talking about what evangelists do. After that I talked about User Experience and what that means to software. Then I started talking about some companies where the user experience, and their use of Silverlight, are making a great difference. I showed off the Olympics and the Hard Rock Cafe live and online. Then I pulled up some of the great work that Jimmy Schementi has been doing with a project that he calls Silverline. It’s pretty fantastic – it’s a number of different IronRuby samples running in Silverlight. The one that I missed showing and discussing was the idea of moving the controller in a Rails app out to the browser with IronRuby. Oh well. Next year.

I think that my talk was well received but welcome any comments. 

– Lance Carlson followed my session and closed out eRubyCon with a talk about an open source project that he’s writing called Anvil. It’s a framework for creating desktop applications that’s platform agnostic. The goal is to wrap all of the possible desktop frameworks from Shoes to RubyCocoa in one common framework. It’s a very interesting idea.

– Closing thoughts. Joe O’Brien did a fantastic job putting together this whole conference. The quality of the program, the speakers, the logistics, the whole package is fantastic every year. This is one of the highlights of the year for me every year. The other absolutely non-negotiable item on my calendar is CodeMash. The ton and the maturity of the conference coupled with the passion that not only the speakers show but the attendees as well is unparalleled

It’s an honor to me that Joe has invited me to come and associate with this group of elite and influential speakers/friends/attendees/geeks/passionate people that makes up the Ruby community. I’ve really enjoyed getting to know everyone at the conference.

I was thrilled that Joe wanted to host the event at the Microsoft offices in Columbus. We’re not going to be able to do that next year because we’ll overflow the venue but this year is was the perfect size. We can fit about 120 in the bigger meeting room without having to sit on laps and we had right at 106 in there. It was full but not crazy.

Last year, Joe closed with question as to whether or not they were going to do it again. This year, Joe ended with a definitive – “We’ll be announcing dates soon for next year, keep an eye on http://www.erubycon.com or the mailing list”. Me… I’m very happy about that.

Miguel de Icaza on Mono and Moonlight

Very, very close (It was #1 Explore)         132 times Fav.!Moonlight is still continuing to progress. Moonlight is the open source implementation of Silverlight for Linux. It’s being run by Miguel de Icaza of Novell.

There are a couple of things that are interesting to me about this project.

First, as I talked about in Dancing in the Moonlight!, it’s unprecedented interop and openness on the part of Microsoft. Microsoft gave the project the specs and a ton of support. The Moonlight devs even have access to the Silverlight engineers as they are developing the open source compatible solution to help clarifying specs and ensuring compatibility. One of the things that’s tough from a legal perspective is all of the codecs and other video components. What’s going to happen is that there’s a “Media Pack” that users will download from Microsoft to play videos. This circumvents the legal issues and allows Moonlight users access to all the great VC1 video out there.

Second thing I find interesting is that they are finding interesting ways to innovate even in the constraints of being 100% compatible. For example, They built a Silverlight designer called Lunar Eclipse completely in Silverlight. That’s a really cool idea. They are looking at offline ideas around Moonlight and making their implementation a WPF light enabling them to revamp the GNOME’s desktop development paradigm. They’ve started with desklets, which are small Silverlight components that run in a desktop framwork. Again, really innovative idea.

Miguel did an interview with derStandard.at about the projects and how they are going at Miguel de Icaza on Mono