Click to See Complete Forum and Search --> : ColdFusion and PHP (not another "vs." rant)


jonez
02-10-2003, 07:04 PM
http://www.devx.com/macromedia/Article/10631 is a recent Macromedia piece about switching from PHP to ColdFusion. OK, well, maybe this is mostly wishful thinking on Macromedia's part with a lot more people actually looking to switch from closed and arguablye dead-ended ColdFusion to open and growing PHP but the article does make some reasonable points about the conciseness of ColdFusion and as a newbie trying to make a case for PHP vs. some entrenched ColdFusion folks I'd appreciate any informed, constructive response from PHP experts.

One specific question I have is whether there is any style guidelines or add-ons that provide cfquery/cfoutput capabilities in PHP with equivalent simplicity.

Another question is re: the conditional inclusion example in the piece - this one just seems bogus to me, I mean can't this be trivially done in PHP?

Finally, the comments about session-state-handling in PHP vs. ColdFusion are of interest. I'm curious with Yahoo! et. al. deploying PHP maybe the issues presented here wrt PHP's session state handling are less major than they are made out to be?

abx_2112
02-10-2003, 09:23 PM
quoting the macromedia guy:

"And finally, if you are done with the recordset, you must free the results and close the connection:


<?php
mysql_free_result($rsGetOrders);
mysql_close($connMysqlbookstore);
?> "


You are not longer required to close your connections and free your results when using PHP.

Another thing: thanks to PEAR's DB abstraction layer you are not that dependent of your db choice. It's also good because you'll need less code when asking for a db connection. So don't worry, your code wont look as ugly as he's trying to make it look.

As a side note, he says:
"Another thing you'll notice from the code is that the database MySQL is specified. The PHP code will not work with any other database. You can't simply upgrade your database to MS SQL Server—because the code will not work."

Well, does anyone considers that as an UPGRADE? this makes me think about the reliability of his assertions.

2. About the mail:

This is all you need to send an email:
$status = mail ( $to, $subject, $body, "From:$from\nReply-To:$from" );
This guy spent 10 lines of ugly code to make it look that bad.

You can also use an include file that sets your $body variable. It's easy.

Anyway i recomend you look at PEAR again since they may have some cool functionalities ( i admit the mail tag is cool)

3. Conditional includes.

I use it very frequently, there's no problem with that.

Well i wont extend on the rest of the article. Let me just say that PHP OOP is evolving towards the kind of necessities CF is adressing right now, and MORE (much more).

The thing is. CF reduces you coding time ... sometimes ... a bit.
:)

Let me put it this way: If you want an application that scales easy time wont be saved by choosing one Language or Another. Most of the time will be spent defining the achitecture. Actually it will be easier to overcome a larger number of problems using PHP since it has TONS of features to help you out, that's one thing i've missed coding CF.

You may want to understand this guy's "productivity" as how fast can you code a one in a life-time non-scalable solution.

Dont take everything he says for granted. I'm sure CF is great, but I still prefer PHP. It simply rocks

- abx_

jerdo
02-10-2003, 10:30 PM
You must also look at the source of this article it is by a guy who makes his living off of Macromedia's products so of course he is going to skew the article to php is hard and messy, Macromedia products are easy and clean. As abx said, most of his php code was produced to make it look difficult when he very easily could have done the same thing in fewer lines. An example of which is his creating an array for the mail body and then using join, when he could have used an include type structure like he did in his ColdFusion example. I'm not even scratching the surface on his biased statements, the example about the pulling information from the database and displaying is a big one "The ColdFusion code has several advantages that are evident right from the start: it's shorter and more concise. It's also much easier to understand exactly what the code does, even without programming knowledge. " When to me they look pretty much the same other than his drawn out method of extracting the data in php. As for the session question you present, I don't think they get much more simple than php. Another benefit of php is that it doesn't cost any money to run it on your server, where as with ColdFusion you have to purchase the server software from Macromedia, so when it comes time to install/update php will be free and can be used across platforms, ColdFusion will cost and if they offer it on different platforms you will have to buy a copy for each different platform. The cost factor should be enough for a business to want to look a little harder at php.

