June 11, 2008

IronRuby and ASP.NET MVC

At Tech Ed last week, I showed a prototype of integration between IronRuby and ASP.NET MVC. I was really happy about how straightforward this turned out to be; it’s a strong testament to the robustness of our hosting API that Levi on the ASP.NET MVC team was able to add IronRuby integration with only a simple example and the existing docs.

Let’s walk through a simple example. Keep in mind that this is a prototype, and that many things will likely change before we’re done with it (particularly some of things we do today with globals and instance variables).

First, let’s look at how you can define some default routes via routes.rb:

image

Next, let’s look at the Controller code for the HomeController:

image

The index action renders a view using a trivial Model which lives in models\HomeModel.rb:

image

This model is used by the index action View, which lives in views\home\index.rhtml:

image

Next, let's look at a slightly more sophisticated example using a Products Controller that renders a list of categories that looks like:

clip_image002

It also renders a list products for a category when you click on it:

clip_image002[5]

This is what the controller looks like:

image

There are two actions in this controller: index and list. The index action returns a list of the categories, and the list action returns a list of products for that category.

Note that we're using instance variables on the controller to communicate with the view - this is likely going to change in the future, but it was something we hacked in to see what it would look like.

If we look at ProductsModel, you'll see that it contains a simple adapter around a Visual Studio generated wrapper for the Northwind database:

image

We had to write our own adapter to work around a few bugs that we have in our .NET interop story as of right now, as well as adding a few model-esque methods. Here's what the NorthwindDatabase adapter looks like:

image

Notice how we can use LINQ to SQL to write our queries to the database, and the funky C# 3.0 anonymous delegate syntax that we use for GetCategory().

The interesting code in the view looks like:

image

Today we're using the MVC template engine, but there isn't any reason why we couldn't enable erb / haml etc. in the future.

How can I get it?

You can download a ZIP of the entire project from here if you want to take a closer look. Note that you can't run these bits yet, since I demo'd it using a private build of ASP.NET MVC from mid-way through their current milestone. That said, when Preview 4 of ASP.NET MVC ships you'll be able to run IronRuby on top of it (their current release is Preview 3).

Look for a blog post here, and from the folks like Phil over in MVC-land when we're ready to ship you some bits to build MVC apps using IronRuby.

June 10, 2008

IronRuby at Tech Ed 2008

image

I’d like to start out by thanking everyone who came up to talk to me at the conference. We had a Dynamic Languages booth at the conference, and it was great to talk to all of the folks who took the time out to drop by for a visit.

A big thanks goes out to our booth staffers – Dave Fugate, Curt Hagenlocher, Jimmy Schementi, Bill Chiles and Mahesh Prakriya who helped to keep things running smoothly. Dave somehow managed to grab an enormous whiteboard from somewhere and used it to help answer many of the FAQs for folks who were hanging around waiting for a blue-shirted guy to become available.

image

Tech Ed is (not surprisingly) a very enterprisey conference. We spent at least as much time telling folks what Dynamic Languages were (or correcting their misperceptions) as we did talking about our team’s progress. We also had a whole bunch of folks come up to ask us questions about F# because, apparently, F# is now a dynamic language :)

By far the most frequently asked question was why dynamic languages? The advice that resonated the most with the folks that I talked to was about using it to help them build internal DSLs for their applications. This is the idea that you can use DSLs for part of your app, dynamic languages to help faciliate those DSLs, and statically typed languages for the foundational pieces. You'll find that this idea is often called polyglot programming.

The Talk

The IronRuby talk was the very last talk of the conference. Apparently I was one of the ‘big guns’ that would convince folks to stay all the way to the very end of the conference. While I prefer being at the start of the conference so that my talk can help drive further discussions with folks while they’re still there, it is what it is. Oh well, let’s see if the tubes can help start a conversation :).

My talk focused on three things. First up was an introduction to Ruby since half of the folks in the room hadn’t used Ruby before. I wrote a simple unit-testing framework live on stage. Each new feature in the framework helped to introduce a different feature of Ruby. At the very end of the talk I showed how that same framework could be used to test .NET code. Here it is in its entirety:

image

And here is some .NET code that we tested using this framework:

image

It worked rather well, and I think I’ll continue to use it at talks where I need to introduce Ruby to the audience.

