Thursday, March 27, 2008

Beta Browsers 2008

This is a big year. Both IE and Firefox will release new versions this year. That hasn't happened ... ever? IE8 had its first beta, whereas Firefox 3 is at beta four. Indeed FF3 is much more polished at this point than IE8. However, I must say that Microsoft has been smarter than the Firefox team in a number of ways.

First, IE8 includes an improved IE Developer Toolbar by default. The IE DevBar is roughly equivalent to Firebug, but Firebug does not work with FF3. Of course you can’t really blame this on FF, but IE8 is much more web developer friendly. Web developers are the primary (only?) audience for beta browsers. IE8 also includes the IE7 emulation mode. Again this is very nice for web developers who have to program for IE7 currently, but need to get a head start on IE8 (wait, isn’t that all web developers?)

Vista Annoyance #432

A few weeks ago, I watched Guy Kawasaki's interview of Steve Ballmer at MIX. Kawasaki gave Ballmer a hard time about Vista. It made me think of some of the problems I have had with Vista. I started thinking "well things seem better now.' Then this morning I try to log on to my home system and get an error message saying that Windows could not load my user profile. In the event viewer it says:

Windows cannot load the locally stored profile. Possible causes of this error include insufficient security rights or a corrupt local profile.

DETAIL - The process cannot access the file because it is being used by another process.

Luckily I rebooted and everything was ok. Yep, rebooting is still the best way to fix most Windows problems. Things haven't changed much in the last fifteen years.

Actually I still have other problems with Vista. I still get problems caused by Windows Firewall. Vista was so unstable on my MacBook under Parallels that I replaced it with XP. In December, my Vista install was completely corrupted. After several minutes of use, its network and memory consumption would go ballistic making the system unusable. I thought at first it was a virus or malware of some sort, but I never found any evidence of either. I wound up re-installing Vista to fix the problem.

Now Vista SP1 is out. I don't know if I should be hopeful that it will be a remedy for all of my pains ... or if it will just be fuel for the fire and cause me to "upgrade" Vista to XP.

Wednesday, March 19, 2008

eBay on developerWorks

I have written a lot of articles for IBM over the last couple of years. Most recently I got a chance to write about "my day job" if you will: eBay. I wrote two articles on how we use Eclipse at eBay to tackle a lot of interesting problems. When I first came up with the idea for the two articles, it seemed really cool but I was a little worried about it being complicated. When you think of a large company (and with 15,000 employees and a $36B market cap, eBay certainly qualifies) you think of all kinds of red tape, armies of lawyers, etc. I was pleasantly surprised to have almost none of that to deal with for these two articles. The articles definitely show some of what's "under the hood" at eBay, but its just enough to explain some of eBay's unique needs and how we have used Eclipse to help with these needs.

Monday, March 17, 2008

Go Disney?

A friend of mine got the following email:
Dear Parent of Chris,
We're pleased to inform you that your teenager has registered with us
and will now have access to the Internet sites of the
Walt Disney Internet Group ("WDIG") including Disney.com, ABCNEWS.com,
ABC.com, ESPN.com, FamilyFun.com and many more!

As a result, we want to make you aware of all of the information below:

1. Participation in WDIG Site Features. Now that your teenager is
registered with us, he/she can participate in all of the features we
make available on our sites to registered guests under the age of 18,
including games, sweepstakes, contests and interactive features on our
sites through which personal information can be made public to the
Internet and shared with users of all ages (i.e., "Public Forums").
// Random B.S. omitted

2. Terms of Use. Use of all WDIG Sites is governed by the
"Terms of Use" posted at the bottom of each WDIG Site.

The Terms of Use contain important provisions governing your, your
teen's and our rights including acceptable conduct on the WDIG Sites,
intellectual property rights (for example, our right to use
information, content and materials submitted to us by your teen) and
other rights available to you, your teen and us. We ask that you
read the Terms of Use and ensure that you understand them. If you
do not want you and your teen to be bound by these terms, you must
revoke your teen's registration. If you revoke your teen's
registration, your teen will not be able to access any portions of
the WDIG Sites that are made available only to registered guests.

