Sitecore potentially on Mono

Came across the Mono Project page today. Its wonderful to see all those volunteers working extremely hard on implementing the whole BCL and all other projects in Mono. ASP.NET 2.0 is almost implemented. They’ve decided not to implement precompiled websites and the WebParts API. For compatibility testing, they’ve release MoMA(Mono Migration Analyzer).

I’ve been running 5.3.2’s Sitecore.Kernel, Sitecore.Client and Sitecore.Nexus against mono 1.2.6. The results are surprising:

Sitecore.Client:

  • 1 Method is missing in Mono
  • 1 Method is marked with a MonoTodo

Sitecore.Kernel:

  • 20 P/Invokes into native code
  • 9 Methods are missing in Mono
  • 15 Methods are marked with a MonoTodo

Sitecore.Nexus:

  • No issues found

So it becomes time to get rid of the last P/Invokes for comparing, timers and process data. Then Sitecore will run without any problems on Mono(potentially, haven’t tested tough). So let’s get this on the roadmap folks!

It would be very cool for all the Sitecore XPress chaps around who love to host on *n?x-variants.

Alex is moving…

Yes I’m. I’m actually finishing my last days at the great company LECTRIC. I’ve had a fantastic time with lots of really cool colleagues. I’ve learned a lot. Starting as a 17 year script kiddie. Look me now, nearly 4 years later, in age, the wisdom I’ve collected is hardly to describe in years. I’m pretty happy to ‘announce’: I’ll join Sitecore from the start of March.

Details on where you can find me and what you’ve to do to get me on the phone will follow. I’ve got a lot of ideas for the product and I’m sure I’ll have a lot of influence in future product development. I will also continue to spread the word. Blog about Sitecore, Content Management, development and .NET. And you’ll likely see me joining Lars(or Lars joining me) in the .NET/CM community as a speaker.

For now, thank you: Alex, Anton, Bart, Ben, Bert, Erwin, Esther, Frans, Hans, Hanny, Jan, Jan-Hein, Jan-Pieter, Jeroen, Karen, Kevin, Lydia, Martijn, Mark, Marcel, Max, Michiel, Niels, Okke, Paul, Paul, Rob, Robin, Ruud, Ruud, Sander, Sjoerd, Sjoerd and Vincent. And all the colleagues I’ve seen coming and going away and those who are still in the company but I forget to mention. I’ve learned so much and the last year the support I received when I was in Zaltbommel.

Some friendly words to all of you:
Thank you Coby for the lunches :). Bert for the smalltalk every friday evening. Marion for being the voice when I call. And Lydia for sending the overview of my vacation days left, over and over. Bert(2) for giving me the chance to join LECTRIC. Jan-Hein for the wise words last Christmas. Sjoerd for being ‘a little’ chaotic. Paul for showing me how you survive a weekend in Berlin and calling his son after me. Marcel for explaining me how to snowboard. Martijn for ‘developing’ a Sitecore baby. Ben for calling his wife ;). Rob for the ongoing discussions. Erwin for his critical but friendly voice. Karen for being always right(she is!). Hans for education, being my driver and for trying to convince me that Java ‘superclasses’ C#. Sjoerd(2) for dissing my music. JP for all the deployment stuff. Vincent for being our BOFH. Ruud for teaching me how to write code, sing, eat, smoke and drink coke at the same time. Paul(2) for always having the opposite vision on design. Alex for the words of 2008. Niels for the useless movies on Hyves. Okke for the weekly car and football update. Frans for being the oldest, while I was his youngest ‘son’. Robin for the evening in ‘White Trash’, Berlin. Michiel for unlimited enthusiasm. Bart of saying Smartsite is always better and does have a better concept. Kevin for being quite. Jeroen for trusting me and the conversations about what does care in life. Esther for having patience when I was in a rush again. Anton for selling me and a big box of air, over and over. Mark for trusting me as a teacher. Jan for listening to all my theories. Hanny for being my LECTRIC-mother. Max for being my buddy the last 9 months. And all those I forget… Sorry. This definitely was just a abstract of what the LECTRIC family is and stands for.

Now I just want to say: Cheers! Let’s have a beer.

Displayname (2)

Dear Derek Roberti,

