Compiler Dev Lab – Scripting

Day Two of the Compiler Dev Lab was all about scripting. Iron Python was the primary focus of the day, but they also had Phalanger (Managed PHP) and Monad folks there as well.

  • I hadn’t realized just how performant these dynamic languages are on the CLR when compared to their native versions. The original version of Iron Python was 1.7x faster than the standard C implementation back in the summer of ’04. Now with CLR 2.0, that version is now 2x faster with out any code changes. The Phalanger folks said they are 2.5x faster than the native version of PHP (1.7x faster than PHP + the Zend Optimizer). That’s pretty impressive performance.
  • The IronPython folks are heavy users of the new DynamicMethod class from .NET 2.0. Otherwise known as Lightweight Code Generation, DynamicMethod allows you emit a static function but have it get garbage collected when it’s no longer needed. IP almost never generates new classes, since new types can’t be garbage collected. The only times they generate actual classes are when you inherit from an existing .NET class or when you generate a new delegate type.
  • It’s really hard to serve the dual masters of both the existing language community and the .NET community. Jim Hugunin used the example of String.Trim(). A .NET developer would expect String.Trim() to “just work”. A Python developer would expect that to throw an AttributeError exception (the Python equivalent of Trim is strip). How do you handle this? In IP, it defaults to pure Python mode, but if you enter “import clr”, you move into .NET hybrid mode.
  • One of the typical features of dynamic languages is the ability to change the base class of an object on the fly. Jim demoed this with WPF. He created a class that inherited from one type of panel and then set the __class__ property of the object to a different panel and the display changed immediately. Freaky, but cool.
  • Jim showed a demo of a WPF app that hosted Python for extensibility. One of the scripts in turn hosted Python to create an interactive console for the app. Having a scripting engine that can host itself is awesome.
  • The VSIP SDK CTP (reg required) includes an sample lanugage integration project for Iron Python. So you can get both the source into IP language itself as well as the source to the integration into Visual Studio.
  • I got an email yesterday from someone asking about the possibility of Visual Ruby.NET. I haven’t heard anything about it, but it would be cool to see Ruby on Rails runing under CLR. John Lam is working on RubyCLR, but my understanding is that is a bridge between the CLR and the Ruby runtime, not a CLR implemenation of the Ruby runtime. (IP is a CLR implementation of the Python runtime.) I’m thinking that there are some similarities between Ruby and Python, so having the source of IronPython would be a huge help in building a Visual Ruby implementation. For example, both Ruby and Python have closures. IP has a FunctionEnvironment class which is used to lift stack variables onto the heap in a variety of scenarios, including closures. So if I was building Visual Ruby, having access to the FunctionEnvironment class would be a good start.
  • I said yesterday that I need to learn more about F#. They showed a video of an internal F# presentation, but I spent most of my time cracking jokes with Sam Gentile who’s in town for an SC-BAT workshop.
  • I didn’t pay enough attention to the Monad presentation. 😦

Compiler Dev Lab – LINQ

Even though I haven’t finished my ETech postings, I’m already onto another event. This week, thanks to an invite from Michael Lehman, I’m sitting in on a Compiler Lab discussing implementing other languages for CLR. The first day was about LINQ. Much of the info is rehashed from PDC or the docs up on MSDN. However, I have learned a few new things.

  • One of the standard features of LINQ is Extension Methods. That enables you to declare a static method like “static void Foo(this string source)” and then use it like “stringvar.Foo()”. Apparently, they are considering adding other types of extension members including properties and fields. The idea of extension fields is somewhat scary but powerful.
  • LINQ uses something Anders called deferred query execution. The query isn’t executed until the values are asked for (typically by calling foreach on the query). That means you can compose queries to your hearts content with no perf impact until you actually invoke the query.
  • Query Comprehensions in C# and VB is a pattern implementation in a similar vein to foreach. Foreach is relatively simple shorthand for iterating through an collection by calling IEnumerator.MoveNext until it returns false. While LINQ enables arbitrary composition of queries, there is obvious gravitational pull towards the SELECT / FROM / WHERE / ORDER BY / GROUP BY approach favored by SQL. So if you build your own query operator, you can include it in a LINQ query, but C# and VB won’t be able to include it in the Query Comprehension syntax. Probably not a big deal, given the breadth of standard query operators as well as the deferred query execution, but it’s good to understand how the abstraction works.
  • I want to know more about how DLinq is implemented. I’ve been refining my thinking about data since working with Ning’s content store and I’m convinced of the need for a simplified datastore. SQL is designed for significantly complex database schemas, which means a significantly complex development environment.
  • I’m looking much more closely at VB, given the new features in VB 9.0. Not only the LINQ stuff from C# like type inference, extension methods and anonymous types but also VB specific stuff like XML Literals and Duck Typing. Combined with VB’s existing support for late binding, there are compelling features to make VB attractive over C#.
  • I’ve been hanging out with Brian Beckman. He’s a hoot.
  • I think I need to take a deeper look at F#.