Click below to view the Terms of Use:

http://disney.go.com/corporate/legal/terms.html

By not revoking your teen's registration, you agree that you and your
teen will be bound by the Terms of Use in connection with his/her use
of WDIG Sites and you agree to personally ensure that your teen
complies with the Terms of Use. (emphasis added)

If you want us to revoke your teen's registration, click below:

// link removed
How awesome is Disney! Under-age? No problem. Go ahead and register on their site. Then your parents will receive an email and have to read it and click on something to revoke your registration. Or better yet, just use a bogus email for your parents to remove the off chance of them actually reading the email and being responsible.

That is clearly the case here in fact. My friend has no children, so clearly some child picked a random email address that happened to be my friend's. Now if that child will start publishing plans to blow up buildings on a Disney forum page, my friend can be held responsible (per the Terms of Use.) Lovely!

Thursday, March 13, 2008

Silverlight Stocks

Ever since details of Silverlight 2.0 came out, I planned on re-doing my stocks app using it. This is an app that I first wrote for a GWT tutorial I did for IBM, and then re-wrote when I learned Flex last year. I wanted to write it in Silverlight last year, but Silverlight was not ready then. Now it is. Here's a picture of it.


This look-and-feel is all defaults. It looks like a web page! It's usually easy to spot Flex apps, but that is not as true with Silverlight. Everything works the same as with the Flex or GWT versions, except the color-coding for stocks that are up or down. I figured out how to define styles with Silverlight (more on that) but could programmatically set the style. Let's take a look at the code. First the UI code.


<UserControl x:Class="SilverStocks.Page"
xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400" Height="300">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<TextBlock Text="Enter Symbol "/>
<TextBox x:Name="symbol" Width="100" KeyDown="symbol_KeyDown"/>
<Button Click="Button_Click" Content="Get Info" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Company Name: "/>
<TextBlock x:Name="company"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Price: "/>
<TextBlock x:Name="price" Text="$"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Change: "/>
<TextBlock x:Name="change" Text=""/>
</StackPanel>
</StackPanel>
</UserControl>


Pretty similar to MXML, but distinctive. As with ASP.NET pages, Silverlight puts all code in a code-behind file:


public partial class Page : UserControl
{
const string url = "http://localhost:8080/Stocks/Stocks?symbol=";
public Page()
{
InitializeComponent();
}

private void Button_Click(object sender, RoutedEventArgs e)
{
invokeStockService();
}

private void invokeStockService()
{
string symbol = this.symbol.Text;
WebClient service = new WebClient();
service.DownloadStringCompleted += new DownloadStringCompletedEventHandler(handler);
service.DownloadStringAsync(new Uri(url + symbol));
}

private void handler(object sender, DownloadStringCompletedEventArgs args)
{
if (args.Error == null)
{
this.showInfo(args.Result);
}
}

private void showInfo(string xmlContent)
{
XDocument root = XDocument.Parse(xmlContent);
var stocks = from xml in root.Descendants("stock")
select new Stock
{
Symbol = (string) xml.Element("symbol"),
Company = (string) xml.Element("companyName"),
Price = Decimal.Parse((string)xml.Element("price")),
Change = Decimal.Parse((string)xml.Element("change"))
};
foreach (Stock stock in stocks)
{
this.company.Text = stock.Company;
this.price.Text = stock.Price.ToString();
this.change.Text = stock.Change.ToString();
}
}

private void symbol_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
this.invokeStockService();
}
}
}


Notice that I used the LINQ-XML cleverness, as advocated by Scott Gu. Most dynamic language folks will probably favor ActionScript's E4X over using this lambda-ish query language and a statically defined class. Actually I'm sure I could refactor this to not use the class at all, and just set the text fields during the query.

