Archive for the_time('F Y')

NHaml View Engine for ASP.NET MVC
20 December 2007 in Code & Microsoft & Tools | Comments (0)

Andrew Peters (co-founder of Mindscape) has released the NHaml View Engine for ASP.NET MVC. He had been working with Haml on a project and fell in love with how easy it was to use and the quality of the output and decided it was high time something like this was available to .NET Developers.

Andrew has created a rather lengthy blog post about the engine as well as how to write in Haml, Check out the NHaml View Engine here.

If you are using ASP.NET MVC and are a lover of fine XHTML output then you should check this out.

– JD

IE 8 & Standards compliant
20 December 2007 in Microsoft | Comments (0)

I’ve been looking to find more information about IE8 lately however it looks like JB got the scoop (damn Regional Directors and their underground connections! :) and has posted specifically about standards compliance in IE8 – certainly the most important area of enhancement in my opinion.

Click here to read Jeremy’s post about IE8.

I also question the inclusion of a new header tag to force compliance mode. Even if this is just a meta tag addition I can already hear the outcry’s about splintering standards. Admittedly Microsoft often find themselves in “damned if they do, damned if they don’t” type situation and overall it’s fantastic to hear that there will be ACID2 support – lets just hope that they manage the whole tag required challenge well.

Bring on the beta’s!

– JD

iPause 2.0
19 December 2007 in Apple | Comments (0)

A long time ago Phil Cockfield blogged about how the iPod would pause your music when you removed the headphones from the socket. The general theory was that many people did this to pause the iPod when you suddenly had to pay attention to something and didn’t have the time to fumble around looking for the pause button. It was one of those cool little features that Apple packs into their devices.

Zooming up to modern day, I recently acquired an iPhone and was complaining to Lena about how I have to take it out of my pocket to pause music. You can’t even fumble around and click a button through your pocket like you could with an iPod, you had to remove the cable to pause the phone quickly if you wanted to.

A few days later and I was looking at the mic on the iPhone headphones and noticed it seemed like it would break easily. It had a distinctive “click” feel when I pressed it together and that got me wondering as to why Apple would make something so crappy that it would feel broken right out of the box. However something interesting happened – when I clicked it, the music paused. When I clicked again it played. When I double clicked it the track skipped to the next one. Colour me impressed – listening to music on the iPhone became a much more enjoyable experience once I realised this small feature existed!


iPhone Headphones

So why am I telling you this? As a male, I don’t much care for instruction manuals and possibly never would have found this out. Given the demographic of my audience here I suspect you’re likely a male and therefore likely also not read manuals :) Hopefully this will be helpful to somebody like myself out there.

– JD

Technology doesn’t matter – solving problems does
5 December 2007 in General & Mindscape | Comments (7)

Perhaps a funny thing for a geek to say but hear me out. We, geeks, surround ourselves with many other geeks and we all get our jollies discussing the latest and greatest technology. We have to build this website in Ruby on Rails! This application must be written in .NET 3.5! We must use SQL Server 2008 RC9! We need to change back end to use framework XYZ!

If geeks were to be believed, often you would think they completely couldn’t function without the latest alpha bits of technology xyz.

The thing that geeks often ignore is what is best for the end user. If you’re building a website, for example, and you elect to build it in fancy technology xyz but it delays your delivery by 3 months is that a benefit to the end user? If you elect to build it in technology xyz but, because you had no idea how it really worked beforehand, needed to stop and start all over again in the middle, is that a benefit to the end customer?

Customers just want the work done so that it works, is delivered on time and helps solve the problems it was designed to solve. That is about where their interest ends usually. Your mission to to ensure you meet those goals effectively and in a manner that won’t turn into a maintenance nightmare when it needs to be supported later.

But I am a geek!

I want to stop short of saying that technology platform NEVER matters because, to geeks, it does. And keeping geeks happy, in fact any employee, is important to moving forward efficiently. No geek wants to still be coding in VB 3 (and those that still want to code in Access… well… that’s a seperate blog post!). We do get job satisfaction from playing with cool stuff. If you were a pilot you’d probably love to fly some kick ass new fighter jet rather than than what you currently fly.

There are also additional benefits to developers from new technology – some things do become easier, some things do require less code and perform faster. However the decision to use the latest and greatest needs to be considered carefully – I know many software houses that use the latest stuff only because it is the latest stuff and this about the worst reason to move up.

WTF JD?

Some of you might be asking this question – how can I be saying this when we at Mindscape were pumping out solutions based on LINQ to SQL 9 months before it even RTMs? We all speak about upcoming changes in the new releases of SQL 2008, Windows Server 2008. Heck, Jeremy has even been training folks on how to use Windows Server 2008 a year before it comes out. So what’s the story?

I believe strongly that it is beneficial to play with these technologies before you put them into production. We are geeks, we do grab alpha bits, we do explore but that is so that we can make judgment calls about when it’s appropriate to use in products. What is LightSpeed written in and targeting? .NET 2.0. That’s it. We know a lot of our customers can’t move up to .NET 3.5 right away and, while we could have targeted 3.5, we knew it was better for our customers and therefore better for us to use .NET 2.0.

