Passion * Technology * Ruthless Competence

Wednesday, April 09, 2008

Morning Coffee 162

  • Another nice thing about the new job: I'm working in the vicinity of some good friends. I was over in building 42 yesterday and made it a point to stop by Pat Helland's office yesterday and spend an hour or so chatting about the new gig. Pat is down the hall from David Hill, whom I worked with on Architecture Strategy. Back in my building, we're down the hall from the VSX folks including my friends Ken Levy and Gareth Jones. I'm sure there are more folks I know around, but hey it's only my second week!
  • I'm a big fan of Carbonite, which I use to back up all the digital media on my home computer. With two little kids, we have lots of digital photos as you might imagine . However, one thing that bugs me about Carbonite is that it doesn't back up video files by default, you have to go in on a folder by folder basis and select "'Back up Video files in this folder" from the context menu. Given how much trouble this "feature" has given me, I imagine less techie folks don't even realize their video files aren't getting backed up. However, I will say the latest version of the Carbonite Software at least makes it easy to find files that aren't backed up. A quick sweep revealed around a dozen folders that had un-backed-up video files in them, which I promptly fixed.
  • The big news yesterday was the new Google App Engine, which looks to give you access to virtualized infrastructure that sounds similar to what GOOG is rumored to use internally. I like Dave Winer's comment that this enables "shrinkwrap net apps that scale that can be deployed by civillians." Given Google's history w/ Python - Python's BDFL Guido van Rossum works there - it's no surprise that Google App Engine (GAE?) runs on Python, though apparently they "look forward to supporting more languages in the future". I'm guessing "more languages" == Ruby, maybe Erlang too.
  • I wonder if/how Google App Engine will affect Ruby on Rails momentum? If there's a significant lag before App Engine supports Ruby, will that drive developers to Python web stacks like Django? (Django is included in "the box" with App Engine)?@ PyCon, I was surprised at the intra-language animosity I observed. I wonder how many Python developers are secretly hoping Google never ships Ruby support. I highly doubt Google would do that - they want to tap the exploding RoR market like everyone else - but I'd bet it would really take the wind out of Rails' sails if they did.
  • Today's Michael Foord Link: Embedding IronPython 2, Examples of the DLR Hosting API. You can read the DLR Hosting spec, but it's pretty out of date so Michael's article helps fill in some of the gaps.
  • Looks like PowerShell has gotten the open source community treatment in a project called Pash. While I'm sure others are excited about PS on Linux or Mac, I'm excited to see PS running on Compact Framework. I wonder if it would work with XNA?
  • Speaking of XNA, XNA Console is a new CodePlex project that provides an IPy console to manipulate your XNA based game on the fly. Python is no stranger to game development - Civ IV for example provided mod capabilities via python. Alas, the compact framework can't run IPy today, so neither can XNA on Xbox. But wouldn't it be cool to hack your game in IPy running on a 360 using the messenger kit? (via IPy URLs)
  • Bart De Smet gets functional, writing type switch and pattern matching in C# 3.0. I guess it works, but it sure is ugly. Why not just use F# and be done with it?
  • Soma announces that the VC++ Feature Pack has shipped. Somewhere, I assume, there is much (some?) rejoicing.
Posted By Harry Pierson at 10:20 AM Pacific Daylight Time

Wednesday, February 06, 2008

