AdobeStock_455007340

Defending ColdFusion Against PHP

PHP is not one that comes up often, there is not a significant overlap between PHP developers and ColdFusion developers. But, in the interests of presenting the complete story, here is what you need to know.
PHP is also script based, pages contain code which are processed by the PHP engine. The PHP engine itself is open source, and the PHP language uses a syntax borrowed from C, Java, and Perl (the latter is important, as PHP is particularly popular with former Perl developers). PHP runs on all sorts of systems, and uses functions and API for all sorts of processing.
PHP’s stated goal (as per the official PHP FAQ) is to “allow web developers to write dynamically generated pages quickly”. Ironically, developers with both CFML and PHP experience will tell you that while PHP development may be quicker than using C or Java, it does not come close to that of ColdFusion and CFML.
There is no refuting PHP’s power, PHP developers have an impressive and rich set of functions and language extensions available, and that is definitely part of PHP’s appeal. But this power comes at a cost, it takes a lot more PHP code to do what simple CFML tags do, and as explained before, more code = greater cost. If you truly need that power, than PHP may indeed be an option worth considering (although CFML+Java would likely give you the same power and more). But if what you really need is to “write dynamically generated pages quickly”, then PHP leaves much to be desired.
One of the most compelling arguments for PHP is its cost, there is none. But the cost of software is only one part of the total cost of application development, arguably the least significant coast in the long run. It is for this reason that despite being incredibly popular with developers and consulting shops, corporate users have been slow to adopt PHP as a development platform (which in turn is why the PHP versus ColdFusion discussion comes up so infrequently).
The bottom line is if you really need the power and flexibility of PHP, and can justify the longer development cycles and more code to manage and maintain, then PHP should seriously be considered. But if time to completion and total cost of ownership are an issue, then ColdFusion wins hands down.

