Oracle published a comparison article between PHP 4/5 and ASP.NET concluding that PHP is better, while there are counter arguments that ASP.NET is better. And here’s a user’s benchmark on the issue.
Oracle published a comparison article between PHP 4/5 and ASP.NET concluding that PHP is better, while there are counter arguments that ASP.NET is better. And here’s a user’s benchmark on the issue.
The user’s benchmark is absolutely pointless. It doesn’t compare like with like so I guess the usual caveat about benchmarks applies here.
That is a seriously worthless benchmark. I would like to bitchslap the person who published that.
Come to think of it, I have yet to see a decent php asp.net benchmark. Anyone have a link?
ps: the oracle article was also plain advertising. It was even worse than the benchmark since there was not a single piece of evidence. That is so much crap its not even funny.
PHP @ 8 Million 4.561
ASP.NET@ 80 Mil 0.218
for 10 times more calculation, ASP.NET is 20 times faster.
so overall ASP.NET is 10×20 = 200 times faster than PHP
am i doing something wrong here ?
wot ?
can some1 run a few ASP Vs. PHP benchmarks and confirm this ?
In a real world case scenario, you’ll never compare the same constant strings again and again and again.. you’ll probably get completely different results using variable strings.
That Oracle article was one of the lamest, most preposterous pieces of cheerleading I’ve seen since Dave Massy said that he was afraid to use non-IE browsers for security reasons.
I mean, c’mon, PHP? Back in 1996, when I was writing CGI apps in Perl, I would’ve turned up my nose at PHP. It’s a horrid little hack of a platform that nobody in their right mind would ever want to use — it’s as if somebody saw ASP (a horrid little hack in its own right) and made a cheap rip-off without even bothering to develop a proper language in which to embed their page-template stuff. At least when Sun ripped off ASP with the original JSP spec, they had the decency to graft it on top of fundamentally sound technologies.
But not only is PHP bad in comparison to other antiquated techniques, it doesn’t even bear comparison with modern development methods. JSP 2.0 with JSTL (and possibly JSF, which I haven’t had a chance to really try) is amazingly better than old, hackish JSP. ASP.NET is incredibly advanced over old, hackish ASP. PHP 5 is… a slightly better lousy hack than it used to be. Um, yay.
I’m wondering what about code optimize while compile process? I mean something like:
if (condition)
{
// do nothing
}
should be optimized somehow? Maybe ASP.NET has better optimiziation, that’s why it’s much faster.
> PHP @ 8 Million 4.561
> ASP.NET@ 80 Mil 0.218
This is not a joke, but is like comparing PHP vs. Java.
Why? Because I of the “ASP (compiled)”. So this person is comparing a compiled language with a interpreted one (?+!!#º?).
Just my two cents,
Edulix.
Hmmm…. you’re either trolling us here or maybe having trouble distinguishing arse from elbow..
I’ve worked with both PHP AND Perl, and i can tell you that php is way better than perl for web dev stuff – because it’s designed for use with the web. Plus it’s syntax is far easier to pick up for most programmers (c-style) – i hate that perl mess which seems to bear no comparison to any other language than it’self.
Snooty programmers such as youself consistently miss the point of PHP – it’s not designed to be ‘beautifully gracefull’ offereing the cleanest OO perfection, it designed to be quick and easy to pick up and use, and to GET THE JOB DONE with a minimum of fuss. In the REAL WORLD most websites are small – meduim size, so using things like JSTL, JSF, Stuts, whatever are simply overkill. For much bigger sites where scalability is an issue, i’d agree that PHP is probably a bit too simplistic, but that doesn’t detract from it’s merrit in all other cases.
You are so right.
There are however issues with both JSP, ASP and what not.
JSP is not for the weak an timid. You need to know quite a lot apart from Java. On the plus side, JSP and it’s likes is a decent solution to a bad problem (i.e. writing applications ontop of HTML & co.).
ASP is just horror. It’s a bad dream come true.
The list of things I loath in ASP is too long to mention.
What where they thinking???
perl is quite useful, it’s actually quite powerfull.
It is however a utter hack. Just try to find one piece of perl code out there (longer than on line) that sports some sort of consistant code base.
The problem, of course, is the syntax hell.
To quote my compiler theory teacher:
FORTRAN had the worst syntax of any language ever in that it was ambigous – of course, at the time, perl was not yet invented.
Now, PHP blows monkey ****s through a straw. It’s a nightmare (just try to use it in a threaded webserver) for many reasons. However – the language itself is extremly simple (wich in itself is a limitation – it’s not suitable for complex tasks). All documentation is in one place. Heaps of people who shouldn’t be let near programming tasks use it wich gives it a huge community – it’s easy to find ‘help’.
It sort of is on the level with Visual Basic – but it’s an improved pile of crap that I rather use (and see other people use) than any of the other technoligies mentioned above.
All of it. Anyone who has ever worked with any of these for more than 5 minutes realizes how dumb this is. PHP is great, and is on the same level as ASP as far as general quickness/ease of use is concerned, but like ASP 1) it is interpreted, and 2) it suffers when code bases grow very large. Not saying it’s not possible to write a large complex site in PHP or ASP, just saying it’s not easy to make it clean and pretty.
ASP.Net should not be considered in the same sentence as PHP, as ASP and PHP are more in line with each other. ASP.Net is more like Servlets + JSP than anything, although they are definitely different in their own respects.
This article is silly. I wonder how it got to be published under Oracle’s name? That’s just sad.
However, in fairness to it, PHP does have a very good function library. Yes it’s not OOP, but that’s hardly a major issue, and it’s thoroughly documented (possibly the best I’ve ever seen). The Asp.net article was a bit too quick to brush it aside.
The OOP side of things is getting a solid makeover in PHP5. It doesn’t take the total-OOP style of languages like C# or Java but it’s good enough for most programming needs. I’ve been using OOP with PHP4, and other than a few minor niggles, there’s been no problems.
You can do templating in PHP.
The real problem with PHP (speaking as someone who just did a pretty major piece of work in it) is that it’s a bit too free-form. It’s very easy to write very messy code with it (e.g. inconsistent session_start()’s, lots of cryptic require_once()’s etc.). As a result you need a lot of discipline.
Which means that PHP is great for small sites, alright for medium sites, and not suited to professional and enterprise sites. Sites written in PHP can be written very fast indeed which is a consideration. And despite the article on ASP.net, the reliance on IIS is a major issue. Let’s not forget that IIS only works on Windows – I’d like to see a comparison of known exploits between Windows and pretty much any other OS out there. Not to mention the cost of upgrading (TCO my ass!)
I uses a compiled version of the asp script, and doesn’t even consider the fact that *any* desent compiler would optimize the [if “hello” != “world”] statement.. not to mention the empty code block that followed.
And then he states “I waited until system usage was 0%”.. That’s *really* scientific.. What if the windows system wanted to do some backup or some other hidden task while one of the test were run.
The published “benchmark” was also kind of pointless. While it’s true compiled languages will be much faster in tight loops than scripted languages in almost any case, you rarely do that kind of thing with normal web applications. In fact, you should avoid it at all costs!
Compiled vs. interpreted is usually only an issue if you have a severely overloaded server and don’t mind the overhead (in terms of development time for a compiled language or VM overhead for things like ASP.Net and Jsp). Overall, it’s probably cheaper to buy a fatter server than to choose something that your developers are not comfortable with.
because asp.net uses…
1 programming languages never designed for web
2 IIS
3 Windows
not enough? try do md5 in C#, try php now
more? try connect C# to postgres
now which is better? I would say python… I mean php
I used the follwing code to see how fast PHP would make random values of a string and after that compare it with a value.
My server 1200mhz/256mb needed +/- 45 secons to do this without Zend. I canot compare this with ASP.NET but i am very curious how fast it will do it. I have to admit its FAST.
I hope the code will stay in tact after submitting it…
<?php
function getmicrotime()
{
list($usec, $sec) = explode(” “, microtime());
return ((float)$usec + (float)$sec);
}
$time_start = getmicrotime();
for ($i=0; $i < 800000; $i++) {
srand((double)microtime()*1000000);
$ran = rand(1,9);
if($ran < 5) {
$world = “hello”;
} else {
$world = “world”;
}
if(“hello” == $world)
{
}
}
$time_end = getmicrotime();
$time = $time_end – $time_start;
echo “Did $i string comparisons in $time seconds
“;
The benchmark also had different code. The PHP code had a function call and also some casts, I imagine that takes more time.
But how often can you choose? I often cannot choose, ASP.NET webhosting is usually more expensive here.
because asp.net uses…
1 programming languages never designed for web
I am not sure what you call “never designed for web”, but I never had any problem whatsoever doing web programming with C# or VB.Net.
2 IIS
3 Windows
Breaking news: Mono reached 1.0
not enough? try do md5 in C#, try php now
MD5 md5 = new MD5CryptoServiceProvider();
byte[] result = md5.ComputeHash(data);
more? try connect C# to postgres
http://www.go-mono.com/postgresql.html
And of course you can use anything with ADO.Net as long as you have an ODBC driver.
now which is better? I would say python… I mean php
I think it’s not such a good idea to compare PHP with .Net because they’re not exactly for the same audience: I’d use PHP for smaller, simpler sites, and ASP.net for bigger sites, especially intranet/enterprise sites.
I agree about your point 2 and 3. Despite the effort from the Mono people, ASP.NET is in reality tied to MS Windows and IIS. This is clearly the major drawback for the ASP.NET platform.
But I don´t understand your compaint about the language not being designed for Web programming. There are plenty of classes supporting functions for the web. In fact, this is one of the stronger sides of ASP.NET. With C# you have a an OO programming language with heavy support for web-dev built into the framework and the class-libraries.
For the MD5 comment – I am currently using MD5 hashing implemented in C# in some of my applications. Its easy… whats the problem?
It should be possible to connect to PostgresSql, but I have no experience with quality of the dataproviders.
These stats are pointless. The fact of the matter is about 67-69% of the webservers run Apache. With either JSP, PHP, CGI, or whatever. ASP.NET is pointless unless it runs on Apache on BSD/Linux/Solaris/HP-UX/AIX. And since Microsoft has no intention to do that, ASP.NET will remain a niche product, only used to create webapplications for certain segments who already rely on windows servers for their web solutions.
Besides, PHP+MySQL/PostGreSQL works fine for thousands of sites, even large corporations rely on it. The benchmarks will always be biased – i dont buy them at all. With proper planning both solutions can run fine. Besides those benchmarks are the most retarded i have ever seen, only one pointless test and even badly executed at that.
>1 programming languages never designed for web
1. I don’t like the languages what are desiged for only one purpose. Let see xBase/Clipper. And in a big project can be different tasks, not only html generation.
2. The PHP web handling is not too lucky thing, at least IMHO. In a bigger (or smaller) projects can be very useful the separation of the code and the design, and the PHP 4 is not support this feature. There are many template generator for PHP like smarty, but IMHO in this case the page generation will slower.
>2 IIS 3 Windows
Go mono …
>Despite the effort from the Mono people, ASP.NET is in reality tied to MS Windows and IIS. This is clearly the major drawback for the ASP.NET platform.
Guess what? ASP.NET only requires the .NET Framework, no IIS required.
The sql integration is very bad in these kind of languages. I don’t understand why PHP is so popular in database driven websites. For example in harescript i could do:
RECORD ARRAY lines =
SELECT CUSTOMER_ID, NAME
FROM DEMO.CUSTOMER;
FOREVERY (RECORD line FROM lines) DO
{
Print(” ” || line.customed_id || ” ” || line.name);
}
which is much more readable than the same in PHP or ASP.
But in ASP.Net using C# this would be:
DataRow[] rows = DataSet.Table[index].Rows;
foreach (DataRow row in rows)
{
Response.Write(…);
}
Looks about the same to me. And you could do this in even less lines with DataBinding.
>The sql integration is very bad in these kind of languages. I don’t
>understand why PHP is so popular in database driven websites. For
>example in harescript i could do:
I full agree with you that the scripting of PHP is somewhat unlogic and mostly unreadable if you are new to it but PHP offers MUCH more than just
database connectivity. I do not know harescript very well but as far as i could read on their website it lacks many features PHP has built in.
Weither is free/open-source softwsre or not is also a very important point..
Another “Apple vs PC”-like argument all over again……..
Isn’t Yahoo enterprise class?
That benchmark is really stupid. The fact is that PHP is seeing the strings as varibles while ASP sees them as constants that it could cancel out durring compilation.
The sad fact is that ASP has not even realised that a loop with nothing in it should be skiped over in pointless cases like that, yet the test shows it does not even know this.
” ASP is just horror. It’s a bad dream come true.
The list of things I loath in ASP is too long to mention.
What where they thinking??? ”
This is where a lot of people disagree with you. I very much prefer ASP over JSP, PHP, and Perl. ASP is a much better scripting language and I feel it corrects the faults and deficiencies that are in the other 2. Since Microsoft helped Covalent and the Apache team with the ASp.NET module for Apache I can now run ASP on Apache and not have to worry about being tied to IIS.
But i would not be microsoftisch if there where not any string attached to it….
MS helped the Covalent team because people who wantto use asp.net on Apache MUST buy Covalent software and thus Covalent is PAYING MS for it, so helped yes but not because they wanted to be innovative but where hungry for more and more…money.
from the article:
With help from Microsoft, Covalent said it was able to develop a module for its Enterprise Ready Server that would allow ASP.Net applications to run on Apache 2.0.
However, organisations that use the freely available Web server will not be able to run ASP.Net applications unless they purchase Covalent’s software. Zemlin said the company was not planning to release an open source version of its .net module.
ASP.NET was not part of the ECMA spec, so by implementing it Mono opens themselves up to being forced into some very unreasonable and discriminatory licensing. There are reasons why people aer worried about the legal position of Mono. So ASP.NET is tied to IIS and Windows, as should Mono with Apache on Linux start to gain enough popularity that it threatens Windows Microsoft will simply tell Mono to pull it, the whole point of the dual stacks being that they can if need be. But enough of that flamefest, onto the main one.
PHP is interpreted, ASP.NET is compiled (to bytecode, then to native machine code on first view). Of course PHP will be slower on benchmarks, this is trying to compare apples with oranges. They are not aimed at the same market.
PHP small sites thrown together quick and cheap.
ASP.NET big business apps intergrated with windows.
“Is” operator used to compare two object references, not for comparision of object values.
If he wants fair comparison it should use ASP analogue of the PHP operator ‘==’.
“PHP small sites thrown together quick and cheap.”
“ASP.NET big business apps intergrated with windows.”
you can also implement a cheap and quick site using ASP.net… I’d even venture that it is easier and faster using tools like webmatrix and vb.net.
ASP is a much better scripting language (…)
You give yourself in for anyone who didn’t know you. ASP isn’t a language, it’s an envelope for VB or other languages.
The benchmark is over a year old, completely unprofessional, and the PHP code is written in such a way that it WILL run slower than it actually can. It’s clear that this person is NOT a professional PHP coder. I am sure that if I decided to run a PHP v.s. ASP “benchmark” of the same caliber, I could easily make PHP faster than ASP, merely because I don’t know ASP at a professional level.
“Benchmarks” like these do nothing to help anyone, and only hurt those who listen.
Also, you should use single quotes for the string constants…
if (“hello” == “world”) { }
should be:
if (‘hello’ == ‘world’) { }
as with double quotes, php will parse the string for embedded variables whatnot (ie. as in “abc $value def”). with single quotes php takes it to be a literal string.
but i must admit – i would have thought the zend accelerator would have optimised the whole loop out to be honest. simple optimisation. i am guessing this is what the asp engine did.
Why can’t PHP be compiled like Asp.net ?
Is there any project attempting this ?
Gnu php compiler ?
Except of course for all and it was inside PHP or ASP.
I like Perl.
The Aps.net weblog link reports an error and throws an SQL Execption. I don’t claim anything on this but seems a good defend of ASP.net !
The ASP.NET code does only compare the reference of the string constants while the PHP code does a stringcompare.
A reference compare just compares the address of the strings, something that can be done in one line of assembly.
The string compare will need to loop through the two strings and compare one and one character. This will obviously take more time than just comparing two address pointers.
I have worked with both and ASP and the biggest problem is actually the webserver. I have had more problems with IIS slowing down the system or crashing or being hacked into. The speed difference between the 2 really isn’t a good comparison as it depends on servers. Oracle really wants to compare databases and that should be the speed comparison since major database queries are computed by the database and really not by PHP or ASP. From my experience they seem to be the same speed on a windows server running both of them.
PHP will overtake ASP due to it being open source. For example you can cut down your programming time because you can get thousands of sample programs for free for your website. ASP can’t match that and the ease with which you can program something in PHP. Since it is open source you can take your code from a Windows machine, to a linux machine, to a Mac without re-coding the whole thing. That is pretty sweet.
I wonder, are you talking about ASP or ASP.Net?
I’m asking because ASP is pretty much being deprecated by MS, their whole investment is on .Net and ASP.Net right now, so I don’t see why bother comparing ASP with anything, ASP is “dead man walking” anyway..
When it comes to ASP.Net vc PHP, now that’s an interesting comparison. I like both a lot, PHP because it’s OSS and a very fine technology, and ASP.Net because I got _huge_ productivity gains with it, the difference from old ASP+COM was really amazing (and C#/.Net is a damn good platform, IMHO)
In a _very_ simplified view, I’d say PHP is great for the internet, and ASP.Net is great for big intranets.
Guess what? ASP.NET only requires the .NET Framework, no IIS required.
ASP.NET requires the .net framework and IIS, at least MS’s version of ASP.NET requires IIS.
If anyone knows how to run ASP.NET on windows via apache then its news to me.
” a _very_ simplified view, I’d say PHP is great for the internet, and ASP.Net is great for big intranets.”
Any opinions on ColdFusion? It’s the only app server I’ve used – running it with MySQL on top of jRun, (which is actually really cool – super flexible) on OS X. I’m a designer by nature, and find it’s HTML like syntax super easy and quite powerful. The code moves flawlessly to both Windows and Linux servers.
My client wants me to help on their intranet using ASP.NET… am I in for a major shock?
” ASP.NET requires the .net framework and IIS, at least MS’s version of ASP.NET requires IIS.
If anyone knows how to run ASP.NET on windows via apache then its news to me.”
Strictly speaking, anyone can implement a server for asp.net that doesn’t require IIS. In fact that’s exactly what Web Matrix does. Same with XSP on Mono. In reality, you currently have to run ASP.NET under IIS on Windows for production environments, but there’s nothing stopping somebody from implementing an Apache module. It may already work under Apache on Windows, although I haven’t tested it yet.
I know of at least one host that’s capable of hosting .NET apps on Apache under Linux; http://www.cityhost.ca
That’s where the MonoDevelop website is hosted, if I’m not mistaken.
My client wants me to help on their intranet using ASP.NET… am I in for a major shock?
Unfortunately, you are. Moving from ColdFusion to ASP.Net, in terms of learning curve, is like moving from HTML to C#, from scripting to full-blown programming (OO included).
Moving from CF to (old) ASP is an easier move though, they have more in common, since both mix HTML and server-side tags to generate the contents. But then again to move from ASP to ASP.Net is the same as above.
I had a lot of fun with ColdFusion in the past (ca. 1997), but the web became so complex on interface and requirements now that I can’t imagine myself using it, it would take forever to do stuff (unless CF became a different product from than the one I knew then)
I’m no expert on PHP but I have done some PHP programming in the last 2 years. And I only do ASP while helping my son with his website so I don’t know much about optimization on ASP. But never the less I have done the following benchmarking comparring ASP (not ASP.NET) and PHP4 both running on my old Linux Server with Chili ASP on Apache 1.3 and PHP on Apache 2.0:
Using scripts from http://www.pzycoman.myby.co.uk/lspeed.html
PHP – 1 million String Comparisons: 7-8 sec
ASP – 1 million String Comparisons: 6-8 sec
PHP – 8 million String Comparisons: 57-58 sec
ASP – 8 million String Comparisons: 52-57 sec
Same script but with double quotes optimization
PHP – 1 million String Comparisons: 3-4 sec
PHP – 8 million String Comparisons: 28-30 sec
My only conclusion is that it’s difficult to compare different languages in a scientific way and that optimization or just writing the code differently can make a big difference!
I think the real test would be on a multi form site where Microsoft’s Asp.Net Event Driven model is going to hurt you.
Multiple round trips to the server to validate each field is going to be the bottleneck for ASP.Net. That’s it’s disadvantage. One, compiled code on the server will not help.
However,
ASP.NET brings the vb6 event model to the web, allowing easy conversion of vb apps, and less JavaScript code.
So easier to write, but slower then the Request/Response model.
The ASP.NET benchmark’s code should use String.Compare to compare strings. The “Is” operator just checks if the reference is the same, it just compares a pointer(ASM CMP).
This kind of do-something-simple-in-a-loop benchmark is almost useless, since it shows only little subset of the language.
“Multiple round trips to the server to validate each field is going to be the bottleneck for ASP.Net. That’s it’s disadvantage.”
Doesn’t work like that. I’m not sure where you got the idea that it did. ASP.NET validation controls provide both client side and server side validation. If the user’s browser has javascript enabled, *no* return trip to the server is required. If the form must be validated on the server for whatever reason, only one trip is made. All the ASP.NET event driven model does is wrap up the Request/Response model in a way that makes it more similar to coding Windows Forms apps. Underneath it all, it’s exactly the same.