Morning Coffee 143

  • I've been sick for three days, hence the lack of posting around here.
  • As a Redskins fan, it's hard to root for any other NFC East team. On the other hand, it sure was easy to root against the Patriots. Congrats to the Giants on their Super Bowl victory. Favorite headline: 18 and uh-oh!
  • Sounds like there's cause for optimism regarding the writer's strike. But is it already too late? Will the 9% drop in viewers ever come back? Personally, I think the studios have hastened their own irrelevance.
  • With last night's win, the Caps are one game above .500. In and of itself, that's nothing to be proud of - Coach Boudreau remarked when we reached .500 that the Caps had "officially reached mediocrity". However, the Caps are the only team in the SE conference that's above .500. If hockey used baseball standings, Carolina, Atlanta and Florida would each be 1/2 game back of the Caps. It's going to be a fight to the finish.
  • In fairly big managed Ruby news, Wayne Kelly has decided to contribute to the IronRuby effort, effectively walking away from the Ruby.NET which helped get off the ground. One the one hand, obviously this is great for IronRuby. On the other hand, I liked the idea of multiple managed implementations of Ruby, so here's hoping Ruby.NET doesn't fade away.
  • Speaking of the DLR, I know I mentioned Martin Maly's blog in my Lang.NET Morning Coffee Post, but I didn't actually get to read his posts on targeting the DLR until I unexpectedly had several days off sick. If you are at all interested in writing your own language for the .NET platform: Go. Read. Now. You should also check out Tomas Restrepo's blog, he has also started writing about targeting the DLR.
  • Larry O'Brien's blog is currently offline, but he commented that he doubted my ToyScript F# parser would be more than 600 lines of code. Currently, the parser is clocking in at 287 lines of code plus about 50 more for the AST. It's not done yet - see earlier statement about being sick - but I'm fixing bugs not writing additional code at this point. To be completely accurate, that's 287 lines of FParsec code. It's taken me a little bit to learn FParsec, but so far I'm pretty happy with it.
  • Scott Hanselman points to the new MS Deploy project, a tool for managing content and configuration on web servers. I've never understood why this wasn't a standard part of IIS. It seems every hosting company I've used has rolled their own web-based management tool like DotNetPanel.
  • Oh yeah, Vista SP1 and Windows Server 2008 shipped Monday. Congrats!
  • I fired up Inside Xbox the other day, and there was a page about the new Disney Channel show "Phineas and Ferb". Of course, with two kids under five, anything new on the Disney Channel is notable in my house. What made this blog-worthy is the fact that it's directed and written by Dan Povenmire, who I knew from my USC days. I used to go see his band Keep Left and groan loudly at the bad puns in their song "PSA". Dan, if you found this searching for yourself online: Awesome work, my kids love the show!
Posted By Harry Pierson at 11:41 AM Pacific Standard Time

Thursday, January 03, 2008

Morning Coffee 134

  • Bill de Hora responds to a few of my Durable and RESTful ideas. He points out that relying on a client-generated ID can be troublesome, and recommends using multiple identifiers - one created by the sender, one by the receiver and one representing the message exchange itself. However, the sender ID is vulnerable to client bugs & tampering as Bill points out, and neither the receiver ID nor the exchange ID can be used to determine if a given message is a duplicate. If you don't trust the sender, is it even possible to determine if a given message is a duplicate?
  • Pablo Castro confirms that there are "practical limits" to what ADO.NET Data Services can do with respect to idempotence. Nothing in his post was surprising, though I hope it will be more explicitly called out in the final docs. Developers used to the comforting protection of a transaction may be in for a rude awakening.
  • Dare Obasanjo has a great post comparing the new features in C# 3.0 to dynamic languages like IronPython. I believe many of the productivity aspects of dynamic languages have little to do with being dynamic.
  • Pat Helland noodles on durability and messaging, two topics near and dear to my heart (probably from working with him for a couple of years). I'm not sure where he's going with this - his conclusion that "Basically, big, complex, and distributed system are big, complex, and distributed" isn't exactly ground-breaking. But his point that "durable" isn't a binary concept is worth more consideration. Also, his description of IMS only looking at the effects of a committed transaction is very similar to how web sites work, though obviously HTTP isn't durable so you can't make event horizon optimizations like IMS did.
  • Tangentially related, Werner Vogels discusses the idea of eventually consistent distributed databases. Today, that's a problem mostly only Internet-scale sites like Amazon deal with. In the near future of continued data explosion + manycore, we'll all have to deal with it.
  • Nick Malik argues that categorizing enterprise applications by lifecycle is much less useful than categorization based on organizational impact. He might also need a new chair.
  • Jesus Rodriguez digs into one of SSB's new features in SQL 2008: conversation priorities.
  • Arnon Rotem-Gal-Oz and Sam Gentile are mixing it up over the definition of SOA. Sam thinks SOA has to include business drivers and Arnon doesn't. I'm with Sam on this, defining "SOA" independently from "Applying SOA" seems pointless. Then again, rigorously defining SOA - much less arguing about said definition - seems like a waste of time in the first place IMHO.
  • Wow, this guy Zed is mad at the Ruby community.
  • Andrew Baron has 8 Reasons Why The TV Studios Will Die. Personally, I think reason #2 - Expendable Middle-Person - is the most important. If content producers can reach consumers directly, what value-add will the networks provide? (via United Hollywood)
Posted By Harry Pierson at 10:00 AM Pacific Standard Time

Tuesday, November 20, 2007

