Friday, 5 September 2008

Before we rewrite all those ASP Classic sites as .NET

What Language Should I use?

Although .NET is the way a large percentage of websites are going I still find a lot of them surprisingly slow. As a developer you are always wanting to work with the newest technologies getting to spend time learning new languages to boost your CV and work with whatever is cutting edge at the time just for the fun of it. However most of all developers work for someone and a lot of the time the customer your sales team sell to doesn't care if the site they are paying for is written in PHP, ASP.NET or ASP Classic as long as it works, is fast and doesn't break every time more than 10 people visit it at the same time.


The Quickest .NET Site Development in History

My boss used to joke that we should upgrade one of our biggest sites from classic ASP to .NET but rather than rewriting it all we should just change all the file extensions from .asp to .aspx. We used to laugh about this thinking it would be a good way to get a .NET site up quickly that was faster than our competitors with no development costs. However it was only a pie in the sky joke until recently when we actually sold a version of this software to a foreign company who wanted control of the source code.

A few months later when one of their management team spoke to my boss he proudly informed him that they had indeed rewritten the whole system in .NET and paid a lot of money for doing so. My boss informed him that if they had done so that quickly we would like a copy ourselves as it would save us some time re-developing the system having taken 2+ years to get to the stage we were currently at when we sold it.

We all eagerly gathered round the nearest PC and entered the URL to examine this marvel of technology that had only taken 2 months for a complete rewrite. Imagine our surprise when we were met with the exact same site not just the look and feel but the exact same site structure, page layout, CSS styling, client side JavaScript and so on. The only difference we could find was a new sub directory that used the companies name before our existing site structure and all the pages were now renamed .aspx.

We got some of our .NET developers down to view the source code and found nothing that indicated it had been generated by .NET cod and in fact it looked exactly like the classic ASP source code including some secret debug code generated by ASP that I had outputted in specific places hidden in HTML comments. Nothing had changed apart from the extensions!

We reckoned that maybe the Indian team that had been given the contract for the rewrite had taken one look at how much code there was and how complicated it would be to even understand without any training let alone rewrite that they took the decision my boss had batted around as a joke.

Of course we no longer had access to their servers so we couldn't confirm 100% that it had been a file extension change and nothing else. Maybe they had in fact re-written the whole system in .NET and reproduced every single feature that was already there in the exact same way as before including all my debug statements and client side JS code that was generated by the system. If that was the case then what was the benefit to the client? They had just forked out a huge bill for a rewrite with no visible benefit. Another indicator that the site hadn't been rewritten was that it was still as fast as it was previously so I would give pretty good odds that the Indian outfit that had the contract made a very easy £20k or so.

My point being is if you have a system that is performing well and is earning your company £££ with constant sales then does the language its written it actually make much of a difference to the sale of that product. Wouldn't the speed, reliability and development time required to get it up and running be more important in the customers mind or is that .asp extension just considered too old and unfashionable nowadays in the small percentage of customers minds who even know the difference between .asp .aspx ?

And if you do have a customer that gets all panicky about those .asp extensions you can always use ISAPI URL rewriting to remove any mention of .asp or .aspx. Remember a fast well performing site is just that and the customer is probably not as bothered as you whether its been developed in classic ASP, .NET 3, PHP, Java or the next 3 lettered acronym language that comes along.

As a developer you may want to rewrite existing sites each time a new sexy technology comes out but unless there are desirable benefits to the company that pays your wages in doing this then its not going to happen. If you work for a small company then the time and money lost by taking a developer away from new work to rewrite an existing system is not going to be cost effective.

However saying that you might have a good case in convincing your boss to put that effort in a rewrite and there will always be tech savy customers out there who pay money over fist for the latest code base just like uber rich fashionistas that only wear the same clothes once. However before you do upgrade your classic ASP system try and see if you get it to perform as fast as it possibly can first. There's a high chance that a lot of classic ASP systems have a lot of bad code contained within them that could be tweaked to improve performance with a little work.

I work on a number of large high volume traffic sites that are still using classic ASP and have spent considerable time trying to get the best performance out of them as possible as a rewrite in .NET is going to take some considerable time and effort. If I have a poorly performing site then the steps I would go through on the way to a redevelopment are these:

1. Improve the ASP application code as much as possible. See top 10 tips for improving ASP sites.

2. Make sure the database is performing as well as possible and returning data to the application as quick as it can. View my top tips for increasing SQL performance article.

3. Make sure your hardware and software is configured correctly and that you don't have problems with the servers setup.

4. Consider moving to a 64 bit server and put more RAM in. See tips for moving from 32 to 64 bit server.

5. If all the previous have failed and you still do not have a scalable site that can take large amounts of traffic then consider a rewrite in .NET.

However there maybe some fundamental issue in the applications design or site structure that is causing problems. If so then a redesign is required anyway. Creating and maintaining scalable high volume sites in ASP classic is possible but requires some skill and knowledge. You need to weigh up the cost to the company in time and money that a total redesign and redevelopment would take opposed to any gains made by performance tuning and adding extra hardware.

4 comments:

Marcelo said...

I agree. If you have a tool that still does the job, why change?

My personal opinion is that asp.net is too bloated for small/medium sites. I think its more suitable for large companies and huge applications.

Classic ASP does the job and has its advantages. And using cool libraries such as Ajaxed - ajaxed.org, URL rewrite (as you said) and cool javascript frameworks and snippets, one can build killer apps.

It's a pitty Microsoft abandoned classic ASP. It could have evolved and be something like Rails today.

R Reid said...

Yes I think its a shame especially seeing that PHP is all the craze lately and that's still a scripting language.

Also using JavaScript as the server-side language in Classic instead of VBScript offers a whole extra level of functionality. Its a shame VBScript became the mandatory server side language instead. See this blog: http://blog.strictly-software.com/2009/08/php-and-demise-of-asp-classic.html

Whenever I want to get a page up running quickly I will still consider ASP classic just because its so easy for me to code and get working.

However I will also say this having worked with .NET, C# etc that getting a feature rich UI that is fast and scalable using ASP classic/Ajax/Jscript is a much harder task than using .NET and just dropping a few grids or controls onto the page.

If I had to pick between someone who could create such a system in Classic and one who could only do it in .NET I would say the classic person has the edge just because of the skills you would have to know to do it from scratch and to do it well. Obviously .NET is OO but that often makes things a lot easier.

Personal preference is everything though! Thanks for your comment.

Anonymous said...

dude it's been time to move off of asp for 10 years. .NET slow? that just means whoever is coding is sucks...it's not the framework.

R Reid said...

You are reading an article over 3 years old and .NET has improved a lot since then. Just so you know I do write all my "own" code in .NET 4 or PHP nowadays (depending on what it is).

However unfortunately I have to maintain a huge system that has been written in ASP Classic. I would love to rewrite it in .NET but we don't have the time.

Actually ASP classic developers can obtain quite large salaries in the UK market due to the fact that many companies don't like hiring .NET programmers due to their limited knowledge of coding.

We have had more than a few come and work here and dragging and dropping seemed to be their only skill.

Many had little or no idea about OO or proper coding and the point of the article was to say that if you have a large system in ASP classic for the cost of rewriting in .NET you could probably get just as good performance out of it compared to .NET by tuning it up. We have.

The second point was about the choice of VBScript as the server side language instead of JScript which is much more flexible.

However if I had to start a program now I would not chose ASP classic as the code to write in.

Thanks for commenting