Thursday, February 28, 2008

Whinning about Microsoft's Inept Naming Schemes

While searching on O'Reilly's code search site this morning, I was reminded how Microsoft chooses unfortunate names for products. My initial problem was searching for code in C# relating to the ICollection interface. I entered the category as "C#":

cat:c# icollection

and got returned a bunch of code snippets on C, C++, and C#. What I needed to say was,

cat:csharp icollection


The problem with "C#" is that it doesn't really play well with search. I can see the cute progression of C, C++, and the the musical incrementation with C#, but it's a pain in search. I can understand a non-technical marketing person (with a degree in music) selecting the name, but a technical company? Sun did a nice job selecting "java" as the final name for the language - it's a real word, but a little obscure. Why couldn't Microsoft select something like "jasper" or some obscure tea name?

And selecting ".Net" as the name of a framework? Isn't ".net" a top level domain? And how do you search for something with a dot in front of it? Don't search engines strip out obscure characters?

And while I'm at it, what sense does it make to name your operating systems, Windows 3.1, Windows 95, Windows 98, Windows 2000, NT, XP, then Vista?
Please, use version numbers, or years, or code names, but don't mix them - it gives a sense of purposeless wandering.

Ok, I feel better now - back to ICollection.

Wednesday, February 20, 2008

China to Open Coal-To-Liquid Plants


According to the Guardian China is about to open the first of many Coal-To-Liquid plants. The technology is well understood and was used by Germany and Japan in WWII. The process will allow China to import less oil and save money. The estimated cost is 25-40 dollars in equivalent barrel terms.
A bad thing about the process is that it produces more CO2 than conventional oil.
This is why I thing the EnvironmentalGraffiti.com smears the technology calling it "Nazi Fuel" (we don't call the F-22 a Nazi-Jet, or the Saturn V a Nazi-Rocket).
Although it does increase CO2, a way to help supplement our energy is a good thing until we can get renewables online.

Calculating with Google.com

I was trying to determine how many times all the DNA in our bodies, if stretched out and laid end to end, would go back and forth to the sun. Don't ask why. I just think about these things so you don't have to. Each cell contains six feet of DNA, our bodies contain 100 trillion cells, the sun is 93 million miles away... the numbers were too big for my calculators, so I thought I'd try Google. I entered:

((6 ft * 100 trillion) / 93,000,000 miles)/2

and out popped my answer, 611. Google calculator does all the unit conversions for us. Very cool.

Tuesday, February 19, 2008

"using" in C#

C# provides an interesting feature with "using". The target of "using" must implement the IDisposable interface which contains one member, Dispose(). After the block is executed, the Dispose() method is called on the target object.

using System;
namespace Doodle {
class DisposableExample : IDisposable {
public void Dispose() {
Console.Out.WriteLine("I'm being disposed!");
}
public static void Main() {
DisposableExample de = new DisposableExample();
using (de) {
Console.Out.WriteLine("Inside using.");
}
Console.Out.WriteLine("after using.");
Console.In.ReadLine();
}
}
}

This produces:

Inside using.
I'm being disposed!
after using.


This can be used to good effect with database connections. Instead of using the finally block to close connections, a "using" block can be more succinct.

using System;
using System.Data.SqlClient;

class Test {
private static readonly string connectionString = "Data Source=myMachine; Integrated Security=SSPI; database=Northwind";
private static readonly string commandString = "SELECT count(*) FROM Customers";

private static void Main() {
using (SqlConnection sqlConnection = new SqlConnection(connectionString)) {
using (SqlCommand sqlCommand = new SqlCommand(commandString, sqlConnection)) {
sqlConnection.Open();
int count = (int)sqlCommand.ExecuteScalar();
Console.Out.WriteLine("count of customers is " + count);
}
}
Console.In.ReadLine();
}
}


"using" can also be helpful with files as this example shows:

using System;
using System.IO;

class Test {
///
/// Example of "using" with files.
/// This repeated creates files and closes them subtly by the "using" statement.
///

private static void Main() {
for (int i = 0; i < 5000; i++) {
using (TextWriter w = File.CreateText("C:\\tmp\\test\\log" + i + ".txt")) {
string msg = DateTime.Now + ", " + i;
w.WriteLine(msg);
Console.Out.WriteLine(msg);
}
}
Console.In.ReadLine();
}
}

Monday, February 11, 2008

Solazyme Is Making Biodiesel from Algae

Solarzyme is producing biodiesel now from algae. The technology is very intriguing since the final product is something similar to oil, so it can be refined, transported, and consumed by our existing infrastructure.



Solazyme Produces Biofuel from Algae

Chevron has taken a stake in the company causing fears among the conspiracy theorists that big oil would quietly shelve to process to protect Chevron's oil interest. But Big Oil (tm) is in big trouble now. Most of the oil deposits are now out of reach of big oil companies and in the hands of state sponsored oil companies. Big oil should welcome processes like Solazyme's that will them to produce and deliver oil independent of foreign government's whims.

Another video clip here.

Monday, February 04, 2008

Skip the Biomass - Go Straight Hydrogen

In photosynthesis, plants take sunlight, wrestle hydrogen from h20 and make ATP, their power source. When we create alcohol or other synthetic fuels from plants we are really harvesting the energy from sunlight that freed the hydrogen from inside the plants. To make alcohol from corn we have to plow the fields, lay down fertilizer and insecticides, plant the seed, and harvest the corn - all of which takes a lot of energy and emits carbon.
What if we could just skip the plant and get the energy straight from the sun?
That's what Nanoptek is doing.

Nanoptek has a special catalyst to free hydrogen from water in the presence of sunlight.
Why use this process instead of photovoltaics? One of the advantages is the ability to store the energy for use later. A farm of Nanoptek's harvesters could create hydrogen all day and store it for burning in turbines at night or peak demand. This gives great flexibility to the power-grid. The hydrogen gas could through serious chemistry be used to create liquid fuels similar to diesel.
What remains to be seen is whether the economics will work, but their recent announce is exciting to see.

Abandoned by Intellisense

This morning I was already to get to work on a fun programming project in Visual Studio 2005, but I had lost intellisense which is very annoying. I toggled between ReSharper's version and Microsoft's. I quit VS2005 and reopened. I checked in the recalcitrant file, checked it back out. Nothing.
Finally I closed all open windows, quit VS again, and Intellisense returned.
Which reminds me of a haiku,

Yesterday it worked.
Today it is not working.
Windows is like that.