Next, I talked about our Silverlight integration. I showed the excellent set of demos that Jimmy created for RailsConf last week, including his client-side Try IronRuby demo:

image

and the lovely Silverlight watch demo:

image

I also got a chance to sneak in some of the code I was hacking on in the evenings – an adapter that maps the HTML 5 Canvas API to Silverlight. I ran a few of the examples from the excellent Mozilla Canvas tutorials using a my adapter. I pasted some code (with minor rubification) from the Mozilla tutorial into the text box:

image

and hit run - the colored boxes with the translucent circles appeared below: image

There's no reason why we couldn't do this with managed JavaScript either using the cross-language interop features of the DLR.

Oh yeah, there was one more thing that I demo'd - more on that tomorrow.

May 30, 2008

IronRuby and Rails

IronRuby dispatched some simple requests through an unmodified copy of Rails a few days ago. Today, we’re going to show off our progress live at RailsConf. This is an important milestone for IronRuby; it’s our ‘ticket to entry’ to the world of alternative Ruby implementations.

We started our work on IronRuby back in February 2007. Now, just 15 months later, we’ve reached what others are calling the “Rails Singularity”. A few folks claimed that we would never get here this quickly, or that we wouldn’t be allowed to accomplish this goal. But we did it on our own, in our own way and with help from our community. And we’re just getting started.

I have always maintained that you must judge us based on our actions and not our words. Running Rails shows that we are serious when we say that we are going to create a Ruby that runs real Ruby programs. And there isn’t any a more real Ruby program than Rails. This demonstrates that we’re true to the language, and that we’ve put compatibility above all else on our TODO lists.

But we have a lot more work to do.

Our performance is nowhere near where we expect it to be, particularly in startup of a large application like Rails. We are consuming much more memory than we would like to. But this is the price you pay when you put compatibility ahead of all other work. We’ve shown that we are willing to do what it takes to run Rails. Now we have to do the work to make it run better, and faster.

But there are other things to talk about as well.

IronRuby doesn’t just let you run Rails; it lets you interact with the rich set of libraries provided by .NET. You’ll be able to use IronRuby to build server-based applications that run on top of ASP.NET or ASP.NET MVC. You’ll be able to use IronRuby to build client applications that run on top of WPF or Silverlight. You’ll be able to use IronRuby to test, build and deploy your .NET applications. You’ll be able to run Ruby code in your web browser and have it talk to your Ruby code on your web server. That’s a feature that we feel that many folks will enjoy.

Perhaps even more important than all of this technical stuff is what the IronRuby project represents at Microsoft. IronRuby has pioneered a number of new processes that make it easier for other folks at the company to build and release Open Source products. What we learn from building IronRuby will be applied in other product groups to help us become more open and transparent than we have been in the past. We have a great leadership team that is willing to push the envelope on openness and transparency to create a world where both Microsoft and our customers can benefit.

Come join our project on Rubyforge and help us show everyone how it’s done!

April 14, 2008

MVP Summit Ruby Meetup

OK. So here’s the scoop. 2pm at the International Meeting Place (see map).

I’m going to be at the Convention Center from around 1:30 onwards. There are a lot of central public meeting places at the convention center. From where I sit at my desk this morning, it looks like the “International Meeting Place” on the second floor will do just fine:

image

I’ll hang out there and I’ll be happy to demo / talk about IronRuby, OpenSource and whatever else *you* want to talk about.

Follow me on twitter (john_lam) if you want up to the minute updates on where we’ll be just in case this location doesn’t work out.

I’ll be giving talks on Ruby in both the C# and VB tracks. Right now it looks like 10:30AM and 12:30pm – check your schedules to make sure – the second talk’s time slot looks fishy to me.

BTW, for those of you who are reading this who don’t know what an MVP Summit is, it’s an event where we fly put up in hotels and feed some of our closest supporters to Redmond for a week-long tech love-fest. This is an awesome event since we get a chance to give back to the folks who help us do our jobs here at Microsoft.

April 02, 2008

Nominate Us for Open Spaces Sessions at MS MVP Summit

I have a simple request for you if you are:

Please go ahead and nominate us for one or both of these sessions and I’ll show up along with Jimmy Schementi to discuss at the MVP summit. Take advantage of the Open Spaces format – you get to control the agenda!