Finally, the other major difference between the two is the Flex framework's mx:HttpService. This component encapsulates the call to the back-end and provides dynamic binding. There is no handler code in the Flex version because of the binding. Will data source bindings and components like mx:HttpService find their way in to Silverlight?

Wednesday, March 12, 2008

JsonViewer Updated

Some folks pointed out that the JsonViewer installer was complaining about being on the wrong version of AIR. That was because I wrote it before AIR went 1.0. So I thought "no problem, just re-compile it." Well sort of.

I updated Flex Builder 3 to the GA version and updated AIR to 1.0. I imported the old project. It picked up my Subversion settings and what not, very nice. I did a new "export release version" and it worked just fine. I tried to execute the .air file and it bombed. It told me that my AIR file was damaged.

WTF!? I tried to run the app directly from Flex Builder. It did nothing. No errors, just nothing. So I tried debugging. Then I finally got an error message about using the wrong version of AIR. I opened up the JsonView-app.xml. There was no "setting" in here for AIR version, but then I saw this

<application xmlns="http://ns.adobe.com/air/application/1.0.M6">

Yep the .M6 was killing me. I removed it from the XML namespace declaration, and voila! Everything worked perfectly. Show your appreciation for my pain by downloading JsonViewer.

Monday, March 10, 2008

New developerWorks Article on WSAS and Eclipse

IBM published a new article I wrote last week. This one is titled WSAS and Eclipse simplify creating Web services. It is about the WSO2's Eclipse plugin that comes with their Web Services Application Server. The article shows how the plugin let's you take any POJO and turn it into a web service.

Sunday, March 09, 2008

Fantasy Baseball 2008

Oh yeah, it's that time of the year. Of all fantasy sports, baseball is without a doubt the best. I have had a mostly straightforward formula I have used over the years to rank players. This year's results top 30 (I did top 30 so I could squeeze in Tim Lincecum):

  1. Johan Santana 9.997069335

  2. Chase Utley 9.395566713

  3. Matt Holliday 9.28777674

  4. Alex Rodriguez 8.06973671

  5. Albert Pujols 7.362279704

  6. Jake Peavy 6.687233845

  7. Vladimir Guerrero 5.979646533

  8. Victor Martinez 5.724916421

  9. David Ortiz 5.661505849

  10. Ryan Howard 5.650694866

  11. Alfonso Soriano 5.226027058

  12. Carlos Lee 5.114022165

  13. Jonathan Papelbon 5.06406981

  14. Grady Sizemore 5.012756748

  15. Lance Berkman 4.721401161

  16. Hanley Ramirez 4.707462255

  17. Miguel Cabrera 4.202140221

  18. Jimmy Rollins 4.069476267

  19. J.J. Putz 4.013553495

  20. David Wright 4.007944434

  21. Joe Nathan 3.984203692

  22. Adam Dunn 3.907455051

  23. Mariano Rivera 3.793661698

  24. Prince Fielder 3.7901273

  25. C.C. Sabathia 3.749804343

  26. Russell Martin 3.703008847

  27. Carlos Beltran 3.629816436

  28. Ryan Braun 3.556328479

  29. Tim Lincecum 3.377436453

  30. Robinson Cano 3.376123846


The big weakness is always my source of projections. I prefer to be somewhat random about this. Sometimes I tweak based on personal bias. This year I did not. The numbers don't mean too much, unless you are in an auction league. In that case, a rating of 0 corresponds to the average price of a starting (non-bench) player. An increase of 1 point corresponds roughly to a 40% premium. So if rating(Player x) - rating(Player y) = 1.0, then $(Player X)/$(Player Y) = 1.4.

Thursday, March 06, 2008

IE-Hell Freezing Over

Even after I heard the rumors, I still never thought I'd see it with my own eyes:

My enthusiasm was quickly curbed when I tried to use IE8 to post this blog entry. Not only did the Blogger interface look crazy, but the upload image link did not work. I tried switching to "Emulate IE7". To do that, you must restart the browser. That's not very practical, and just means that most people will have to default to the IE7 emulator. Oh well, I guess Blogger just needs to fix up their non-standard JS? Maybe I will open up a debugger to figure out what is breaking. Probably some kind of browser sniffing code that picks different JS syntax depending on if it is IE or not. Maybe what is needed is an IE8 add-on that fakes the user-agent so that most sites think IE8 surfers are actually Firefox surfers.