Weedpacket
02-11-2003, 06:37 AM
I've worked with ColdFusion here and there in the past; more than once because I was converting a site to PHP. The results were smaller in size (both on the server and client-side - coldfusion-generated files tend to have idiotic amounts of gratuitous whitespace), had a few extra thingies, ran faster, and ran on the server the site was being moved to.

I don't see how understanding PHP will make it easier to switch to ColdFusion any more than understanding any other programming language; if PHP is such a rotten language as he makes out, why does he reckon it would be easy to switch?

He also claims that "PHP sessions are file based". True, but that's only the default - not everyone who has PHP has a database - and you can write your own session handlers.

"ColdFusion s a sophisticated session-handling mechanism that works even if the user has cookies turned off". Well, yeah. So does PHP. Is this supposed to be a point of difference, or is it one of those things that would make a transition easy?

Basically, the reason why this article came about is obvious. Macromedia wanted to push ColdFusion MX and hired this guy to write a beat-up about it, and try to make it sound better than the current front-runner in the server-side scripting language field (its chief competition).

It's interesting that the author missed one advantage of ColdFusion over PHP that is illustrated by his article. You don't need a username or password to log into a MySQL database with ColdFusion ;)

cahva
02-11-2003, 06:59 AM
PHP hard and messy? Yes it is if you use Dreamweavers "Click'n'Go" features. I tried the MySQL and the forms wizard and damn it makes messy php code.

Personally I havent tried CF at all so I cant comment on that.
But DreamweaverMX is a wonderful piece of software when coding ;)

Elizabeth
02-11-2003, 10:54 AM
Seeing as how I have a marketing background, I find this article quite interesting in it's portrayal of PHP. The author was careful not to really "bad-mouth" PHP - as is the cardinal rule in marketing. He touts that the "switch will be easy, if you have to change because of project requirements or in the event that you would want to make yourself more productive..." (duh, who wouldn't?). But he is careful to never say PHP is a terrible language because he knows better.

I'm also curious as to who the target audience was for this article. If it was PHP developers, then surely they would see the misrepresentations embedded in the article (the "oh so long" mail script for example). Personally, it doesn't convince me to switch, and I'm fairly new to the PHP environment. I'm sure more seasoned PHP veterans are not swayed either. I would value a truly non-biased comparison a lot more than a one-sided one (perhaps if he had one some big PHP awards along with his Macromedia awards, then we'd talk :) )

I like my Dreamweaver, don't get me wrong... but it seems to me that Macromedia should be embracing PHP instead of feeling threatened by it.

I did a lot of research way back when, while I was trying to decide the future of our dynamically driven website, and the results were resoundingly in favor of the PHP/MySQL combo... for ease of use, capabilities, and of course the price.

-Elizabeth

Elizabeth
02-11-2003, 11:01 AM
Oh, you all would probably be interested to read the NEARLY IDENTICAL article about switching from ASP to ColdFusion, written by the same guy (imagine that!)

http://www.devx.com/macromedia/Article/10486

He could have at least rephrased the darn thing. :D

-Elizabeth

jonez
02-11-2003, 12:40 PM
Thanks for the responses so far - yep, clearly this is a marketing piece targeted at suits or semi-suits not hard-core developers. Once again though I'm looking to fight fire with fire. The points made are good ... but ... I still don't feel like I have a complete answer.

It really seems to be about the level of abstraction. The joking comment about database id & pwd seems like a good example - of course the id & pwd is in fact required by mySQL no matter what language you use to generate SQL queries but it's just that in ColdFusion this is handled in configuration code, underneath the covers. PHP provides what seems to me to be a set of lower-level and thus more powerful/flexible building blocks but at the same time with this power & flexibility comes a certain amount of exposed complexity.

That is, unless it is hidden away by an abstraction. I don't know whether PEAR or equivalent provide this but I don't see why a function with the power of "CFOutput" couldn't be provided in PHP. That would IMO be a very good answer to the ColdFusion propaganda.

jerdo
02-11-2003, 04:46 PM
I still think the best answer to the suits is PHP is FREE and ColdFusion is EXPENSIVE, most suits like to look at the bottom line. Considering PHP is very likely capable of everything that ColdFusion can do, maybe more, then the price would be the only issue for the suits in charge of the money.

Weedpacket
02-11-2003, 05:31 PM
Originally posted by jonez
PHP provides what seems to me to be a set of lower-level and thus more powerful/flexible building blocks but at the same time with this power & flexibility comes a certain amount of exposed complexity.

There's a mathematical proof to the effect that a certain amount of complexity in any given program is unavoidable: the question is how much you hide away in the language and how much you expose in the code. While you're hiding away stuff you need to predict what the language will be used for and how; people using the language will then be guided or even constrained by your decisions.

ColdFusion may be "easy and simple to learn" (in comparison to PHP), but how often are you going to be doing that? What's important is further down the track, when you're using the language on a regular basis in your normal line of work. How will what is provided affect your thinking about problems? What will you do if the functionality provided isn't quite what you want - could you plausibly craft a more suitable alternative yourself? Will you be finding yourself frustrated at not being able to "get at" the problem with the available tools? Could you (say) write your own MySQL connection/transaction routines in the given language without recourse to any of its native functionality?

PHP is almost certainly a harder slog in the beginning - especially for people with no prior programming experience (those who have formerly worked in Perl or C or even VB will find it less of a wrench), but once you've settled in - well, repeat the questions in the previous paragraph.

While plenty has already been bundled into PHP's existing functionality, it still leaves you with all the machinery to do the work yourself (how many of PHP's functions can be written entirely in PHP?) - which also means that others can write their own more abstract APIs to do what they wanted, not what some corporate decided they wanted.