BTW- please leave a comment here if you want to nominate so that we’ll be sure to show up then!

Update: Apparently the folks running the “Open Spaces” event at the MVP Summit want to exercise central command and control over the event, quite unlike this definition of a BarCamp from Wikipedia:

“The procedural framework consists of sessions proposed and scheduled each day by attendees, mostly on-site, typically using white boards or paper taped to the wall. This has been dubbed, with another play on words, The Open Grid approach.”

Apparently nominations are now closed, so we won’t be there to participate, sorry.

Update 2: OK. So we’re going to stick it to the man and take matters into our own hands. Follow me on twitter, and we’ll figure out a place to do our own Ruby meetup at the MVP summit.

March 31, 2008

Open Source Ambassador

Yep, that’s right. That’s my other job here at the company. This means that I participate in a set of events that have nothing to do with IronRuby as a technology, but have everything to do with IronRuby as part of a movement toward greater openness within the company.

Last week, I participated in the Microsoft Technical Summit that we held here on campus. Every year we invite a bunch of Microsoft skeptics to campus and subject them to mind conditioning engage in a dialogue with them. I talked about why we were doing Open Source, why we were doing dynamic languages in particular, and showed them a few demos of stuff that works today. It was great to get blunt feedback from folks who took time out of their lives to attend, and hopefully we did move the dial on their perceptions of what we’re up to here at the company.

I had a lot of fun talking to Adam Keys who rocked my world with his RubyConf one-man play (warning – you need to either be a Ruby programmer to really appreciate the crazy humor that this is, or be fascinated by what geeks think is funny):

On Friday, I participated in our inaugural Open Source Day internal conference at Microsoft. I was on a panel with three other folks: Rob Mensching, who did the first Open Source project at Microsoft – WiX, Shawn Burke, who runs the AJAX Control Toolkit project, and made the .NET library source code available among many other cool things, and Tom Hanrahan who runs our Linux Interoperability lab. We talked about experiences – Rob and Shawn have been at the company a long time and had a ton of fun anecdotes about what it was like to try and do Open Source at the company back in the dark ages. I contributed some stories about how we do IronRuby development and some pointers about how other product groups can think about why and how they should participate in Open Source. Tom was our elder statesman, and talked a lot about why interop is important to our customers (bottom line is that virtually all of our medium to large customers live in a heterogeneous aka non-100% Windows environment).

One thing that came out in the discussions is how we need to be better at transparency, even while developing our non-Open Source products. One of the powerful ideas of Open Source is the ability for outsiders to actively participate in the creation of products even if they never crack open the sources themselves. That’s a powerful idea, and one that I think that (at least in Developer Division – where I work) we’re in a great position to deliver on.

*

I’m a huge fan of vimperator after discovering it via Zed Shaw. If you’ve internalized the vim keybindings, you’ll be surprised at how you can leverage your muscle memory while surfing the web.

March 13, 2008

Steve Yegge on Interviewing

Steve Yegge

Sorry, Steve for dragging out that lovely photo of yours that I took at Foo Camp. But hey, it's the only one that I have :)

I've been interviewing a bunch of folks for our 4 open positions (a nice fellow just accepted our IronRuby SDET position). Some of the other folks I would like to believe would have done better if they had read Steve's Get that job at Microsoft blog post [1].

I've told folks that my MS interview was on par in difficulty as my Ph.D. candidacy oral examination, partly due to the fact that it was much, much longer. (A Ph.D. oral exam is done by 3-5 professors vs. you in a room and they decide whether you continue in your studies or whether they kick you out). Mine started at 10am and ended at 6:30pm or so when I sat down with Scott Guthrie at the end of my loop.

Steve has a lot of good tips (including bring your own dry-erase markers - my last interview candidate actually ran out of ink and I wound up running down the hall to get some more for him). It's essentially a syllabus on what to study for a technical interview. 

[1] At least that's what IE on MS CorpNet shows me :)

March 10, 2008

Henry's Adventure in Las Vegas

One day, Daddy put Ben's favorite train Henry in his pocket. He was cleaning up the house the night before he was going to Las Vegas for the MIX conference. When Daddy got up the next day, he brought Henry with him in his pocket! Silly Daddy!