First of all I’m glad to see you blogging. And you spend a lot of time on good post. This time I just want to add a note which should be common knowledge for all Sitecore Developer. Alex Shyba wrote a comment, but I would expand this a little.

The DisplayName of a Sitecore item is actually the friendly title which should be known by all users, developers and administrators. The DisplayName is just the friendly name(as you describe in your post). When you want to generate an path by yourself, you even got the option to use Item.Paths.GetPath(Item item, string seperator, ItemPathType.DisplayName).

Also, in nearly all cases you should use Item.DisplayName rather then Item.Name. Actually, the DisplayName-property is implemented in this way:

        public string DisplayName
        {
            get
            {
                string str = base[FieldIDs.DisplayName];
                if (str.Length > 0)
                {
                    return str;
                }
                return Name;
            }
        }

This means there’s a fallback scenario for the DisplayName.
Next to it, users can decide in there Content Editor settings wether they want to see the DisplayName in the tree or just the item-Name.

In different solution I often see developer create Title-fields. I would strongly suggest to use the DisplayName for those cases. As it will adjust to the Sitecore thoughts.
It might be good to spend some time at a customer and look how we are able to make sure the DisplayName-button can be recognized and found in a more usable way. I guess a lot of people just look over it.

A nice hint for the experienced Sitecore users. You can always quickly rename the item by hitting F2. The DisplayName doesn’t have a shortcut. You could set this up by changing /sitecore/system/ribbons/chunks/rename/displayname. Set the KeyCode to 114(rather change it to F6, 117 as F3 is reserved for searching) for F3. Other keys could be resolved using the KeyboardMap application in Sitecore.

Thank you again for your clear post. Hopefully you think this post is a nice addition :).

– Alex

Beauty and most annoying things about Silverlight

Let me be clear, I like Silverlight. I like the idea of using XML for data-driven web interaction. I also like it to see the CLR run in such a small package. You might even want to call it Micro Language Runtime. Its extremely fast as well. Unbelievable how quick movies load. I don’t need HTML 5 for media components, just give me Silverlight :).

Can you also imagine what proper written Silverlight can mean for screenreaders? It can actually make interaction readable for that kind of applications. Cool!

Well there’s also another side of Silverlight. For example, I couldn’t use Silverlight for a long time. Why? The 1.1 alpha wasn’t compatible with Silverlight 1.0. So it bugged me over and over to install Silverlight and when I listened, the system told me it couldn’t because a new version was installed.

I didn’t want to uninstall 1.1 neither as it could harm my instable VS2008. Well just another 2 weeks using this crappy Windows version(it bugged me last week extremely). Then it becomes time to clear all of it and dump the machine(like every 2 months…).

Last note for the Sitecore junkies out there, compare the following three option you’ve got when you become a XAML-addict:

  • XAML to Windows -> WPF
  • XAML to Interaction -> WPF/E -> Silverlight
  • XAML to Html -> Sitecore

How cool technology can be. It can even make people cry ;).

Benchmarking, HighResTimer and string concatenation

Got challenged yesterday by a community member. This experienced guy had the following statement:

Just give every object which handles strings a StringBuilder. The overhead is minimal and the performance is maximum.

I do not believe this at all. And although it might be a very micro optimization, it found it worth to try.
For quick output, I’ve used the very handy HighResTimer written by Sitecore(you can find it in Sitecore.Diagnostics). It just returns the ticks which are calculated by the Performance Counters in Windows. So it should give a true answer. I’ve written a small handy wrapper to use it:

    public class Timer : IDisposable
    {
        private static readonly HighResTimer hrt;
        static Timer()
        {
            hrt = new HighResTimer(false);
        }
        public Timer()
        {
            hrt.Start();
        }

        public void Dispose()
        {
            Console.WriteLine(hrt.GetElapsed());
        }
    }

Then it became time to get my test class ready(a console app):

        private const int cycles = 10000000;
        static void Tel(Method m, params string[] input)
        {
            using (new Timer())
            {
                m.Invoke(input);
            }
        }