Wednesday, March 05, 2008

More JRuby Performance

In the aftermath of my post on JRuby's performance, I exchanged some info with Mr. JRuby himself, Charles Nutter. Per his request, I opened a bug on the matter. It looks like it is a JVM issue, i.e. JRuby ran slowly on IBM's J9 JVM. I did some micro-benching on Ruby vs. JRuby on a variety of platforms and JVMs. It was only on the J9/2.3 (IBM's JDK 5.0 JVM) that JRuby was was slower than the latest "native" Ruby implementation on that platform. Everybody loves charts, so here are some fun ones.


This was on my MacBook, with both the standard HotSpot Java 5.0 and Java 6.0 preview versions. I also compared using the -J-server (just becomes -server for the JVM) option, since HotSpot on the Mac runs in client mode by default. Thus the -server made a big difference.

This was on my home desktop system, a 32-bit Windows Vista system. I only did native Ruby vs. JRuby with and without the -server option. Again JRuby with the -server option crushed native Ruby.

Finally the environment that caused all the problems, my workstation. As you can see, it did quite poor compared to native Ruby. However, JRuby with either the 5.0 or 6.0 HotSpot JVM was much faster. I was actually hoping to see a better performance advantage on the 6.0 VM vs. the 5.0 one... I don't have IBM's 6.0 VM, so I could not include it. The HotSpot VMs were both 64-bit, whereas the IBM J9 on was a 32-bit VM.

Tuesday, March 04, 2008

JRuby Performance

During my lunch today, I solved Problem 12 from Project Euler. As usual, I wrote the solution in Ruby and was surprised by just how long it took to calculate. It made me decide to try JRuby.

First, a note about the problem and my solution. The problem was to find the first triangle number (where the n_th triangle number is 1+2+3...+n) that has at least 500 divisors. My solution was pretty brute force. I took each triangle number and computed its prime factorization. For example 28 = 2^2 * 7^1. Thus the number of factors is (2+1)*(1+1) = 6. Generally if N = A^a * B^b * ... where A,B,.. are primes, then the number of factors is (a+1)*(b+1)*...

With all of that in mind, why did I think JRuby would be faster than Ruby on a problem like this? This kind of calculation is well suited for JVM optimizations: unwinding of loops, JIT'ing of the code, etc. Thus I thought this might be the kind of problem where the JVM could make JRuby run a lot faster than Ruby. Boy was I wrong!

In general, I found JRuby to take twice as long as plain ol' Ruby (or C Ruby as the JRuby folks like to call it.) This was true on Windows, where Ruby is considered to have a poor implementation by many, and on OSX.

This made me thing that my conjecture was wrong to begin with. Maybe this was not the kind of code that the JVM could do much with. I re-wrote the algorithm in Java and re-ran it. It was exponentially faster in Java than in Ruby or JRuby. Indeed, the JVM was able to optimize the runtime execution of the code and make it fly.

Is this what I should have expected? Is JRuby generally much slower than Ruby? I really thought that part of the idea behind JRuby was to leverage the JVM to make Ruby faster.

Friday, February 29, 2008

AJAX, the REST Killer

I was at a demo today that was showing off an application that was designed to be a reference implementation / blueprint app. Of course it had some AJAX based features in it. One of the AJAX calls allowed an existing object to be edited, and another would delete said object. I noticed that the AJAX was using HTTP GET. I pointed out to the developers that since this was supposed to be a blueprint app, it should get everything right and use POST for both of these. Of course it should really use a PUT for the update and DELETE for the delete, but browsers just don't support that.

After the presentation, one of my colleagues pointed out that a lot of times we are forced into GETs because of cross-domain calls. He was right, and made me realize how the hack-that-is-AJAX is always rearing its ugly head. Cross domain calls are part of life for any large, distributed site. In an AJAX world you either have to use JSONP style calls, i.e. using a Script tag to make your call, or you have to use a server proxy. Of course going directly to the appropriate domain is much more efficient, so JSONP is going to usually win. There's no way to do an HTTP POST on a Script tag, so there you go. Forget all about respecting the REST protocol.

Of course Flash and Silverlight (gotta include it now!) both allow for declarative cross domain security. No need for JSONP hacks. Now if only they both supported HTTP PUT and DELETE...

Thursday, February 28, 2008

Silverlight Slim and Fat Flex

A couple of days ago, I talked about Silverlight 2.0. One of the interesting things to me was that it was how Silverlight RIA-style apps could be a lot smaller than Flex apps. I posted a comment to Scott Guthrie and he was kind enough to post a reply to my question. His reply indicates that for Beta 1, a relatively complex application will be slightly smaller than the same thing in Flex. However, much more of the framework is going to be included with the initial Silverlight download starting in Beta 2, thus giving Siliverlight a huge advantage in terms of app size.

When Adobe announced that the Flex framework could be cached on the Flash player across domains, I wondered why the didn't just included it with the Flash player. I have even bugged Flex evangelist Ted Patrick with this question. His response to me was that they would open themselves up to "DLL hell." In other words, there could be problems with people building their app against Flex framework version X, but a user has an older version installed.

As if this doesn't already happen! Let's not forget that Adobe jumped ActionScript from version 2.0 to 3.0 and thus required Flash player 9 or higher for anything authored using 3.0. This was not just some update in framework, it was the entire programming language being overhauled. It is common to use JavaScript to detect Flash player version and require people to upgrade. It is so common and so part of Flash development, that Adobe distributes the ExpressInstall SWF for doing this as easily as possible. Heck, I usually require users to be on 9.0.28 or higher, since that is the version that fixed some bugs with ExternalInterface.

So back to the Flex framework/DLL hell issue. It would simply require people to check for a certain minimum version of the Flash player (since that would correspond to a version of the Flex framework) and prompt for an upgrade if needed. In other words, it would require something that most folks already do today.

To me the real reason is that it is more economical for Adobe to not include the Flex framework. Ted has a widget he wrote showing over 3.9 billion downloads of Flash player 9. Add an extra 200K to that and you get over 726 TB. That's a lot of bandwidth to pay for. That's a price Microsoft wants to pay, because it would indicate lots of folks with Silverlight installed. Perhaps once that happens, Adobe will reconsider.

Wednesday, February 27, 2008

Project Euler

A friend of mine pointed me to Project Euler. Being a mathematician and a programmer, he knew I would love it. It is a lot of fun. It reminds me of these computer competitions I used to participate in when I was in high school. You would get some list of problems on sheet of paper, have to code a solution, and a judge would come by to test your program. Anyways, I am a 4% genius having completed seven problems so far. I am mikeg on the message boards on there, if you want to check out my solutions. So far I have done everything in Ruby. I picked Ruby for two reasons. First, I like its syntax and want to use it more often. Second, it is slow. So I figured it would force me to come up with good algorithms. Here is a sample of one of my solutions. The problem was to find the largest palindrome that is the product of two 3-digit integers.

def isPal(num)
if num % 11 == 0
return num.to_s == num.to_s.reverse
end
return false

end
 
max = 0
999.downto(100){ |i|
i.downto(100){|j|
val = i*j
if val > max
if isPal(val)
max = val
end
else
break
end
}
}
puts max

Monday, February 25, 2008

Silverlight 2.0

We all knew this would happen at some point. Even when it seemed like it would not, you just had to know in the back of your mind that it would happen. Microsoft has given a preview at Silverlight 2.0. This time it is not about media, it is about RIAs. They even use the term correctly now... You should really check out that link and especially the tutorials it links to. They are very high quality.

Like I said, we knew this had to happen. Silverlight 1.0 was really just a streaming media platform. Silverlight 1.1 was only a little better (and isn't it still in beta?) It gave the first real clue though. It included a stripped down CLR, allowing C# to run inside Silverlight. This was a clear indication that Silverlight was going to take aim at developers and thus become Microsoft's answer to Flex.

Now this has finally happened. I spent the last hour reading through the tutorials. There were several things that really made me raise my eyebrows:
  • A 4KB Hello World : It looks like either the controls (and the framework code that lets them get wired up, etc.) are either really small or the compiler is very smart at stripping things down (or both.) Hello World in Flex is 140KB because all of the Flex framework is included. I don't think all of the Silverlight controls/app framework is included with the base runtime, as it clocks in at 4 MB, i.e. about the same size as the Flash player.
  • Crossdomain Silverlight: MSFT wisely just re-uses the Flash crossdomain.xml policy file system to get the same kind of declarative security. Very nice of MSFT to just tip their cap and say Flash got this right, let's not reinvent the wheel on this one.
  • Silverlight Styles: Their style syntax is ... different. Well different from CSS certainly. Adobe has tried to leverage CSS in Flex. The Silverlight style syntax is probably much more powerful than CSS, but you have to wonder if it is really worth it. It is still a declarative XML syntax on top of the selector paradigm used in CSS.
  • Silverlight for the Desktop: Ok not really. But MSFT is going out of their way to point out how easy it is to take a Silverlight app and turn it into a desktop app. This is clearly in response to the attention that Adobe AIR has received.
So I find myself eagerly awaiting the release of Silverlight 2.0 along with the tooling for it in Visual Studio 2008. I will definitely have to (finally) create a Silverlight Stocks Quote app.

Sunday, February 24, 2008

TDD Gone Wrong

Last time I wrote about TDD. I read this article from some guy at Spring about doing TDD with the Google Web Toolkit. I have to say this is a good example of how TDD zeal can lead to some twisted thinking.

The article starts by point out how GWT enables RIA development in pure Java. That's a good thing. He then talks about some of the difficulties he's experienced trying to write unit tests for GWT widgets and concludes:

views are usually very hard to test, therefore they should know and do as little as possible ... Most of the GWT code has pretty much all the logic in widgets, so most developers using GWT extend a widget and just add some more logic. My advice is simple: don't go there.

RIAs are all about putting lots of logic in your view. Now it's not just any logic, but view logic. You see there is logic involved in creating a rich user interface and the place for that logic is the user interface. So this guy's obsession with testing has led him to the conclusion that you should dumb down your view code so you can test it. This completely defeats the purpose of using GWT. Very sad.

I think the author does bring up some valid points on unit testing GWT. If you place a huge importance on unit test coverage, then the more logical conclusion is that you should not use GWT. Don't try to dumb down the technology so that you can sleep better at night. Just pick a different technology.

Thursday, February 21, 2008

Test Driven Development

Terry wrote a great post about "pragmatic" programming. It brings up the usefulness of test driven development(TDD). It is good that this is debated. It seems like it is almost accepted as fact that TDD is good. Period. Whenever people start accepting something without questioning, it leads to very bad things.

So I am glad that Terry questions TDD. Many folks I work with question it, too. Their arguments are different than Terry's. For example they point out that much what you code in a test has to be duplicated by QA. Of course that's not an issue for some folks, because they don't have QA, but it is an issue in larger organizations. Terry uses the example of Facebook as a large organization that uses no hard rules, i.e. TDD, for development. Also, folks I work with point out that TDD is a recurring tax. You not only spend time coding the test to start with, but you spend more time re-writing the tests every time you make changes to your code. The cost of TDD must be weighed against its benefits, you should not just accept it blindly.

To me, the value of tests greatly depends on the clients of your code. Let's say you have code whose only client is the end user, i.e. "application" code. Generally what matters for that code is that it is accepted by the end user. If it does what they want, that is all that matters as that is the only purpose for the code. I can definitely see how writing tests may not have as much value for this kind of code, though I think there is still some value to it.

Now compare this to code whose clients are other pieces of code. To make it simple imagine application code that calls infrastructure code. In this case it's harder to argue that if the end users of the application are happy, then the infrastructure code is good. Imagine if the infrastructure code has an API that is supposed to produce a formatted date. The infrastructure code could produce the wrong formatting, but the application code could work-around this to keep the end user happy. Maybe that is ok, but things get uglier when somebody "fixes" the infrastructure code, particularly if a second application uses the same infrastructure code. Having fine-grained tests for the infrastructure code becomes more valuable.

For me personally, I like using TDD, though I am not religious about it. There are times that I write a test first, then I write the code. There are other times I write the code, then a test, run the test, tweak the test, fix the code, etc. In general, I like to write tests just because I like to test my code to be sure that it works. I figure if I am going to go through the effort of doing that anyways, I might as well do it in an organized way that could be useful to others. Also, writing test code is at least as useful as writing inline documentation in your code, maybe more useful. A unit test is sample code, or darn close to it.

Sunday, February 17, 2008

Clemens v. Congress

The big story in sports this past week was the testimony of Roger Clemens before Congress. Now obviously this was a huge waste of time and (more importantly) tax payer money. It is classic pandering by Congress. We all know this, right?

There was something else that bothered me even more about the Congressional hearings. That was the obvious division along party lines. Republicans clearly supported Clemens and tried to discredit his accuser, Brian McNamee. Democrats clearly wanted to prove Clemens had taken steroids and HGH. I don't have a problem with folks having an agenda (though if everyone has their mind made up already, why a hearing? Oh never mind.) No what bothers me is that this division was along party lines.

Why does the Republican Party need to support Clemens? How is his innocence somehow a priority for the Party? One can only conjecture. Is Clemens a significant contributor to Republicans and the Party?

Similarly, why does the Democratic Party need to prove that Clemens is guilty? Is it just to spite the Republicans? Do they want to bring greater government regulation and involvement to Major League Baseball or sports in general?

These questions just lead us back to the beginning of this post. The government has no business doing hearings on Roger Clemens. Not only is it wasteful, but inevitably the issue itself becomes meaningless thanks to partisan politics.

Oh, and for what it's worth, I think Clemens is lying and that he used steroids and HGH. I don't care if he did or not, but clearly the evidence points against him.

Thursday, February 14, 2008

Metaprogramming in Grails

Groovy is a swing-and-a-miss. It will go down like OS/2 did. People will say "man that Groovy language was so good, I don't know why it didn't catch on." Here's an example of why it is a fail.

I was reading this article on developerWorks about GORM, the OR framework in Grails. Like everything else in Grails, it is "inspired" by Ruby on Rails. In this case GORM was inspired by ActiveRecord. In GORM here is an association:

class Airline {
static hasMany = [trip:Trip]

String name
String url
String frequentFlyer
String notes
}

Compare this to the same thing in Rails

class Airline < ActiveRecord::Base
has_many :trips
end

Forget the explicit listing of fields for a minute, concentrate on the has-many notation used by both frameworks. In Grails, you have a static field that has a special name. In ActiveRecord you use a meta-API or macro (or whatever you want to call it) to dynamically add methods to each instance of Airline. Grails accomplishes the same thing, but it is much more of a hack. You just happen to have a static field that has a special name.

It just feels like "wow that feature is cool, we can't do it the same way ... but we can hack something together that is pretty close!" Just seems like Groovy comes up short.

Tuesday, February 12, 2008

New Version of JsonViewer: Now Open Source!

I updated the JsonView AIR app I wrote a couple of months ago. It has wound up being pretty useful for some of the folks I work with, hence there have been some bug fixes new features requested. I have also had some folks email me about the source code. So as a result of these two things, not only did I update the app, but I released it as open source via Google Code.

So you can get the latest version here, or you can check out the source code for yourself. I was almost embarrassed to show the source because it so trivial!