When Daddy got to the airport, he reached into his pocket for something else, and he found ... Henry! So Daddy decided to take a picture of Henry at the airport:

img020

Soon, it was time to get onto the airplane. Here's a picture of Henry looking out the window just before the airplane takes off!

img021

After a long plane ride, we finally landed in Las Vegas. Henry was excited to be off the airplane. Here he is in front of the gate, D25:

img022

We got into a taxi van to go to our hotel. Here is Henry looking out the window at some of the signs in Las Vegas. It was a sign for Defending the Caveman:

img024

When Henry got to his hotel, the Mirage, he saw the biggest fish tank he had ever seen right behind the check-in counter. Look at all the fish!

img025

Next, we went up to our new hotel room on the 5th floor. We opened the curtains and saw all the other hotels outside! The hotel that Daddy was going to for his conference was right across the street. It's called the Venetian.

img027

It was the afternoon, and it was time for Daddy to take a nap before dinner. After he woke up, we went with Henry to go across the street. On the way out, they saw some dolphin statues. Here's Henry in front of the dolphins:

img028

After they walked across the street to the Venetian, they saw a water fountain. Henry wanted to take a closer look:

img029

There were also people floating around in gondolas. Henry wanted to have a ride:

img030

Daddy and Henry went inside the Venetian. They saw lots of paintings on the ceiling!

img031

Later, they went into a big indoor shopping mall. There were even gondolas inside! Henry wanted to say hello to the people!

img032

Daddy was walking into the MIX conference when he saw a tiny model of the Venetian hotel. Henry wanted to take a closer look. Here's Henry flying over the model of the Venetian! It looks like he's a giant engine flying over the real hotel!

img033

When Henry got to the conference, he went to the MIX Sandbox area where he signed up to give his own talk about Ruby, Ruby, Ruby! Just kidding. It was really Daddy who was giving the talk!

img034

Daddy and Henry were getting hungry. It was time for dinner! They went to a nice restaurant called Canaletto. Here's Henry eating some oil:

img035

Here's Henry drinking some wine:

img038

After a big dinner with lots of wine, it was time to go back to the hotel for sleepy time. The next morning when Henry woke up, he had to go and check his email at Mix:

img041

After checking his email, he had to go and eat some breakfast. It was some bacon and eggs with mushrooms!

img042

After breakfast it was time to watch the opening keynote. Here's Henry watching Ray Ozzie give a talk about the future of Microsoft:

img043