And write 3 tests:

        static void Concat1(params string[] input)
        {
            var arr = new string[cycles];
            for(int i = 0; i < cycles; i++)
            {
                arr[i] = string.Concat(input);
            }
        }
        static void Concat2(params string[] input)
        {
            var arr = new string[cycles];
            for (int i = 0; i < cycles; i++)
            {
                var sb = new StringBuilder();
                foreach (string s in input)
                {
                    sb.Append(s);
                }
                arr[i] = sb.ToString();
            }
        }
        static void Concat3(params string[] input)
        {
            var arr = new string[cycles];
            for (int i = 0; i < cycles; i++)
            {
                string e = string.Empty;
                foreach (string s in input)
                {
                    e += s;
                }
                arr[i] = e;
            }
        }

So far no fancy stuff. You can doubt about the foreach-loop. But internally string.Concat does the same(it even uses a for-loop following Reflector). And least efficient one, Concat3, should have the biggest disadvantage.
As I know for sure, the StringBuilder is the best one when you’re going to concat more then 10 strings, take a look at these links for examples.
So my test we’re had a maximum reach of 6:

        static void Main()
        {
            string input1 = "aaa";

            Tel(Concat1, input1, input1);
            Tel(Concat2, input1, input1);
            Tel(Concat3, input1, input1);
            Console.WriteLine();

            string input2 = "aaaa";

            Tel(Concat1, input1, input2);
            Tel(Concat2, input1, input2);
            Tel(Concat3, input1, input2);
            Console.WriteLine();

            Tel(Concat1, input2, input2);
            Tel(Concat2, input2, input2);
            Tel(Concat3, input2, input2);
            Console.WriteLine();

            string input3 = "aaaaa";

            Tel(Concat1, input1, input3);
            Tel(Concat2, input1, input3);
            Tel(Concat3, input1, input3);
            Console.WriteLine();

            Tel(Concat1, input2, input3);
            Tel(Concat2, input2, input3);
            Tel(Concat3, input2, input3);
            Console.WriteLine();

            Tel(Concat1, input1, input2, input3);
            Tel(Concat2, input1, input2, input3);
            Tel(Concat3, input1, input2, input3);
            Console.WriteLine();

            Tel(Concat1, input1, input2, input3, input1, input2, input3);
            Tel(Concat2, input1, input2, input3, input1, input2, input3);
            Tel(Concat3, input1, input2, input3, input1, input2, input3);
            Console.WriteLine();
        }

Here are the results:

7374,3959078598
8739,34284944036
2674,68798408736

7556,49502939619
8253,90880684556
3885,96399821765

7379,0495719428
8699,20227291457
2812,4434809452

7774,4316665945
8487,17392853002
2751,89723833616

7969,81627553223
10075,2866635285
3680,81418169069

8520,05939302342
8696,66926941832
7840,39032893845

11077,971082917
19650,061390484
13404,9534228512

Till 4 strings the +-operator is definitely the winner. Above string.Concat goes for gold. But in ALL cases, the StringBuilder was the slowest. So for all you guys, when it comes to concatenation and it are just a couple of strings. Just use string.Concat or the the +-operator. The StringBuilder ruins your code(you’ve to write more code) and it isn’t more efficient!

Guess you may consider me a geek ;). Happy coding :).

For the people who are interested. You can find the class here. Just reference the Sitecore.Kernel for the HighResTimer.

C# 3.0: Extension Methods + Resharper 4: EAP

With the public release of Visual Studio 2008 this month, .NET 3.5 and particular C# 3.0 is released to the broad public. This does mean that the new functionality will be exposed a lot. And I guess Extension Methods will be the most used functionality.
I’m actually not 100% happy with this language extension. Of course we all do know its tried over and over by many beta testers and language fanatics. It does allow you a lot of flexibility. But hey, what about class coupling?

Lately I’ve been involved in many research and study projects which used the highest standards on architecture and code guidelines. This meant that all models where heavily tested by many metrics. We’ve been trough all kind of metrics and later on, while developing again. I found out that Extension Methods can become very dangerous. With a namespace such as System.Linq, you have totally no notion about class coupling. And later on, when you’re going to write some Extension Methods by yourself, you totally forget about the complexibility you’re introducing on top of objects.

For all you guys who are considering using this option heavily, make sure you know what you do. You’re creating lots of cross concerns over your code. And it does not always make your code better. Or at least the metrics say it doesn’t. And I do know that metrics aren’t laws, but they do say something.
A last suggestion: keep on using util-classes rather then extension methods, they are still very usable and they do make sure you’re backwards compatible. At least your interfaces are.