Maybe ColdFusion (CFScript?) does allow one to work as close to the coalface as PHP; but I don't see any of that in the article. Of course, the author would pick applications that would suit his point. The problem I would have with that is that it introduces an arbitrary conceptual break in the language between "tags" and "script".



An interesting exercise would be to find a master PHP programmer and a master ColdFusion programmer (and chuck in Perl and ASP/VBScript while we're at it), and see how they cope with a variety of typical (and not-so-typical) applications (Default installs of each; no extra third-party apps except a common DBMS). Eg: a discussion forum; a weblog; an image upload/thumbnail-generation/gallery app; a shopping site w/ cart; a web spider; an online Scrabble tournament.


Another thing to ponder: Which would be easier: a ColdFusion emulator written in PHP, or a PHP emulator written in ColdFusion?

[Edit: Oh, yeah. "Less typing = more time working on the meat of your program". Since programmers generally spend only 5-10% of their time typing anyway, half-a-dozen characters more or less is not about to make much impact. That said, I much prefer $i++ to ADD 1 TO I GIVING I...]

$SuperString
02-12-2003, 05:52 AM
Coldfusion eh.... That brings back memories.
I worked as a Coldfusion developer for nearly 2 years (up untill early last year). I used V4/4.5 and the few updates in 5, havn't touched MX though. The last I new (before Macromedia bought Alliare out) was that Coldfusion was moving greatly towards Java in its next release (code name neo or something). So that said I can't comment on MX.
Anyway The main big difference Coldfusion has over other Server-Side scripting languages is that it has its own Server (as well as needing a Web Server also), Its pretty powerful and has many good features easily administered. Its error trapping and sessions are also pretty good (as long as you know how to use them properly). But thats were it stops. The syntax is very easy for HTML coders to pick up, but it just doesnt seem like real scripting (those damn tag based languages !!). I mean, you have to right a hundred line application to do something very simple in most cases. and you cant even create functions (in V 4/4.5), the best you can get to functions is custom tags (realy just a clever structured include file).
Personally I prefer PHP as its just as powerful (probably much more powerful), the syntax is far better with much more control left with the programmer. Also PHP does run on far more platform at a much less cost.
Just think I my company were to migrate from PHP to Coldfusion, they would have to cough-up 300* Coldfusion Server Licenses, that a lot of money !!!

abx_2112
02-12-2003, 12:53 PM
At work I have similar discussions with a friend who codes in CF MX (I do all of my stuff in PHP) and we always find a lot of situations where one makes things "easier" than the other. While CF has specific structures for you to loop through record sets, PHP has an unbelievable function repository and so on... well I dont think I have to make a list for you to understand.

So, you may want to do a case by case evaluation. Keeping in mind price, scalability, support, availability, expirience, development community, etc. and then decide which technology suits better your needs. Personally, as I said on a previous reply, I prefer php for large scale projects with strange functionalities (I even like it for small implementations but I still want to give some credit to CF).

Now, what I do want to make clear is how silly it is for one to base the arguments on code -quoting jerdo- "produced to make it look difficult". This lowers the level of the discussion, and I think these are the ones that encourage positive changes on both sides which end up benefiting the end user.

- abx_

A side note, the previous reply said:
I mean, you have to right a hundred line application to do something very simple in most cases. and you cant even create functions (in V 4/4.5)
CF MX has full support for functions now. CF Components even allow a very good OOP support. PHP does too, but i would like to see more features for this kind of support, like abstract classes, destructors, etc.

Weedpacket
02-13-2003, 12:02 AM
Just came across a comment by Larry Wall that seems relevant to this thread:

(Source document here (http://dev.perl.org/perl6/apocalypse/A03.html))
My overriding design principle has always been that the complexity of the solution space should map well onto the complexity of the problem space. Simplification good! Oversimplification bad! Placing artificial constraints on the solution space produces an impedence mismatch with the problem space, with the result that using a language that is artificially simple induces artificial complexity in all solutions written in that language.

[Edit: Don't you hate people who change their URLs on you?]

mystrymaster
08-23-2003, 10:06 AM
I have learned both and had no prior programming experience. I did find php a little easier to learn from a personal standpoint.

When I was working with Coldfusion (about 2 years ago) I found myself basing my solutions on what coldfusion could do rather then what I can do. With PHP I think of the best possible solution and then figure out how I can make php do that.

drawmack
08-23-2003, 11:22 AM
I find it intriging that those links won't load in opera. If it don't load in opera it ait wirth seeing is my motto

Merve
08-26-2003, 12:27 PM
I find Cold Fusion really weird. I tried to learn it, but I gave up after half and hour. That's how much time it took me to learn basic PHP.

I really am against Cold Fusion. The website of the public library of my city uses Cold Fusion servers, as well as some other municipal websites. I don't think that this can be justified. First of all, Cold Fusion isn't really a great choice for what they are using the website for. Second of all, how can they justify using taxpayers' money to pay the Macromedia guys? The server is slow, very slow, and there are constant errors. It really makes me mad. In fact, it messed up the whole library system because there was an error in the code and it messed up the online reservation process.

So use what you will, but every time I see .cfm I shudder.

minorgod
09-11-2003, 02:58 PM
Originally posted by Weedpacket
There's a mathematical proof to the effect that a certain amount of complexity in any given program is unavoidable...

Looks like someone's been reading too much Stephen Wolfram :) Oh, and I totally concur with the above opinion that CF is an inane server language that should pull an SVG and just go away. You all know SVG right? It's, that amazing vector graphics 'standard' proposed by that noble open-source stalwart Adobe (sarcasm). Seriously though, at least 50% of the CF-based sites I visit are RIFE with errors and about 10% of the time I end up seeing exposed database errors that reveal sensitive application logic. If the language itself weren't bad enough, the sloppy CF programming community makes the language look like a joke in half the sites I've looked at. Obviously, some programmers are being tasked to write CF pages by marketing and management idiots who don't bother to send the programmers to any CF training classes and who wouldn't know a good reason to choose CF over PHP if it bit them on the ass (which it usually does). Macromedia should dump CF and write products for the existing robust scripting languages such as PHP and ASP. CF is a total waste of time and money IMHO.

Weedpacket
09-12-2003, 08:54 AM
Originally posted by minorgod
Looks like someone's been reading too much Stephen Wolfram :) Gregory Chaitin, as it happens (e.g., "On the Simplicity and Speed of Programs for Computing Infinite Sets of Natural Numbers", J. ACM 16 (1969); pp407-422)
Okay, so I had to look it up to get the exact citation.