If code is performing its function correctly and is performing well then you do not have a major reason to upgrade. For example – TradeMe used to be all ASP code and it took them a while to jump on the .NET bandwagon. I’m not sure the specific reasons that dictated it was time to move up but my guess is that it’s a combination of reasons:

  • It was getting harder to find developers wanting to code in ASP
  • ASP code can be a wee bit harder to maintain due to it only providing an inline code experience
  • .NET code could be run faster than the older ASP code (that’s a guess on my behalf)

As I say, these are just a guess from my part. I’m pretty sure it wasn’t from a lot of people posting in the forums saying “ASP sucks – you should use .NET. I’m not going to use TradeMe anymore unless you move up”. Customers don’t care unless the technology starts surfacing in terms of performance slow downs etc which is often more of a design issue that being explicitly because of the technology choice.

What are your thoughts? Have you fallen victim to upgrading for the sake of it? Am I completely off the mark or have I missed something out?

John-Daniel

kick it on DotNetKicks.com

DotNetKicks.com
4 December 2007 in Blogging & General | Comments (1)

On my previous post I placed an image at the end that states “kick it”. For those of you who don’t know what this means, it allows you to effectively “digg” my post and have it appear on a .NET specific site that works in a similar manner to digg.com. I’d recommend joining the site and taking part in the community as some really interesting posts can be found on the dot net kicks site.

Check it out here: www.dotnetkicks.com

Getting kicked helps improve the profile of a post and, hopefully, help drive some new traffic to my site. I’m not asking that you kick every post, but simply making you aware what the icon means and, if you do think a post is useful, you can kick it to show your appreciation.

Note that I haven’t placed one on this post because it’s just an internal memo to you, my reader :)

And that ends this short service announcement.

– JD

Parallel Extensions sample
4 December 2007 in .Net & Code & Tools | Comments (5)

After yesterdays post I thought I should write up a basic sample to test the effectiveness of the Parallel Extensions. Admittedly it is a contrived example and you are unlikely to see this sort of performance increase in a real world since your applications are unlikely to be this primitive.

My sample iterates through a number sequence from 0 upwards and works out if the value is a prime number. There are two implementations, one using a standard loop and the other using a Parallel.For(). Of course, to try and ride out any spikes I iterate the tests 25 times and then average the outcome. This test is of course not run in a clean environment but does give a roughly indicative result of using the Parallel Extensions.

Using a dual core system, checking the numbers up to 100,000 and running 25 iterations of each run I had the following outcome:

Using a normal for() loop: 3104 milliseconds average per run
Using a Parallel.For() loop: 1607 milliseconds average per run

This speed up is acceptable and, as you can imagine, these sorts of results are only going to become more impressive as we move to 8, 16, 32 core systems.

A few things to consider in a real world application (consider this my “don’t blame me if you think this will solve all your problems” line! :) :

  • Often slowness is caused by some slow resource – a web connection, a database call etc. The parallel extensions library will default to spinning up as many threads as there are cores and therefore if you have a slow dependent resource you may wish to investigate bumping up the thread count or writing your own threading code.
  • The architecture of a solution is more likely to impact the overall performance of the application. Improving the speed of a few loops and LINQ queries will not improve performance by any order of magnitude.
  • Amdahl’s Law applies – effectively this law states that the maximum parallel improvement that is possible for an application is limited by the amount of sequential code remaining. For example, if I can only make 10% of the code run in parallel then even with infinitive parallel processes running I’m still running slow sequential code 80% of the time – this feeds back to the previous point.

Download my sample application here (with source)

Note: You will need .Net 3.5 framework installed + the Parallel Extensions Library installed

– JD

kick it on DotNetKicks.com

Parallel Extensions CTP released
3 December 2007 in .Net & Code & Microsoft & Tools | Comments (0)

Just an FYI for anyone that is keeping up parallel computing, Microsoft has released the December CTP of the Parallel Extensions Library.

From my work with it I’ve found it to generally be quite usable however the documentation and general install quality is a little weak at the moment. Even when trying to respond via the email link in the documentation with some suggested documentation changes I found the email was bounced back – not an overly good look but it is early days :)

The extensions provide parallelisation helpers for both general tasks (e.g. making a for loop parallel) as well as providing PLINQ (one quess for what the “P” stands for!). PLINQ, from my reading, applies only to LINQ to Objects but is a useful start. So far my interest has been in the tasks support.

As a simple example of how to make a loop run using all your cores, here is our original code:

foreach(MyClass c in data)
{
  DoHardStuff(c);
}

Here is our code using the Parallel Extensions:

Parallel.ForEach(data, delegate(MyClass c)
{
   DoHardStuff(c);
});

As you can see, the extensions make it easy enough to start getting some elementary parallelism working.

The tide is changing

I haven’t heard developers discussing parallelism all that much yet and that concerns me slightly given the impending dependence on parallelisation that high performance software solutions are going to have in the coming years. I wonder if perhaps this is because Microsoft hasn’t released anything specific about it yet (present post topic excluded) and therefore many in the .NET space simply have ignored the parallelisation issues. Certainly some developers are looking at languages such as Erlang which is designed with parallel development in mind and enables the creation of massively parallel software.

A key thing to remember is that parallisation is not a solved problem. Simply dropping in a Microsoft assembly is not going to mean that your solutions are going to run a lot better all the time, hence my advice that developers everywhere should be sharpening their saw and rediscovering exactly what the long bearded lecturer in their computer science concurrency class was babbling about.

I would urge every developer to, at the very least, do some reading up on threading, concurrency and even perhaps try the Parallel Extensions.

– JD