May 31, 2008

Enterprise Library 4.0

So it is here: Microsoft Enterprise Library 4.0.
Most important for this version is that it works only with .NET 3.5.
At my work we currently use Enterprise Library 2.0 but it lacks Validation and Policy Injection blocks. Those blocks are present in the 3.1 version that, for instance, works on both .NET 2.0 and 3.0.

For 4 or 5 days ago I downloaded this latest version to my workstation in order to test it and make a complete evaluation. Although we are not moving to .NET 3.5 it is important to follow Micorsoft's steps.

Compared to its predecessor, this version as some performance improvements, bug fixes, instrumentation support and VS 2008 support.

May 26, 2008

El baile del chiki-chiki

Con ésta humorística contribución un poco refinada España se presentó el pasado sábado en el Eurovisión 2008.



La canción original la tenemos aquí:



...mas Chiki-Chiki News:

May 25, 2008

Hallazgo

En marzo pasado un grupo de pescadores de la localidad de Trinidad, al sur de la antigua provincia de Las Villas, sacó a la superficie una serie de objetos entre los que se incluyen balas de cañón, lastres de hierro, baquetas entre otros.
La edad de dichos objetos "corresponde al período comprendido entre el inicio de la colonización en América y principios del siglo XIX" según el arqueólogo cubano Leonel Delgado citado por el diario oficialista Juventud Rebelde.

Este singular hallazgo me deja más preguntas que respuestas. En la plataforma insular de Cuba encuentran un barco de casi cinco siglos de antigüedad. Pero ¿qué pasa con el avión de Camilo que no aparece?

Hemos de apresurarnos a preguntarle a Raúl Castro antes de que envejezca demasiado y la demencia le impida recordar lo que en realidad le ocurrió al comandante de la sonrisa ancha y el sombrero alón. Yo no creo en casualidades y mientras no se demuestre lo contrario continuaré con mi idea de que Camilo fue accidentalmente herido de muerte (menor probable) o asesinado súbita o premeditadamente de mano o por orden de los hermanos Castro (la más probable).

May 3, 2008

.NET or .NJET?

Most of programmers that began their career on the .NET framework have never asked themselves how the programs interact with the OS or computer through the framework.

Before I went over to .NET, I spended many hours trying to understand what makes the generated code so slow compared to other high level programming languages such as C/C++ or Delphi. I wrote several programs to compare native performance against .NET (C#) and discovered that, for relatively simple operations on integer and floating point types, native languages was over 300% faster than their .NET equivalent ones. The framework itself and the architecture behind is the cause of this. Every time you define a variable in a C program or a member in a C++ or Delphi class, the compiler allocates just as much memory as it needs to hold the variable value: 4 bytes for a 32-bit integer or pointer, 8 bytes for a 64-bit double floating point variable and so on.

While the Marshal.SizeOf method still tells us the truth about the size of an integer or a double type since the method gives the object's unmanaged size, there is a back side of this "truth". Once you've defined a member or variable of any type in .NET, the compiler must also allocate managed resources for, at least, the System.Object members. This means that you can invoke any of those members, for instance, int.ToString(). Easy and elegant but it has a price in form of a performance penalty.
Working on strings is not the best side of the .NET framework. Any time you copy or concatenate a string, the string class allocates a new string object that will be returned by the member in question. As the Copy method reveals, the returned string is allocated by the FastAllocateString call.

public static unsafe string Copy(string str)
{
if (str == null)
{
throw new ArgumentNullException("str");
}
int length = str.Length;
string str2 = FastAllocateString(length);
fixed (char* chRef = &str2.m_firstChar)
{
fixed (char* chRef2 = &str.m_firstChar)
{
wstrcpyPtrAligned(chRef, chRef2, length);
}
}
return str2;
}

In contrast, the C runtime library works on memory areas which is much faster but the programmer is responsible of keeping buffer sizes and boundaries.

It is well known that for large strings, the StringBuilder class, performs much better than the string class does. But this will not be covered here.

But, back to the question: Dot NET or dot Njet? For me the answer is definitly .NET as long as there are no high performance requirements. I suspect there is no programmer out there that would even consider writing a graphic-intensive game or a device driver in C#. For those purposes the Microsoft Visual Studio still gives you the C/C++ option and you have all combined in one development tool. If there comes a day when I must develop a time or resource critical application, I will dust off my C/C++ skills.