For those who want to work with the latest bits available, take a look at the Early Acces Program of Resharper 4. Their program manager announced it last week. But make sure you read these notes.

So what’s the Nexus?

It’s been a while since I’ve been actively blogging about some core parts of Sitecore. As the guys in Copenhagen are working really hard on a release called ‘Crestone’, It becomes time again to get you guys 100% up-to-date.

Well back to the current release. Take the last build: 5.3.2 rev. 071220. It does contain a new library: Sitecore.Nexus.dll.

So what’s a Nexus? It’s a part of the Next-Generation Secure Computing Base initiated by MSR. The nexus particular is the security part. Here’s the wikipedia quote:

In NGSCB, there are two software components, the Nexus, a security kernel that is part of the Operating System, and Nexus Computing Agents (NCAs), trusted modules within NGSCB-enabled applications.

So what’s the Nexus in Sitecore? It ain’t that hard at all. It’s the part which manages all the heavily secured stuff such as licensing. It also takes care of the basic data-actions(add, copy, create, etc), the Sitecore HttpHandler and has some advanced XML-utils.
It’s heavily obfuscated as you would expect from a part which handles the secured stuff in a system.

That brings us immediately to the Sitecore.kernel. There is no need anymore to have this thing so heavily obfuscated as it was in the past. Sitecore.nexus is obfuscated twice as heavy as the Sitecore.kernel was, and the kernel lost (all of its?) obfuscation. This doesn’t mean you can reverse engineer the whole product, this the nexus is heavily obfuscated. But it allows you to use tools such as Reflector to get a way better understanding of the product.

A nice things with 5.3.2 is by the way that the Nexus handles the start up way more efficiently. In other words, it does mean you don’t have to be that patient again on the first run after a build of your assemblies.

Before all you guys are going to download the latest build and use it in your latest projects, make sure you’re aware of the fact that 5.3.2 is still not yet the recommended release!

Note: ‘Crestone’ is the codename of the next release. Its announced a while ago to all partners on their network. Make sure you’ll read the roadmap over there.

I’m a happy coder: Sharepoint vs Sitecore

Today I came across these two blogpost by some Microsoft chaps. They are generally about memory leaks in Sharepoint. The usage of disposable objects, etc.

It seems like Microsoft has a lot of object which needs to be disposed over and over?! Yes we’re talking about a tool written in a managed language! And ofcourse, the reason may be clear:

Internally, SPSite and SPWeb both hold references to an “internal class Microsoft.SharePoint.Library.SPRequest” which holds on to unmanaged COM resources.

But please, we’re living in 2008! When such an important part of your application depends on an unmanaged resource, you do have a big issue. And I would highly recommend Microsoft to get rid of this.
Sitecore uses the IDisposable pattern a lot as well. But this will introduce nice features such the change of security context or to do some timing.

I hate to bash against other systems as all of them are useful in some way. But as a code I generally like those concerns. I prefer managed code above a system language such as C++ primarily because of Garbage Collection and I don’t want that objective taken away.
Just needed to share this with the community. Look how happy we should be :).

Sitecore Xpress

While Lars is presenting it using a WebMeeting tool, I’m downloading Xpress… And all of you should!
Xpress is only in licensing what you call Sitecore Light. So you don’t have more then 1 concurrent editor, its just for your personal sites and you are allowed to run it on just 1 machine.

But that won’t be a reason to walk away from it! So grap your copy and lets get started!

Thinkquest: Jury member

Like last year, I’m again a jury member for the dutch version of ThinkQuest. Thinkquest is a competition for youngsters who create together with coaches(school teacher, parents, etc) educational websites. Here’s a short description from the international ThinkQuest website:

ThinkQuest inspires students to think, connect, create, and share. Students work in teams to build innovative and educational websites to share with the world. Along the way, they learn research, writing, teamwork, and technology skills and compete for exciting prizes.

My point of interest will be the technical aspect of the websites. I’m participating in ThinkQuest Junior(Dutch link), the competition for primary schools.

Don’t think this is a competition for softies. When you take a look at last years winners website, you’ll see definitelly some extremely good content and some rich internet aspects.
I hardly couldn’t believe someone at the age of 10 to 12 is able to make such as thing!