I came across this article that blew my mind and scared the crap out of me at the same time. Its is titled Life 2.0 in Newseek Magazine.

Here is a quote that connected it to software development for me …

“We can now regard cells as ‘programmable matter’,” says Ron Weiss, a Princeton computer scientist who now writes genetic software for cells. Weiss is convinced that he will soon be able to “program cell behaviors as easily as we program computers.”

 The prospect of engineering new organisms from scratch opens up all sorts of possibilities — Good and bad.

I like to think more good than bad. The article mentions developing a “highly efficient biological organism that converts sunlight directly into a clean bio fuel” – now that is mind boggling.

Imagine a day when we can program cells and create new living entities with a programming language – Cell# maybe?

This one is going to take a while to sink in.

- M

Script#

May 25, 2007

I just came across something that I originally found last year that I thought was so very cool.

I don’t know about you but the experience of writing Javascript without really good tools for debugging is a real pain in the a$$.

What if you could write C# with all of its strong-typed-ness and awesome development environment (VS.NET 2005) then just compile it to JavaScript?

Check out Script#

EDIT: Link to more updated build of Script# – thanks Nikhil for the correction

This is such a great idea – instead of compiling to IL – compile to Javascript. The combination of the C# to Javascript compiler  and the object oriented extensions MS made to Javascript for ASP.NET AJAX - makes for very clean Javascript code.

It even provides a debug version that has easy to read code and a release version that compresses everything down (no white space and small private variable names) to make it as small as possible.

I found a good screencast on Channel9 where the author (in about 9 minutes) writes a Javascript behavior in C# that provides text-box watermark functionality.

So very cool

 - M

In a recent project we went through the process of upgrading the MS Enterprise Library v2 to v3. We were eager to upgrade to v3 because in v2 whenever you made multiple database calls within a .NET transaction, the transaction was being promoted to a distributed transaction (even though the calls were to all to the same database.)

We realized this was happening when we enhanced some code by making it transactional and it starting failing on the production server. The error we were getting had to do with the fact the DTC (Distributed Transaction Coordinator) service was not running. We thought this was strange because even though there were multiple database calls within the transaction, all the calls were to the same database. So why would it need a distributed transaction?

We turned on the DTC service and all was fine but we still wanted to know why this was happening. It turns out that v2 of DAAB was creating multiple connections when making multiple database calls within a transaction – even if they were to the same database. As soon as more than one connection is created within a transaction, the transaction gets promoted. This makes sense from a transaction standpoint if the calls are to different databases.

I had read somewhere that v3 was going to fix this issue by reusing connections to the same database – preventing the promotion from occurring. So when it released we quickly replaced the v2 DLLs with v3. Everything built fine, so we knew at least the syntax for the calls we were making were identical. We thought it would be a smooth upgrade from here on in…BUT as we all know just because something builds does not mean it is going to run.

When we started to test the application, we came across a strange database error that we had not seen before.

System.InvalidOperationException: There is already an open DataReader associated with this Command which must be closed first.

After some poking around we found that there were several places we were iterating through IDataReaders and then calling code that also created a IDataReader. All of this reader creation code was running in the larger context of transaction created outside of the reader code.

So the issue of v2 creating multiple connections with in a transaction was actually allowing the reader within a reader iteration to function properly. But when v3 changed it so connections to the same database would re-use a single connection – it broke this code that ran fine originally in v2 when it wasn’t transactional and ran fine in v2 when it was transactional (as long as DTC was on).

So the solution we came up with was to convert the outer reader to a DataSet due to its disconnected nature (unlike the IDataReader).  This allowed the connection that was previously tied up by the outer reader to be reused to create the inner readers. Now it all works like a charm – no more transaction promotion and no more reader conflicts.

Now onto the next challenge…

- M

Microsoft Silverlight

May 22, 2007

This is old news but Microsoft announced a new technology that they are calling Microsoft Silverlight on April 30th 2007.

On the surface, v1.0 might be seen as an Adobe Flash competitor – which I think it pretty much is.

Where it gets interesting for me is in v1.1 which is currently available in Alpha and targeted to be available by the end of this year.

This is the version that gives you the ability to write cross-platform browser apps in languages like C# without having to resort to Javascript (unless you enjoy that sort of thing). It runs on top of a trimmed down version of the .NET Framework – not the compact framework – but a version of the framework with only things that relate to writing web apps. It also has something called the DLR which is essentially an extension to the CLR that makes it easier to port dynamic languages (like Ruby and Python) to the .NET framework.

This is a huge deal for developers who currently target the .NET framework and are tired of writing browser apps that use HTML for the GUI and Javascript for client-side interactivity – I know I am ready for something better.

I look forward to the day where you can write a desktop quality app and have it run in a browser.

- M

My New Blog

May 21, 2007

This is my second attempt at starting and keeping a blog up to date. I will attempt to write something at least once per week that is interesting to a small group of people some of the time.

I will focus on things .NET that I think about.

Enjoy
Michael