After watching the keynote from the overflow room (the place where trains had to watch the keynote because trains didn't actually pay to go to the conference), it was time to go play in the MIX Sandbox. Henry had a big surprise at the Sandbox. He made some new friends. Here's his new best friend, Roby the Robot (aka Channel 9 guy).

img085

Henry had a lot of fun playing with Roby. It was a pretty busy day, and Henry decided that he needed to get a massage. OK it was really Daddy who needed to get a massage. But here's Henry sitting on the massage chair after Daddy's massage:

img086

It was time to go back to the Mirage to get ready to go out to see a show. On the way out of the Venetian, Henry stopped to have a drink in the fountain, and to listen to the man playing the accordion:

img089

It was a fun show called Mystere. They don't allow trains into the show, so Henry had to stay back at the hotel room to watch American Idol all by himself. He had a good time though.

The next day, Roby came over to play. Henry and Roby went outside to play in front of the Venetian. Here they are on a nice, sunny day:

img091

When they went inside they saw the wheel of fortune game. Roby was too young to go into the casino, so we had to take a picture of Henry:

img092

We went over to Daddy's talk about Ruby, here's Henry getting the computer ready for the talk about Ruby:

img093

The talk was lots of fun - it wasn't really a talk, it was a conversation with some nice people who really like Ruby. Henry and Roby worked up a real appetite listening to Daddy talk to the nice people. It was time for a snack. Lucky for them, there was lots of ice cream to go around!

img094

It was time for dinner! Henry, Roby, Daddy and some of Daddy's friends went out to eat at the fin Chinese restaurant in the Mirage.

img095

It was time to go back to the hotel room so that Roby and Henry could watch Daddy hack on Dynamic Silverlight code. By the morning, Daddy had everything ready for his talk at MIX. Here's Roby and Henry helping to hold up Daddy's computer on stage just before his talk:

img096

Once the talk was over, it was time to have some fun! Roby and Henry decided to go and play the Rock Band game. They didn't do so good since they were really little and couldn't play the really big instruments. But they did have fun watching other people play:

img097

Roby and Henry realized that they were inside most of the time. They found out that the Mirage has a pool outside and that there was a big yellow thing in the sky called the sun. They went outside to have a few drinks by the pool. Here they are in front of the waterfall!

img098

Now, a Las Vegas experience wouldn't be complete without playing a hand of black jack:

img099

Daddy and a few of his friends decided to go walking around Las Vegas. Where did they go first? The Sony Store, where Roby and Henry watched Ratatouille on the 52" LCD TV:

img101

They also walked around Caesar's Palace and had their picture taken in front of some of the big sculptures:

img102

Finally, it was almost time to go home. There was one last picture that they took in front of the giant horse and dragon thing before they got on the plane to fly home to Seattle.

img103

It was a fun trip. Henry had a great time. He made a new friend, Roby! But best of all, Henry was really happy to come home to see his most favorite boy in the world: Ben!

The End.

(written with some help from Matthew)

Looking back on MIX 08

Hard Rock Cafe Memorabilia in Silverlight

Last year I was involved in the keynote, so by the time it happened, I had heard it several times already. This year, I could just sit in the audience as a spectator. And wow, what a show!

Highlights from the first keynote for me were:

1. NBC Olympics demo. The whole picture-in-picture thing with live interactive stats was stunning. I'm hoping that Verizon gets FIOS to my house by the time the Olympics start ...

2. Hard Rock Cafe Memorabilia app. The Seadragon Deep Zoom technology was amazingly well done. And nobody tops Scott Stanfield for meticulous demo preparation. Well done!

3. Aston Martin. Well, the demo was OK (and the cars are awesome), but Marek Reichman from Aston Martin was awesome. He was totally 'on message' about Aston Martin and the superlatives (and his accent) that he used to describe the car were priceless.

The Ballmer / Kawasaki Show

The second keynote was pure entertainment. Guy Kawasaki and Steve Ballmer put on a show to remember (apparently quite unlike the Zuckerberg / Lacy show at SXSW). There were lots of good-humored barbs traded back and forth and Ballmer gave as good as he got. It really presents Steve in a good light -both as a guy who can take a joke, as well as a guy who really understands the industry and knows how to set the direction for the company.

Highlights for me were:

1. Jab at the MacBook Air "being heavier than my PC" (27:20) and "I'll have a bake-off between my Tosh and that thing backstage" (27:50).

2. Kawasaki's suggestion that Apple is a chihuahua to Windows that Microsoft kicks away (along with Ballmer's imitation of a chihuahua)

3. Steve's revelation that he gets 60 pieces of email a day (with no human filters) and that he responds to them personally (or delegates to someone to follow up).

Of course, there was also a reprise of Monkey Boy that made the headlines as well.

Introducing Dynamic Silverlight

This year, our talk was on Friday morning. I'd much rather get talks over with earlier in a conference since it means that I can relax and enjoy the show but such is life. This year, we had a pretty ambitious agenda planned for our talk, and with the exception of the voices that I could hear from the PC on stage, it went off without a hitch.

Here are some links to the talk that Jimmy and I gave this year. It's available in a bunch of formats:

Silverlight player

iPod formatted MP4 (57.6MB)

WMV for Zune (84.1MB)

The slides are available online, but they're largely content-free. The real meat of the talk is in our demos, and I wrote out those demos as a series of three blog posts:

Part 1: Hello, World! in Dynamic Silverlight

Part 2: Managed JScript and flickr

Part 3: Integrating Silverlight with ASP.NET MVC

You'll need the latest bits that we uploaded just after my talk to run these demos. You can download them from here.

March 08, 2008

Dynamic Silverlight bits now available!

Thanks to the hard work of John Messerly and Jimmy Schementi, we pushed the Dynamic Silverlight bits out to our temporary web site. We also published the hands on lab that we created for MIX up to the site as well.

Enjoy!

Photos

  • www.flickr.com
    This is a Flickr badge showing public photos from John Lam. Make your own badge here.

June 2008

Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30          
Blog powered by TypePad