Morning Coffee 125

  • So I wasn't quite as close to the end of Dead Rising as I thought I was. Those who've played the game thru will understand.
  • After their promising start, the Capitals lost yet again. At the 20 game point, they're now 6-13-1 for a league-worst 13 points. I think we're at the point where they need to fire Glen Hanlon. Nothing personal Glen, but it's not getting done. The only problem is who you would replace him with? Bob Hartley? Uh, no thanks. I think most Caps fans want Dale Hunter, but I think he's too involved with the London Knights - he's co-owner, president and head coach. But if we could get Dale, I'm guessing Glen would be gone in a heartbeat.
  • The XNA team blog announced that XNA Game Studio 2.0's beta has released. The download is available from Creators Club Online. The big new feature in this release is network support, and they've shipped a new starter kit to get you started.
  • In addition to shipping VS08 & .NET FX 3.5, a new CTP of SQL 2008 shipped yesterday. I couldn't find a good overview of what's new, but the SQL Express team has a post on what's new in just their corner of this release. (via Jesus Rodriguez)
  • In more "I know it's Thanksgiving week, but we're shipping anyway" news, the Ruby.NET folks have shipped v0.9 - the first release since transferring control to the community. Does it run Rails? Not yet, but apparently they're "close to getting Ruby on Rails to run successfully". One thing that caught my eye is that it includes VS integration. Nice.
Posted By Harry Pierson at 8:53 AM Pacific Standard Time

Friday, August 17, 2007

DataReaders, LINQ to XML and Range Generation

I'm doing a bunch of database / XML stuff @ work, so I decided to use to VS08 beta 2 so I can use LINQ. For reasons I don't want to get into, I needed a way to convert arbitrary database rows, read using a SqlDataReader, into XML. LINQ to SQL was out, since the code has to work against arbitrary tables (i.e. I have no compile time schema knowledge). But XLinq LINQ to XML helped me out a ton. Check out this example:

const string ns = "{http://some.sample.namespace.schema}";

while (dr.Read())
{
    XElement rowXml = new XElement(ns + tableName,
        from i in GetRange(0, dr.FieldCount)
        select
            new XElement(ns + dr.GetName(i), dr.GetValue(i)));
}

That's pretty cool. The only strange thing in there is the GetRange method. I needed an easy way to build a range of integers from zero to the number of fields in the data reader. I wasn't sure of any standard way, so I wrote this little two line function:

IEnumerable<int> GetRange(int min, int max)
{
    for (int i = min; i < max; i++)
        yield return i;
}

It's simple enough, but I found it strange that I couldn't find a standard way to generate a range with a more elegant syntax. Ruby has standard range syntax that looks like (1..10), but I couldn't find the equivalent C#. Did I miss something, or am I really on my own to write a GetRange function?

Update - As expected, I missed something. John Lewicki pointed me to the static Enumerable.Range method that does exactly what I needed.

Posted By Harry Pierson at 4:55 PM Pacific Daylight Time
ADO.NET | Database | Development | LINQ | Ruby | XML

Monday, July 23, 2007

Morning Coffee 104

  • I'm presenting at a an internal training conference today and tomorrow, so my Morning Coffee roundup posts will be lighter than usual. On the other hand, I'm taking a bus downtown to the convention center, so I might write something more substantial on the way there and back. Or maybe I'll just read.
  • My wife's blogging will also be light, because she's got her nose buried in a book. If I do read something to or from the conference, it's not that book because she won't let me near it until she's done! :)
  • Speaking of "that book", Werner Vogel drops a few details about how well Amazon handled 1.3 million pre-orders that were delivered on Saturday (including our copy).
  • First drop of IronRuby is available. For now, you can get it from John Lam's blog. Unlike IronPython, IronRuby will be hosted at RubyForge, not CodePlex, but the site isn't set up yet. Other big news is that the IronRuby team will be accepting external contributions. Are these encouraging signs to the Ruby community?
  • More MS Research goodness: a new drop of Spec# is available. I've written about Spec# before, but haven't had the time to dig into it. (via Larkware)
  • Scott Hanselman takes the red pill. Congrats!
  • Speaking of Scott, he forwards on advice to remove a programmatic crutch. Good advice. Not to go all Petzold on Visual Studio, but I would guess the IDE is the biggest crutch out there. As for giving up compulsively checking email, if that's a goal Scott, I think you might have joined the wrong company...
Posted By Harry Pierson at 8:15 AM Pacific Daylight Time

Friday, July 20, 2007

Morning Coffee 103

Posted By Harry Pierson at 11:48 AM Pacific Daylight Time

Tuesday, June 26, 2007

What is the Rails Question?

Nick Malik asked "what is the Rails "answer" on the Microsoft platform? If we don't install Ruby, do we use Rails on JS or is there a Rails version we may want to put up ourselves?" I guess it depends, what is the Rails "question"?

