4 Web Scripting Languages Compared
monkey crunch writes: "ZDNet is running an article comparing PHP, ColdFusion, JSP, & ASP. Although they don't show the script sources, it's interesting to note that PHP garnered the highest performance of the bunch. From the article, PHP: 49pps, ASP: 43pps, CF: 29pps, JSP: 13pps" PHP did gather the highest pps, but it's interesting to also note what the article gave top honors. In any case, it's an interesting topic, but remember: use what's best for you. Don't use what you feel you "have" to.
You can't separate the tool from the kind of craftsman and job it is intended for. The reason I mention this is that comparing these scripting languages this way abstracts out the most critical details
Thus, when you look at the "cost (Developer time)" score, what you are really looking at depends on the composition your team. It's just plain stupid to rank JSP/servlets as "C" and ASP as "B"; there are applications a skilled programmer can do with JSP that would be nearly impossible in ASP. In that case, JSP would be "A" and ASP would be "D". On the other hand, if you are relying your already overtaxed and underskilled Microsoft only IT app development department to deploy some very simple dynamic content, then ASP would rate "A" and JSP would rate "D" for cost.
By the way, about a and a half year ago I took my small company kicking and screaming to Zope. I built a standard page framework with consistent but customizable layout, navigational elements and decorations. Was this costly -- you bet. We wasted untold time arguing over content that users provided that had hard coded positions, dimensions, font sizes, and IE only HTML extensions. However, once I got these people out of the layout business into the content business, we ended up with a web site that is consistent, professional, and constantly updated with no technical skills required at all.
Moral: the cost to deploy is not necessarily related to the cost to maintain.
Post may contain irony: discontinue use if experiencing mood swings, nausea or elevated blood pressure.
I'm suprised by the developer cost/learning score they gave to PHP. I always thought PHP was very easy to learn, even easier than ASP. PHP always takes less code than ASP in my experience. You don't end up with the "Response.Write" when all you mean is "print". Don't get me started about "MoveNext". Arg!
On the other hand, I do think PHP needs a more consistent DB API. (I think they are working on it.) But ASPs is only consistant because there is only really one direct way, ODBC. If you only used ODBC on PHP all your code would be more portable among DBs. But it's much more fun to use FreeTDS to hit a MS SQL server with a Linux/Apache/PHP server than an expensive ODBC driver.
I've also found that all of our contractors that we have hired that know ASP learn PHP very quickly. They all have the same comments about the PHP code being much smaller and easier to read. VBScript that is used in most ASP pages just doesn't quite fit the web as well as PHP.
And another thing. ColdFusion is the cheap way to start a web project? I guess that fits if you rate PHP hard to learn and expensive to develop, but $5000 is a hard price to take up against free for almost anything else. Sounds like Dilbert logic to me. The most expensive product will obviously make our programmers more productive.
For the first time the benchmarks where not the main focus of the article, but the ease of uses and development time in getting to market. I do stand behind their opinion of ColdFusio being something that is easy to get going and something built in one weeks time, but then you will run into the same problem w/PHP.. a bunch of code that is not reusable.
Tomcat/JAVA is a great development platform. The PagePerSecond is not that relavent because you can load balance hardware and
I do agree that there are some performance issues with Tomcat, but those are easily fixed by using something like Resin (GPL) or Orion (Commercial). Lots of small companies are looking for quick and dirty solutions that fit the budget. (Free)
--------------------
I've been developing with most of these "web" scripting languages this past year, and I can tell you one thing about all of them:
They suck.
Yes, it's true.. ColdFusion is nice for rapid, small applcations, but anything over that you will be grinding your teeth because of limitations of the language.
PHP.. PHP is in the same boat, but you can develop middle-sized applications before grinding your teeth. The language itself feels likc one giant hack and there is WAY to much built-in, no module support to speak of, and the "unified" DB driver sucks (ODBC has a performance hit). It's shoddy OOP and function support causes headaches.
Java Servlets take FOREVER and a day to develop; ColdFusion and PHP beat the pants off of Java anyday; However, like I was telling my boss, "With Java, everything looks like a nail..."
Can't speak for ASP, but I can say...
Python. It's a better language (syntax, semantics, libraries, modules, OOP) than PHP any day.
Am I the only one who finds this statement on the second page of the article funny??
"When performance does become important, various techniques are available that can make dramatic differences in speed. For example, Microsoft Corp. has rewritten the Nile benchmark we used in these tests..."
So that's how you get the big speed, to hell with the application, rewrite the benchmark itself! *grin*
Neutron
I get my kicks above the
With JSP's performance measurement may be a bit more of an art than with the others. Since the JSP container (eg Tomcat) is often configured to compile any .jsp that has changed, it may have a serious performance hit attributed to it. However, that _feature_ is meant for development and would be turned of in deployment: all the .jsp files are pre-compiled.
As well, the JVM used makes quite a large performance difference. The Win32 JVM with Hotspot, seriously outperforms some of the other JVM's (orders of magnitude difference). I don't really know about the Linux JVM's, but I have heard that they underperform relative to Sun's Win32 JVM.
Basically, the performance aspect of the article is completely bogus: utilizing two completely different OS platforms is just the start of the problems!
Helping with organizational effectiveness is our job.
I write Cold Fusion all the time, every day, and I have to say it's damn easy to learn and use (and write badly, but that's something else). If all you know is HTML the tag structure won't confuse you and so on. BUT...I just picked up PHP a few months ago and I love it. So much nicer. So much easier to read. Even though my Cold Fusion is still much stronger than my PHP, I would never recommend using Cold Fusion.
Perl can't be taken seriously as a high-end web site development language. For large complex sites (slashdot really isn't either - it's a very straightforward single application), perl just doesn't have the performance one needs, and it is very difficult to maintain.
Sure, perl works great as a quick way to put out code that works - but remember that it was designed as a report language, not a dynamic content engine. While there's an apparent similarity of these two tasks, they scale very differently.
"It is our blasphemy which has made us great, and will sustain us, and which the gods secretly admire in us." - Zelazny
Why are the various scripting languages in such overwhelming favor?
For two reasons, and they're both true:
(i) A lot of web programmers simply don't have the background to use professional development standards, nor the attention span nor attention to detail required for successful non-trivial programming in C or C++. As a result, if they used these relatively low-level tools the result would be fairly horrendous. It's *much* easier to generate buggy code in inherently unsafe languages than in safe scripting ones. Pragmatically, it makes sense.
(ii) The web moves at a break-neck pace, and there just isn't the time to produce a well engineered product using C/C++ before the requirements have changed yet again. Scripting languages allow you to make ad hoc changes without blowing your whole foot off every time. Errors tend to be comparatively minor, easy to diagnose, and the language usually stays in control rather than bombing out altogether.
In a nutshell, scripting languages make a lot of sense in this application area. That said, they're definitely not the answer to everything.
"The question of whether machines can think is no more interesting than [] whether submarines can swim" - Dijkstra
From personal experience I would put ColdFusion and PHP tied for the top slot. CF is cleaner and easier for building small apps but PHP has MUCH better support and is better for medium size apps. Not to mention the easiest to learn. ASP sucks. Really there is no such thing as ASP since its really a hodgepodge of VBScript, JScript and HTML. With Microsoft's .NET it gets even worse with 16+ languages available. PHP is simple, has decent string handling and excellent online support. PHP+Apache+MySQL is a killer combo. Want an easy install? Check out PHPTriad for Windows. Chances are than any question you could come up with has been asked and answered in one os the the support groups.
"God fights on the side with the best artillery." - Napoleon, Marshal of France - speaking truth to power
PHP is an evolved language, and it really shows. There wasn't a conscious and conservative philosophy behind it. That's both a plus and a minus -- but I think more minus than plus. Everything is there, and that's great -- but it's hard to find it, or when reading code to figure out where it came from.
I can also understand why they didn't cover Perl or Python, because both of these aren't really web scripting languages, they are general purpose. Of course, there are HTML embedded versions of both of them but they don't seem to have caught on, which is too bad. And Zope/DTML/Python isn't really scripting either, but considerably more than that (though I'm under the impression that Cold Fusion attempts to be something similar).
This article is rather simplistic and poor, both in content and in conclusions. I will not discuss the fact that the "winner" is probably the only potential advertiser (PHP does not advertise, Microsoft and Sun won't advertise only for yet another article about ASP or JSP), but let us see what was left out, misinterpreted or plainly wrong:
a) Python, Perl: How do you write a serious article about web scripting languages leaving these two out? Perl is the mother of all scripting language, Python is a rising star with lots of supporters and amj already huge codebase. And both perform as well as any of the examined technologies.
b) Their priorities were "of speedy development, ease of use, and a complete and powerful API". In a real corporate environment, maintainability and portability would probably outshine all three, ruling CF and ASP out (my opinion, yuor mileage may vary) and leaving the stage for PHP, Python and JSP (more or less in this order, from worst to best).
c) How on earth would COM support make ASP harder to write? In my experience, access to COM objects let you write smaller and sipler scripts.
d) PHP is probably as easy as ASP to learn, it fells rather natural to any C/C++ programmer and it has probably the most powerful API for Web programming of the pack. The the author did not had the time or the will to learn the APIs ("Users must make a concerted effort to keep track of the indepen dently changing components of PHP they are using")
e) Also, the lack of an standardized database API in PHP is botha curse and a blessing. First, there are some PHP libraries out there addressing this issue. Second, the trade here is speed for convenience. Third, all data acess function were made similar, so changing database is not harder than it should be. And finally, PHP supports ODBC.
f) Tomcat is a reference implementation. There are faster alternatives out there.
I will not go on. Forget this article.
If you need speed, ease of use, a fair price (let us say, zero or less), good portability and good mantainability, use PHP, Python or JSP. Or even, if you are really sure your code will never have to leave a Windows box, ASP/COM.
ASP isn't a language. Its a container for other languages. Its used with VBscript, JavaScript and PerlScript, alongside HTML (And others..). There are no commands in ASP.
As far as I remember ASP was designed to be a sort of glue that holds together a bunch of custom COM objects and DLLs. It was designed to be an operating environment.
In my experience building dynamic web sites (not much.. few years) ASP and PerlScript, with a drop of VB in times of boredom, have always been a good, flexible team. Depends what you're doing..
http://twitter.com/onion2k
Perl can't be taken seriously as a high-end web site development language.
Howso? Oh wait, I think I hear something:
For large complex sites (slashdot really isn't either - it's a very straightforward single application), perl just doesn't have the performance one needs, and it is very difficult to maintain.
Where's the proof? Mod_Perl takes up a whack of memory, sure, but the speed is right in line with the rest of them. What large, complex site doesn't have a cluster of machines with a shitload of memory on each? And as far as your maintainability arguement goes... I can show you code in just about any language which is a nightmare to maintain. Hell I could show you spaghetti code in C++ which I personally thought was impossible until I started cleaning up one particular in-house project.
Perl may seem to facilitate nasty coding practises but in reality it all comes down to the programmers. Are they going for geek machismo or are they working toward something which is maintainable? Perl has a wonderfully clean OO syntax; I prefer it to C++. The built-in regexps are great for formatting stuff after the database has had its try.
Perl ain't perfect, but it is certainly up to the task, IMO.
Is this a joke ?
PHP has been here since 1994. It's older than the other languages in the chart.
Also, they state that PHP has no uniform database API: This is false:
You can use ODBC for all kinds of database. However, you have the alternative of using the direct APIs to improove performance.
Meanwhile you will have ended up with two different languages to support in the same production environment. This may not be a problem for a small design shop where you have a couple developers that know both languages and the code that everybody works on; but in a big company environment, it makes life very difficult.
Despite being a useful "hack language" to create small, simple contraptions; PHP is not exactly the most readable/maintainable language on Earth. Add to that the thousands of Web designers who believe they became programmers by just writing some simple logic in PHP, and you have a lot of poorly written code in a poorly documented (yes, I know about the online manual. Go see for yourself how poorly Oracle functions in PHP are documented, for example.) language. Just like Perl, the flexibility and power comes at the expense of readability and maintainability.
I fail to understand why anybody would want to use PHP with JavaBeans if they know enough about Java to figure thise setup in the first place. I don't think there is anything in particular that you can do with PHP but not with JSP. I don't think the JSP functionality can extend any more, since anything that can be done on the server side in Java can be done in a JSP page.Zigbee Central: A Zigbee weblog
Try Zope. www.zope.org
ZSQL Methods are completely independant of your actual database and you can change your external database with a couple of clicks (if you need an external one in the first place. Zope has a long running persistant object system of its own which keeps instances of things alive along with their data until you specifcally delete them - even between reboots!
The underlying Python DB access is specific to whatever database you use but in Zope Land it is wrappered around Zope DB drivers which the ZSQL Methods talk to. Similar to what the DB.php stuff in PHP4 does but with a more compelling reason to use it.
They also encourage code resuse as you can template your queries just like your HTML..
SELECT * FROM users
<dtml-if username>
WHERE user=<dtml-var username>
</dtml-if>
Then when you call them, their magic happens and out pops the results in a python list.
Made me wonder if they included Zope in this round up if Zope would have A or D for tools, its web interface being its own tool really.
Phill
I used to do a bit of WebObjects development back in the OpenStep days. WebObjects had three great things going for it: great tools, fantastic database connectivity middleware, and really solid web scripting and tag extentions. Recently, I have been doing Java 2 Enterprise Edition development. At my day job, I am working in a high availability application server environment, and in my night job, I am prototyping a educational web system. In that second role I am using JSP's. (Dislaimer: I love Java compared to C++ but hate it compared to Objective-C.) As the article points out, the tool support is missing, and I personally find JDBC to be a pretty weak database interface, but the actual JSP technology is really cool! I've been working on custom tag extentions and they really rock - solving the problem of separating display code (html) from business logic and model code (accomplished with the use of JavaBeans and EJB's). Personally, I think that the Java platform is the way to go in the long run. JSP's are a really good step to completing the platform and the Tomcat reference implementation is a great tool for prototyping.
Helping with organizational effectiveness is our job.
Anyone who has to design, implement and support large, web-based applications should check out Cocoon.
Neutron
I get my kicks above the
Have you written any large projects in PHP? I mean really large, mission-critical projects. If so you'll quickly see that while it has strong points, it's far from perfect.
The database connectivity is far from perfect, and ODBC isn't the magic bullet some people like to think it is. While you can use ODBC to connect to an Oracle database, it will offer significantly lower performance than using the ora_ functions.
If you want an example of the lack of uniformity in the database API, look at odbc_fetch_row, it takes a statement handle, and optionally a row number. If the row number is omitted, it returns the next row. Now look at pg_fetch_row, it takes a statement handle, and a mandatory row number. If you omit the row number, it just plain doesn't work.
Look at the functionality of something as simple as 'break'. One would assume that break would exit any looping construct, whether it be for, foreach, or while. Well, you'd be right that it exits for or while, but it doesn't exit a foreach.
And there are other inconsistencies too, which are obnoxious, for example 'is_array, is_long, is_dir, and is_double' all do what you'd expect. but it's not 'is_set', it's 'isset'. If you take a reference to $this in the constructor for an object, it's not the same reference that the new class returns. (Bug 7454)
And they're right, debugging support for PHP is horrible. The debuggers that are out there only work on certain versions, so if you're doing development against the CVS version of PHP in order to get the latest bug fixes, they won't work, because of changes to the Zend internals. error_log is the equivalent of debugging with printf, and if you add your own error handler, there's a bug which prevents it from showing the error message. (Bug 7283).
PHP has been here since 1994, but it's been massively rewritten at least twice. Once in PHP3, and again for PHP4. It has a lot of potential, enough that I'm using it on large, important projects. But I wouldn't dream of using it on a large, important project that had to be done in 2 weeks. The language still needs time to stabalize.
--
"Don't trolls get tired?"
Anyone have any recommendations for a good JSP server? I've used Apache JServ for a while and it's horribly unstable, frequently locking up and requiring a kill -9. Tomcat seems nice, but I was unable to get it working over SSL even after many hours of tweaking config files. I've been planning on looking into Enhydra, which I've heard good things about.
Any others I should be considering?