17 responses to “Defending ColdFusion Against PHP”

  1. Paul McDonald Avatar
    Paul McDonald

    For some further reading on this subject, read Eric Jones’ article on Sitepoint: http://www.sitepoint.com/article/making-case-coldfusion

  2. Daniel Roberts Avatar
    Daniel Roberts

    interesting article but then this was odd…nothing about encapsulation, OOP, etc

    "ColdFusion Components – CFCs
    With the release of ColdFusion MX, Macromedia introduced the idea of ColdFusion Components (aka CFCs). These are a great leap for ColdFusion, and are one of the most popular features of the new system. See ColdFusion Components, an Introduction for more details.
    One of the greatest features of CFCs is the ability to document your code without having to throw in a bunch of comment tags. By using the "hint" attribute in your CFC files and <cffunction>s, you can tell future users what your CFC does, what the individual methods (also referred to as functions) do, and what kinds of data they take (input) and display (output). You can then browse directly to the CFC, type in your administrator credentials and receive a very nice output of this information.
    If you’ve ever had to document your code, you’ll know what a royal pain it can be. I’ve found this feature to be invaluable in my day to day operations. Since the documentation changes with the code, it’s also very dynamic, so you can rest assured that your current documentation will include the new features you just added."

  3. Arindam Biswas Avatar
    Arindam Biswas

    Daniel,
    Probably because of PHP 5.0, Ben thought it was not quite necessary to make that difference, though there might be other issues as well. Components are a great future no doubt, couple that with Mach-ii and its industrial strength material, arguably. Inheritence issues exist (super), so do missing in action Interfaces among others. However, being a CF fanatic i have both, faith and hope, that the team at Macromedia have the right solutions in BlackStone. I do hope that I get a shot at the beta to try out just the EventGateway if not more. FTP folder drops could mean a different thing altogether!!!

  4. Daniel Roberts Avatar
    Daniel Roberts

    Sorry for the confusion. I was referring to the article by Eric Jones suggested in the first comment above: http://www.sitepoint.com/article/making-case-coldfusion

  5. Daniel Roberts Avatar
    Daniel Roberts

    I just click through to the article referenced by Eric Jones that he wronte about CFCs (http://www.sitepoint.com/article/components-introduction). and now my comments are very worthless — is it friday yet? uggg 🙂

  6. Nathan Strutz Avatar
    Nathan Strutz

    PHP is free? Not if you want it to perform quickly, especially on an enterprise level. If you want PHP to run with actual speed and stability, you need to buy the Zend accelerator. Looks like it’s about $500.

  7. since1968 Avatar
    since1968

    Nice set of articles Ben, thanks for posting. I think another plus in favor of PHP is the size of the developer community — it seems to be substantially larger than the CF developer community.

  8. Chris Phillips Avatar
    Chris Phillips

    Their developer community may be big…
    But, who, tell me who, is friendlier than the CF developer community.

  9. John C. Bland II Avatar
    John C. Bland II

    LOL Chris. That is remarkebly true. The PHP’ers I know are religious about PHP and will argue to the bone about PHP being better (main issue I’ve heard is CF uses tags and they hate the idea of <cf for almost everything. lol).

  10. Ryan Avatar
    Ryan

    Would going to production with Bluedragon’s free standalone server be equivalent to going to production with Macromedia’s standalone Coldfusion Server (the $1300 version), in terms of performance and stability?
    And how does the free Bluedragon Server stacks up to a standard install of PHP on Windows 2K Server in terms of speed and stability?
    I know a lot has to do with coding practices, etc, especially when it comes to making sure you write clean code with PHP. But simply in terms of power – is Bluedragon Server on par with Zend Engine I when both are used with IIS?
    Thanks for any help.

  11. mark Avatar
    mark

    ive tried asp, php and coldfusion and whilst CF is the easiest to use (especially cuz im a wizz at html) it just costs too damned much to host it.
    so for me ASP wins (php blearhgh :P)
    mark

  12. Palyne Avatar
    Palyne

    ColdFusion, CFML is awesome, I’ve been a fan developer for 5 years now. But I’m moving toward PHP (with mySQL or, well, almost anything) for use instead of CF and SQL-Server, as the monthly server cost for myself and my clients using CF is just too high, period. It makes me mad that after all this time decent MS-based server costs are still a problem. Not to mention trying to afford an actual complete install for a dedicated server.
    Every client and potential client I talk to who has that kind of money would frankly rather spend it on java so they can have programmers doing more in the way of graphics or mathematics etc.; those without much money want the database power but would rather try PHP since it’s free.
    Here I am a CF developer, yet arguing my case is tough. Thanks for the help via essay Ben; but I don’t think it’ll change the reality of this part of the issue.

  13. brad Avatar
    brad

    Dear Mr. Forta,
    I started in ColdFusion because of the fact that an auxiliary department contracted for a Content Management system in CF for a good number of Bucks (plus the software). I attended a number of local CFUG meetings including a great presentation by Mr. Forta about [then new] MX, I was thrilled at what seemed only possible prior to that with Perl scripts… then I wasn’t allowed to work on the server ’cause the IT Suit that paid for it wanted to get my boss fired (the actual CF practitioners were very generous with server and info including recommending the Forta books), but the Suit shut me down.
    Without a budget to work with, I went to PHP. What a happy development as it turned out.
    You say that the development time is longer and that adds to cost. You fail to mention how many open source complete projects are available for FREE with ZERO development cost. For a quick example check out either Mambo Open Source CMS or phpBB — both incredibly valuable tools for anyone with clients to serve. I put up a Mambo site in 30 minutes and a phpBB forum in less than an hour — including the time to customize the look and feel. How’s that for cost effective?
    Any mention of Zend products is a false premise. Zend created the Zend Engine for PHP for FREE, and it works just great. That they might want to get paid for the bells and whistles seems reasonable, but the basic stuff works great and is extremely dependable and powerful.
    Getting set up? Yep, PHP is harder… maybe you could spend $20 for Sokkit which sets up a WAMP server in less than an hour including reading the documentation.
    Further, at a PHP conference Rasmus Lerdorf said something that I think is perfectly apt for the Cold Fusion "it’s simple because it’s a tag" old saw. He said, "Don’t Hide the Problem!" and that is what ColdFusion promised to do for you — but by the time they do all the backflips to make everything a "tag" they have made what should be simple into this circuitous scramble all over the map. It is so much simpler to say, "I need to code now" and break into PHP and then say, "Okay back to HTML" and break out of PHP as often and whenever you like. Render unto HTML/CSS that which is layout and render unto PHP that which is dynamic content and logic.
    Next, "Ease of Use?" — My story doesn’t end. The Suit did get my boss fired and the Suit had to offer me a job rewriting my stuff into ColdFusion. Not being independently wealthy I repressed the "Take this job and shove it" impulse and accepted the job until something better came along. Upon returning to CF and the very well written Ben Forta books, I learned just how much effort it takes to do things in "easy" ColdFusion.
    Say you want a form to serve both as the form for new records and editing existing records (and don’t even go there with other ways of skinning the cat, that is always true, this is a legitimate example for how "easy" CF is laborious compared to "scary" PHP) — so anyway, you want a form to serve as both the "new record" form and the "edit record" form, if an ID is supplied, go get the data and prepopulate the form, if not, leave a blank form.
    In CF you need to have (and I forget the exact syntax now) something like:
    value="<CFOUTPUT>
    <CFIF isempty(#cfparam.recordid#)>

    <CFELSE>
    #query.firstname#
    </CFIF>
    </CFOUTPUT>"
    Wow! That was easy!
    Now let’s look at the same effect in PHP:
    value="<?php echo @$firstname ?>"
    Whew! That nearly killed me and all that extra development time!
    Cold Fusion is fine, and Ben Forta writes great books, and CF Developers are very nice people — but once you get past the simple drill-down of the Orange Whip Studio it is nice to have a real programming/scripting language at your disposal.
    Of course, for people that start with HTML and want to go dynamic then ColdFusion is easier, but those are just glorified web designers! And that is not a knock on those individuals. Indeed that is why they invented CSS isn’t it? If your are primarily a designer (and I have the utmost respect for these people) then you shouldn’t be coding, and if you are primarily a coder then you should really stay away from design — again, that’s why I hire a designer to do my CSS based on core XHTML tags most times [see csszengarden.com]. Once you separate design from content this "advantage" to ColdFusion disappears and ColdFusion is just difficult for designers and insufficient for coders.
    Finally, if you really want the "warm fuzzies" that Cold Fusion gives you, then you can use "Smarty", which is an open source tool that is as simple as ColdFusion, and is essentially a layer of abstraction for PHP so that designers don’t mess up the code. It is PHP for people that think that "echo("Hello World");" is too complicated — to me making PHP simpler is redundant, but thousands of people swear by it.
    Please, as impassioned as this is, it is not a slam on ColdFusion or the CF community at all — I ate a lot of pizza with you guys at CFUG events. But the "ease of use" claim is just unfounded.
    Best wishes.

  14. Kevin Avatar
    Kevin

    Worst example ever…. what the heck are you trying to do?
    <CFOUTPUT>
    <CFIF isempty(#cfparam.recordid#)>

    <CFELSE>
    #query.firstname#
    </CFIF>
    </CFOUTPUT>

  15. Tami Burke Avatar
    Tami Burke

    As a developer on both CF and PHP platforms I have extensive experience with both. And, having started dynamic development using PHP, ColdFusion was overly stiff, and overly structured. I feld I was back in the old COBOL days. However, it didn’t take long before I realized that CF did indeed speed up my development cycle time…. so significantly that I am almost exclusively coding in it now. I realized almost a 50% reduction in coding time using ColdFusion over PHP. And I noticed that it did also do a better job of allowing me to create "plug-in" modules for similar projects.
    Sure, the same can be done w/ PHP, but much more forethought, planning, and inherent knowledge of the language is required. PHP is so very flexible, that it’s power becomes its tragic downfall in many situations.
    🙂 T.B

  16. Ian Skinner Avatar
    Ian Skinner

    (and don’t even go there with other ways of skinning the cat, that is always true, this is a legitimate example for how "easy" CF is laborious compared to "scary" PHP). Why not go there. It is fair to compare a badly written piece of speghitti code to a nice clean example in another language and say, "There, my languguage is better".
    What magic code fairy in PHP forces you to not write bad spaghetti code?
    Other examples you forbid me from going to.
    value="#iif(recordID,DE(#query.firstname#),DE(""))#"
    Now that does seem to be a few more characters then your php example, but not overwellimingly so.
    Now does one example prove the point?

  17. Kevin Avatar
    Kevin

    Wouldnt value= iif(recordID,DE(query.firstname),DE("")) make it just a bit cleaner.
    PHP and CFML both have their place.
    I still prefer CFML.

Leave a Reply