On the one hand, the question could be "What's the best way to run Rails on Windows?" I think the short answer to that is IronRuby. In the wake of the IronRuby announcement, John Lam wrote that "Nobody would take our implementation seriously if it doesn't run Rails." Some people question the DLR's teams ability to ship a compatible version of Ruby without looking at the source, but my money is on the DLR team. (Of course it is, I'm a kool-aid drinker!)

BTW, I don't think having a JavaScript port of Rails (JailS?) is much of a help for the Microsoft platform. I'm not sure if Steve Yegge's JavaScript Rails port would run on JScript.NET, but I wouldn't bet on it. I would expect you need either the old Active Scripting JScript or the new Managed JScript (aka the DLR based version of JavaScript). Of course, IronRuby runs on DLR as well so why wouldn't you just run Rails on IronRuby instead of the JavaScript port of Rails on Managed JScript?

(Side note - why isn't the new JScript engine called IronJavaScript? Wouldn't that be cooler than Managed JScript? Don't they know "Iron" is the new "#"?)

On the other hand, maybe the question is "can ASP.NET evolve to be more Rails-esque?" I think it's starting to, slowly. Rails at it's core is a Model View Controller web app pattern (aka Action Pack) combined with an Active Record data access pattern (aka Rails' Active Record). Certainly, nothing stops you from using a similar approach with ASP.NET. The Castle Project has an ASP.NET implementation of MVC (aka MonoRail) and Active Record (also called Active Record). But I assume Nick's more interested in what ships natively in the platform to compare to Rails.

On the data access side, I think LINQ to SQL is a a compelling alternative to the various Active Record implementations. It's not an implementation of the Active Record pattern, it looks more like a Table Data Gateway patten. Also, it's not DRY like Rails Active Record, but I think that's more of a function of dynamic vs. static languages. Castle Active Record isn't DRY either. But once you get the hang of the slightly funky syntax (the from clause is first so you can get intellisense) I find LINQ very easy to use. Certainly, building Query Objects is a snap.

On the web app framework side, the story isn't so pretty. The agile folks like MVC because it's easier to test (among other reasons - see update below). Apparently, there's an ASP.NET MVC framework that's "in the works", but AFAIK no one has seen or heard anything about it since the MVP summit. Jeffrey Palermo was impressed with what he saw, but I guess everyone else has to reserve judgement until it gets a little more public.

Actually, I don't think it's an either-or question, it's both. In order to be the Common Language Runtime, I think it needs to support common dynamic languages like Ruby, Python and JavaScript natively. And, in order to be the best platform, I think the .NET Framework in general and ASP.NET in particular need to support multiple approaches to meet the needs of different developers.

UPDATE - in the comments, Jeffrey Palermo points out that he likes MVC "mostly because it separates concerns of controlling screen and rendering the screen. It makes the application more maintainable and keeps the code easily changeable." Point taken. I didn't mean to imply that testability was the only virtue of MVC.

Posted By Harry Pierson at 2:33 PM Pacific Daylight Time

Monday, June 25, 2007

Morning Coffee 94

  • By most accounts, the Capitals had a good draft this weekend. They started the day with ten picks across the seven rounds. The ended the day with ten prospects as well as three extra picks next year, including two second rounders. According to the GM George McPhee (aka GMGM), next year's is "supposed to be a terrific draft" which is probably true but what you always say when you trade down for future picks. On the other hand, if the guys you want are available further down, why not stock up on the future picks?
  • John Lam reports on Steve Yegge's Rails port to JavaScript that he saw at Foo Camp. Google (aka Steve's employer) wasn't interested in adopting Ruby or Rails since they already use C++, Java, JavaScript and Python. So Steve ported Rails to JavaScript. Wow. However, it does beg the question which is more valuable, Ruby or Rails? If you could have just one or the other, which would you choose?
  • Speaking of dynamic languages, Powershell Community Extensions v1.1 is out. I want to check out the new Elevate function. Currently, I'm using the Script Elevation PowerToys, but I would rather have a pure PS solution. (via Powershell Team Blog)
  • I always know it's a slow day when I decide to check TechMeme while writing my Morning Coffee post. Usually, I get plenty to write about from just my news reading. However, right now, even TechMeme seems mostly uninteresting. Only thing remotely interesting to me is Samsung's new 64GB solid state drive.
Posted By Harry Pierson at 9:57 AM Pacific Daylight Time

Tuesday, June 12, 2007

Morning Coffee 88

I've got over 500 unread news posts and 200 emails in my inbox to process. So this is nowhere near comprehensive.

  • Clarius released the June 07 CTP of their Software Factory Toolkit. Big new feature in this drop is T4 Text Template editor that has syntax highlighting and eventually intellisense. They also released the May 07 CTP of VSSDK Assist, previously known as VSIP Factory. Haven't played with either yet, but it seems like a good time to be a tool builder.
  • PowerShell hits a million downloads in six months. No surprise there, IT'S FRAKING AWESOME. Jeff Snover details seven MSFT products using PS, promising many more that he can't talk about. See earlier comment about being fraking awesome.
  • Speaking of PS, I don't "get" Server Core because it doesn't support managed code. So no PS for Server Core. They announced @ TechEd that Server Core will support IIS 7, but since there's no CLR you can't run ASP.NET. As far as I'm concerned, no PS and no ASP.NET is below the minimum threshold of usefulness. I realize it's technical limitation related to the current factoring of the .NET Framework and I assume some team somewhere in Redmond is working on fixing it. But what's the point of releasing Server Core in the meantime?
  • QUT releases version 0.8 of their Ruby.NET compiler. Given that the IronRuby guys bootstrapped by licensing the Ruby.NET compiler, I wonder how these two projects will evolve side by side.
  • Speaking of Ruby, JRuby has gone 1.0. Congrats!
  • At TechEd, I saw my friend Steve Jones from Capgemini, and it's not this Steve Jones. Woops. But CRUD is still CRAP.
  • Pat Helland breaks Scott Hanselman's Rule #2 and details how he "lost a Megan".
  • My ex-teammate David Hill has been busy with Acropolis. If you are even the slightest bit interested in this technology, you should be reading his blog.
  • Microsoft acquired a company called Stratature last week. I don't typically track MSFT acquisition news + it was lost in the noise of TechEd. But Roger Wolter thinks it's a great move and that Stratature's Master Data Management hub product is one of the best. Given the importance of MDM in SOA, I think I need to go learn more about this product.
Posted By Harry Pierson at 8:58 AM Pacific Daylight Time

Friday, June 01, 2007

Morning Coffee 87

FYI, I'm at TechEd all next week. Given that WiFi access at conferences usually blows, I'm not planning on regular morning coffee posts. I've asked Dale again to keep the lights on around here and he's graciously said yes. Since I'm not on vacation, I'll be lurking around as well, but I'll be in an out. See you in Orlando!

  • Jeff Atwood proclaims that developers are their own worst enemy, because they write too much code. Add in a pinch of "not invented here" syndrome and I think you've got it. This is one of the reasons why people think Ruby is the tits.
  • Scott Hanselman has already taken advantage of the new WLWriter provider customization API.
  • Erik Johnson writes about the thunderous REST bandwagon. He doesn't explicitly say it, but my take is that he thinks this all ends up in some middle ground between REST and WS-*. I hear that, at least, if that's what he's saying. I'm not sold on "HTTP is all you need" - I need durability and async messaging, but I don't see how to get there from here with just HTTP.
Posted By Harry Pierson at 11:30 AM Pacific Daylight Time

Thursday, May 31, 2007

Morning Coffee 86

  • Google announces Gears, a browser plugin for taking your web application offline. Developer docs are also available. TechMeme has lots more, but obviously this is yet another significant bow shot in the upcoming unified client platform war. By my count, there are four horses in this race: Microsoft with .NET and Silverlight, Adobe with Flash and Apollo, Google with AJAX and Gears and Sun with Java and JavaFX. Did I miss anyone? (via Dare Obasanjo and Scott Hanselman)
  • Alex James writes that REST is about intent and shows a pseudo-code sample posting multiple changes to a single endpoint as a way of demonstrating your intent that they be applied atomically. Andres Aguiar left a comment saying that Astoria does something similar. Personally, I like that model for transactions better than the transaction factory approach Jon Udell describes. But either way, you've moved beyond simple CRUD style services and into the world of protocol. Surfacing intent via protocol aligns with what Tim described as making the protocol explicit
  • Windows Live posted new beta versions of Writer, Mail and Messenger. I've been on an internal build of the new Writer for a while and I've really been impressed. There's also a new Provider Customization API, so I can't wait to see what the DasBlog folks do with that.
  • Scott Guthrie's LINQ series continues, this time covering how to build the LINQ to SQL data model. Looks like they used the DSL toolkit to build the LINQ to SQL data model designer, cool! 
  • Martin Fowler digs into racc, a yacc-esque compiler compiler for Ruby. Looks interesting as a internal DSL example (better than the now-canonical rake example). But why is the sexy new language on the block using old school CFG's instead of new hotness PEG's?
  • Speaking of Martin, he writes about the opportunity Ruby presents to Microsoft, building on Scott Hanselman's concerns that Microsoft is losing the Alpha Geeks. Sam Gentile also weighs in, suggesting that Microsoft is at the crossroads. Frankly, I don't work in evangelism anymore so I'm going pass these links along without comment except to say that Scott, Martin and Sam are all folks I have much much respect for.
Posted By Harry Pierson at 11:15 AM Pacific Daylight Time

Wednesday, May 23, 2007

Morning Coffee 82

  • Dare reached a similar conclusion about Silverlight and Apollo that I did. But newly minted Adobe RIA evangelist Ryan Stewart writes that calling Silverlight vs. Apollo the next platform competition is overblown. However, he then reiterates my point that MSFT is moving in on Adobe's traditional stronghold (aka the web) while Adobe is moving in on MSFT's traditional stronghold (aka the desktop). The upshot is that both companies are trying to deliver a unified "client" platform that spans desktop, devices and browser. That sounds like "platform competition" to me.
  • Apparently I'm missing the this years compiler dev lab. :( John Lam is there, with slides from his talk on the DLR. Miguel de Icaza is there, with fairly extensive notes. Hopefully they will post talks like they did last year.
  • Speaking of languages, Scott Hanselman explains why he thinks Ruby is "the tits". Personally, on the scale between "I can't see where Ruby is such hot shit" and "Ruby is the tits", I'm somewhere near the middle, leaning towards tits. I love the expressiveness of Ruby's syntax, but I miss the static typing. Call me over the hill, but I like the compiler catching mistakes at compile time. I realize it's not for everyone, but I like what I like.
  • This talk about Ruby's expressiveness reminds me of something Larry O'Brien said in the wake of the IronRuby announcement: "I am surprised by the IronRuby announcement. I really thought we were going to see some form of Ruby#:Ruby::C#:Java. Although I'm happy, I was actually hoping to see a new language." The expressiveness of Ruby that Scott describes (which is to say, not all of Ruby's expressiveness) would be completely achievable in a statically typed language. Personally, I'd like to see that language...
  • My birthday is past, but I want a Lego Ice Cube Tray. (via Geekdad)
Posted By Harry Pierson at 11:01 AM Pacific Daylight Time

Tuesday, May 08, 2007

Morning Coffee 75

  • 3D Printing is going to be huge. According to the NYT, we'll be looking at around $1,000 for one within four years. For the impatient, check out Fab@Home and build one right now.
  • It's been a while since I experimented with the P2P stack in Windows, but it looks like it's getting the managed treatment in VS "Orcas".
  • The managed Ruby hits keep on coming. Last week was DLR and IronRuby. This week it's a new drop of Ruby.NET which includes VS integration.
  • Looks like Sun is trying to get back into the Ajax/Flash/Silverlight fray with JavaFX Script. I wrote over a year ago that "In platform portability, Flash has succeeded where Java failed." I can't help but believe JavaFX is too little too late. Also, it's yet another Java technology name that sounds like it's been blatantly copied from MSFT. JDBC, JSP, JDO ... What's next? JINQ? (via TechMeme)
  • Steve Maine has a great series of posts on the new Web Programming Model that's coming in .NET 3.5 and is currently being previewed as part of the BizTalk Services SDK. But it was his Balancing reach and rich post that I found most illuminating. The first version of WCF feels hopelessly bound to the WS-* view of the world, which makes it difficult to incorporate alternative messaging models into the same programming model. I've run into this trying to use SSB with WCF. In the next version, that WCF / WS-* marriage looks like it's getting a little more open. In my current role, I'm not so interested in the web programming model, but I am very interested in how they are integrating these alternative models.
Posted By Harry Pierson at 10:16 AM Pacific Daylight Time

Friday, May 04, 2007

Morning Coffee 73

  • The MSDN folks have a utility for creating custom help files from the online MSDN library. I didn't realize MSDN even had a content service. This is tres useful.
  • Jeff Atwood explains how error-filled the web is and how error-tolerant modern web browsers are. I've often argued that one of the keys to the rise of Visual Basic was because it was tolerant of sloppiness. It's hard to argue with Jeff's conclusion that "forgiveness by default is what works".
  • BizTalk Labs shipped an update to the Connectivity Service. It "now supports simple publish and subscribe eventing. This allows multiple clients to subscribe to a service and receive notifications." Steve Maine has some details and a link to the MIX session he did with Don.
  • Larry O'Brein is happy about IronRuby, but was hoping to see a new Ruby/C# hybrid language. Even though it's his "#1 administrative programming language", he specifically hopes for a new language so would "have the flexibility to evolve the language." But Larry, MSFT already had an dynamic administrative language that it can evolve! It's called PowerShell...
  • The XNA folks have shipped a bunch of new content, including the Racing Game Starter Kit.
  • Machinima is growing up fast. I just discovered iClone, a real-time 3D animation filmmaking tool. You know, my birthday is coming up later this month...
Posted By Harry Pierson at 12:19 PM Pacific Daylight Time

Thursday, March 15, 2007

I'm Wrong Because Ruby and Powershell Are Mainstream

Brad Wilson and Scott Hanselman took me to task for my comment the other day that no "mainstream" language had implemented extension methods:

How mainstream is Ruby on Rails for you? Ruby is a full fledged dynamic language. No hacks for "extension methods" (Brad)

Ya, I kind of blanched at that statement too...method_missing is pretty mainstream... (Scott)

They're right, Ruby does support the addition (and redefinition I think) of methods on a class at any time. There's a sample of this in the Classes and Objects chapter of Programming Ruby (aka the pick-axe book) where they add a basic documentation facility "available to any module or class" in Ruby by adding a doc instance method to the Module class.

class Module
  @@docs = Hash.new(nil)
  def doc(str)
    @@docs[self.name] = str
  end

  def Module::doc(aClass)
    # If we're passed a class or module, convert to string
    # ('<=' for classes checks for same class or subtype)
    aClass = aClass.name if aClass.type <= Module
    @@docs[aClass] || "No documentation for #{aClass}"
  end
end

Given how Ruby classes are defined, I think the newly added methods have access to the private data of the class. Extension methods in C#3/VB9 only have access the public interface of the object. But that's a fairly minor difference.

FYI, Powershell can do this as well, though not as succinctly as Ruby. Scott has an example how you can add a DatePhotoTaken property to System.IO.FileInfo using Omar Shahine's PhotoLibrary project.

Chalk this up to my continuing ignorance of dynamic languages. I'm working on it, albeit slowly.

Posted By Harry Pierson at 12:53 PM Pacific Standard Time

Tuesday, February 20, 2007

Internal DSLs in PowerShell

(Harry is on a secret mission in uncharted space this week, so instead of the daily Morning Coffee post, you get a series of autoposted essays. This post combines both some leftover learnings about Ruby from Harry's Web 2.0 days with his recent obsession with PowerShell.)

My first introduction to the idea of internal DSLs was an article on Ruby Rake by Martin Fowler. Rake is Ruby's make/build utility. Like most build tools like Ant and MSBuild, Rake is a dependency management system. Unlike Ant and MSBuild, Rake doesn't use an XML based language. It uses Ruby itself, which has huge benefits when you start doing custom tasks. In Ant or MSBuild, building a custom task requires you to use a external environment (batch file, script file or custom compiled task object). In Rake, since it's just a Ruby file, you can start writing imperative Ruby code in place.

Here's the simple Rake sample from Fowler's article:

task :codeGen do 
  # do the code generation 
end 

task :compile => :codeGen do 
  # do the compilation 
end 

task :dataLoad => :codeGen do 
  # load the test data 
end 

task :test => [:compile:dataLoad] do 
  # run the tests 
end

The task keyword takes three parameters: the task name, an array containing the task dependencies and a script block containing the code to execute to complete the task. Ruby's flexible syntax allows you to specify task without any dependencies (:codegen), with a single dependency (:compile => :codegen), and with multiple dependencies (:test => [:compile,:dataLoad])

So what would this look like if you used Powershell instead of Ruby? How about this:

task codeGen { 
  # do the code generation 
}

task compile codeGen {
  # do the compilation 
}

task dataLoad codeGen { 
  # load the test data 
}

task test compile,dataLoad {
  # run the tests 
}

Not much different. PS uses brackets for script blocks while Ruby uses do / end, but that's just syntax. Since it lacks Ruby's concept of symbols (strings that start with a colon), PS has to use strings instead. Otherwise, it's almost identical. They even both use the # symbol to represent a line comment.

There is one significant difference. For tasks with dependencies, Rake uses a hash table to package the task name and its dependencies. The => syntax in Ruby creates a hash table. Since the hash table has only a single value, you can leave of the surrounding parenthesis. The key of this single item hash table is the task name while the value is an array of task names this task depends on. Again, Ruby's syntax is flexible, so if you have only a single dependency, you don't need to surround it in square brackets.

In Powershell, the hash table syntax isn't quite so flexible, you have to surround it with @( ). So using Rake's syntax directly would result in something that looked like "task @(test = compile,dataLoad) {...}" which is fairly ugly. You don't need to specify the square brackets on the array, but you having to add the @( is a non-starter, especially since you wouldn't have them on a task with no dependencies.

So instead, I thought a better approach would be to use PS's variable parameter support. Since all tasks have a name, the task function is defined simply as "function task ([string] $name)". This basically says there's a function called task with at least one parameter called $name. (All variables in PS start with a dollar sign.) Any parameters that are passed into the function that aren't specified in the function signature are passed into the function in the $args variable.

This approach does mean having to write logic in the function to validate the $args parameters. Originally, I specified all the parameters, so that it looked like this: "function global:task([string] $name, [string[]] $depends, [scriptblock] $taskDef)". That didn't work for tasks with no dependencies, since it tried to pass the script block in as the $depends parameter.

Here's a sample task function that implements the task function shown above. It validates the $args input and builds a custom object that represents the task. (Note, the various PS* objects are in the System.Management.Automation namespace. I omitted the namespaces to make the code readable.)

function task([string$name)     
{    
  if (($args.length -gt 2-or ([string]::isnullorempty($name)))    
  {    
    throw "task syntax: task name [<dependencies>] [<scriptblock>]"    
  }    
       
  if ($args[0-is [scriptblock])    
  {    
    $taskDef = $args[0]    
  }    
  elseif ($args[1-is [scriptblock])    
  {    
    $depends = [object[]]$args[0]    
    $taskDef = $args[1]    
  }    
  else    
  {    
    $depends = [object[]]$args[0]
    #if a script block isn't passed in, use an empty one    
    $taskDef = {} 
  }    

  $task = new-object PSObject    
  $nameProp = new-object PSNoteProperty Name,$name    
  $task.psobject.members.add($nameProp)    
        
  $dependsProp = new-object PSNoteProperty Dependencies,$depends    
  $task.psobject.members.add($dependsProp)    
        
  $taskMethod = new-object PSScriptMethod ExecuteTask,$taskDef    
  $task.psobject.members.add($taskMethod)    
        
  $task    
}

Of course, you would need much more than this if you were going to build a real build system like Rake in PowerShell. For example, you'd need code to collect the tasks, order them in the correct dependency order, execute them, etc. Furthermore, Rake supports other types of operations, like file tasks and utilities that you'd need to build.

However, the point of this post isn't to rebuild Rake in PS, but to show how PS rivals Ruby as a language for building internal DSLs. On that front, I think PowerShell performs beautifully.

I'm looking forward to using PowerShell's metaprogramming capabilities often in the future.

Posted By Harry Pierson at 11:08 PM Pacific Standard Time

Friday, February 09, 2007

Morning Coffee 28

  • From the "Ask and ye shall receive" department: A couple weeks ago I wondered how good or bad my Gamerscore conversion rate is. MyGamerCard.net just launched a completion leaderboard where they rank you on your Gamerscore times your completion rate.
  • Shane Courtrille pointed out that the prize you receive in from the Xbox Rewards program gets better if your Gamerscore is higher. With a meager 1090 points, I'm in level 1. But those with 10,000+ or more can get a copy of Fuzion Frenzy 2 for completing the challenge.
  • Yesterday, I complained that code in my RSS feed looks awful. It appears to be a problem with dasBlog. In validating the HTML is actually XHTML, it screws up the white space. Of course, usually that's not a big deal, but inside a <pre> tag, it is. Until I get a chance to submit a patch to dasBlog to fix this, I'm using CodeHTMLer, which has a "convert white space" option that doesn't use the <pre> tag at all. As a bonus, it even support PowerShell! Note, you have to use the website, not their WLWriter plugin, if you want the convert white space option.
  • There's a new beta of Ruby.NET available. Now that I've moved on to PowerShell, I'm only slightly interested in Ruby these days. If I can figure out how to create internal DSLs with PS, what would I need Ruby for? (via Larkware)
  • My old team just shipped a single-instance multi-tenancy SaaS sample called LitwareHR. Details are on Gianpaolo's blog, code is up on CodePlex.
Posted By Harry Pierson at 9:46 AM Pacific Standard Time

Wednesday, June 21, 2006

Alpha Release of Ruby.NET

I'm not sure what a "Preliminary Beta" is but QIT has released a one for their Ruby.NET compiler. They expect to achieve "full semantic compatibility" (can you tell this is an acidemic project?) by the end of the year. Thanks to David Ing for the link.

They claim to "pass all 871 tests in the samples/test.rb installation test suite of