Hawk Eye on Windows Live Favorites

After installing the new Windows Live Toolbar, I installed some of the add-ins that I usually wouldn’t. Things like the Phishing Filter, Games and the Windows Live Favorites. I’m not sure when Live Favorites was refreshed, but the new version is much better. It support both folders and tags – previously it just supported folders. There’s a reason why tagging has taken off – it makes sense to people. I started using Live Favorites but gave up because the folder approach is so much less flexible.

The other new feature is that the Live Favorites Add-in now sync’s your local favorites with your Live Favorites. Not sure how that will work if you primarily use tags on Live Favorites, but I guess I’ll see.

Finally, Live Favorites can be shared, but there doesn’t appear to be any way to search shared favorites. Am I missing something?

Hawk Eye on Live Toolbar First Run Experience

Now that I’m back in the office with an external monitor, I’m able to use my laptop again. While I was waiting for the help desk tech to show up, I installed the new Live Toolbar. I was immediately thrown however, because it comes with basically no default installed features. It was strange to have to install basic features like tabbed browsing and desktop search. On the other hand, it was nice not to have the previously default features that I don’t use uninstalled (i.e. popup blocker, form fill, msn extensions). There needs to be a better first-run experience that presents the user a list of options to install (along with the standard ones pre-selected). Otherwise, so far so good.

ETech Day Three Quick Thoughts

After my marathon blogging session last night and taking notes all day, I’m a bit burnt out on writing. But here are a few quick thoughts. More details to follow.

  • I’m digging the Live.com home page and the integrated Live Search. Since I’m on a rented laptop, Live Toolbar will have to wait. Coolest new feature IMO is the Search Macros, though it’s a tight race with the new image search interface.
  • Jon Udell and Michael Goldhaber spoke about attention economy today. I still don’t get it, though Jon had some interesting ideas about metadata. I’ll believe that attention is a currency when I can buy a car with it.
  • I liked the session on the Yahoo! Design Patterns, though the title and abstract of the session were awful. The title was “The Language of Attention: A Pattern Approach“. The inclusion of attention just confused the issue. Why couldn’t they just call it “A Pattern Language for User Experience”? Because it doesn’t have the concept of attention shoehorned into it.
  • I really like Eventful, even though I’m on record as thinking their business model doesn’t work. Their new demand feature is pretty cool, though it doesn’t really help their business model any.
  • George Dyson’s session on “Turing’s Cathedral” was fascinating, though he tried to cover too much ground in the time alloted.
  • I’m not sure what the point of Joel Spolsky’s Blue Chip Report Card was. Apparently the alien from Reddit is cute and Motorola newer cell phones (RAZR and PEBL) are taking Joel’s advice on becoming “blue chip”. This is somewhat related to points the folks from Adobe (previously Macromedia) made, except much more obtuse.
  • I have no idea what the point or business model of Plum is, even though it was featured as a keynote (a last minute promotion it appears from the conference guide). Seems too complex and centralized to actually work.
  • I wrote last night that Casting Words isn’t really a business because nothing stops me from going directly to Mechanical Turk and getting the transcription services myself. Today, I found a Casting Words task on Mechanical Turk so I decided to figure out how much they’re making. The task I found was to transcribe about 28 minute podcast and they were offering $5.41 for anyone willing to do it. That’s about 19.5 cents per minute. Tack on Amazon’s 10% charge brings the total to around 21.5 cents a minute that Casting Words is paying for transcription services. Given that they’re charging 42 cents a minute, that’s just under a 49% profit margin. Exactly what are they doing to earn that profit? What’s their value add and is really worth a 100% markup?
  • Anyone want to start “Cheap Casting Words” with me? We’ll pay 22 cents a minute (11% more than Casting Words) and charge 36 cents a minute (14% less than Casting Words) and keep the 12 cents a minute markup (a 33% markup). 😄

Update: Added Quick Thoughts on Yahoo!, Eventful, George Dyson, Joel Spolsky and Plum. Added more detail about the attention economy sessions from today.