ASP.NET and Alternative Server-Side Technologies
There are many server-side technologies available for a programmer to use. Current, popular languages are PERL, JSP, ASP and PHP. ASP.NET is the latest language from Microsoft, and in this article, will be compared to the language most commonly used at the moment – PHP (PHP Hypertext Processor).
What is ASP.NET?
This is Microsoft’s latest programming language for web-based applications following on from ASP. Microsoft have completely re-written the software, therefore they are NOT backward compatible. ASP is actually more similar to PHP that to ASP.NET! Microsoft wouldn’t have done this without good reason. One of the main, most obvious benefits is that you can choose from a large range of programming languages such as VB, C, C# etc (compiled languages) and others such as VBScript, JavaScript etc (scripted languages).This then opens up web development to a much larger range of people – those already trained in other languages without the need for complex training courses. The language you pick is compiled into Microsoft Intermediate Language code and then the Common Language Runtime (CLR) executes this code.
With ASP.NET, Microsoft have provided programmers with a true Object Oriented Programming (OOP) system to work with. This includes true inheritance, polymorphism and encapsulation. A concern with all server-side technologies is database connections. This is achieved through ODBC, allowing connection to all sorts of databases for example Microsoft Access, MsSQL and many more.
The programming environment most commonly used is the Microsoft Visual Web Developer Express (http://msdn.microsoft.com/vstudio/express/vwd/) being free. Unfortunately, there is not too much selection, so if the Microsoft development environment does not suit, there are few options for others.
What is PHP?
PHP is an open source programming language based on processing HTML pages with inserts of PHP code and then sending HTML pages to the web client. PHP has been around for a long time, and is now at PHP 5. PHP allows for development in an Oriented Programming (OOP) manor, but is not a true OOP language. There are many syntactical similarities with languages such as PERL, C, Java etc and has many features of imperative programming languages.
Database connection, again is an issue, PHP being a server side language. This can be achieved through either ODBC as with ASP.NET, or through native drivers for MySQL, Oracle and Postgres. There is also an extended library if you want to connect to an Oracle database.
There is no one programming environment for PHP. You may use anything from Notepad through to Adobe Dreamweaver. There are so many available to a programmer, so there will always be an environment to suit.
PHP4 – PHP5
PHP version 5 has been recently released with many differences and improvements from version 4. The most noticeable area of advancement in the transition from PHP4 to PHP5 is the introduction of a proper Object Oriented programming model, bringing true OOP to PHP, rather than the “bodged” methods of PHP4. One of the main issues with OOP in PHP4 was that if an object was passed through to a function (or a method) the whole object would be passed across resulting in a larger amount of memory being used, clunky programs and so on. PHP 5 just passes the reference to the object through to the function or method. Constructors and destructors are now available for use in
PHP5 allowing objects to be created and destroyed with ease and in a clean manor. The latest PHP now allows for private variables and methods of classes, rather than purely public as was in PHP4.
Exception handling (a.k.a. error handling) has been introduced to PHP5 and was another big thing that seemed to be missing from PHP4. Having the exception handling built into PHP allows you to use methods such as throw, catch and try to handle errors. This results in much more robust and clean code, allowing a defined and standardised method of handling errors to be included in the software being written. PHP5 carries out better type-checking (e.g. to ensure a string is not passed when an integer should be) and throws a type-mismatch error if this occurs. This is then caught by the exception handling and shown to the user (or acted upon).
Security Comparisons
The thing that most people worry about with web-based applications is the security of the server software, and their database. PHP runs on the Apache platform, which has an extremely good track record for security.
ASP.NET runs on the Microsoft IIS platform, which (unsurprisingly, being Microsoft) has a poor record regarding security. Hackers seem to “enjoy” taking advantage of this! If you want to use ASP.NET but are concerned with the IIS security issues, it is possible to use Apache between the clients and the IIS server. Apache handles all of the HTML processing, and passes all ASP.NET processing onto the IIS server. This keeps the IIS server hidden from the open internet.
It is also possible (although many web-hosting companies are not supporting it at the moment) to server ASP.NET through Apache by installing a module called Mono (http://www.mono-project.com/) allowing this (Go Open Source Community!!), although this is not supported by Microsoft.
Comparison Table
Below is a comparison table between PHP and ASP.NET. A tick is in the box of the winner of each comparison.
|
PHP (version 5) |
ASP.NET |
Cost of Software |
$0+ (Notepad to Dreamweaver) |
$0 (VWD Express) |
Cost of Platform |
$0 (Apache + PHP module) |
$300+ (Server 2003 w/ 5 CAL) |
Quality of Platform |
√ |
X (if IIS) √ (if Apache as front) |
Security |
√ |
√ |
Efficiency |
√ |
X |
Speed |
√ |
√ (although held back by efficiency) |
Compiled Code (therefore decreased code running time) |
X (although can use an accelerator, but this caches, not compiles) |
√ |
Viewable Source Code |
√ |
X |
Exception (a.k.a Error) Handling |
√ |
√ |
Full OOP |
√ |
√ |
Collection of OOP features to use (e.g. login script) |
X |
√ |
Browser Specific HTML Rendering |
√ |
X (without some complex scripting) |
Range of languages supported |
1 - PHP |
25+ |
The environment used to create web based applications in ASP.NET provides an excellent de-bugging environment, which allows the programmer to debug code faster and more efficiently, rather than trawling through each line carefully to find the error. This feature speeds the application development up. PHP however, does not have a development environment as such, therefore debugging can be a much lengthier process, even though when you try to execute a script, it tells you where the error becomes a problem, not where the error is, causing the programmer to re-trace the steps through the code they have just written. That said, there are some applications out there to help PHP programmers find the bugs (or not even let them create the bugs in the first place!).
The cost of starting development for a “newbie” programmer with PHP is $0 – download one program (XAMPP) and away you go! Interestingly, although many people do not realise it (realise or believe – I’m not sure which), the start-up cost for ASP.NET is $0. The program to develop on costs $0 – Visual Web Developer Express(VWDE). Surely the database system would cost? No - $0 – MsSQL Express Edition comes packaged with VWDE. Ok, ok – it MUST be the server-side software for your computer. That must cost loads? Oh, so much - $0 again – VWDE comes packaged with one, or you can use IIS. Is this a new Microsoft? Something Free? Because it does not sound right? Ah – the catch. It is a marketing tool to persuade new web developers into using their new language, because it costs nothing, has many wonderful features no other language has. Where they make their money, is that you are required to run ASP.NET on a Windows Server based system (this is not cheap, starting at roughly $300). The “newbie” does not recognise this, until they come to upload their work, to make it public and find that it costs so much more. I mean, on average Windows Server hosting has got to be at least 30% more expensive than Linux based systems. This is the main issue with ASP.NET, although, Mono have released a server-side product to run ASP.NET on a Linux environment, but inevitably, there will probably be bugs and errors with it.
PHP, especially version 5, with its much smaller code path, is much kinder on memory usage resulting in a faster execution, although the code is not compiled which almost counter-acts this. ASP.NET has a larger code path, but is fully compiled before being run on the server and this seems to be speedy. This would only really be an issue and become noticeable for a website where the number of hits would be huge (many thousands at a time), but this is counteracted by the ability to have a large amount of memory without breaking the bank.
Any questions, please drop me an e-mail (see Mail Me page)
